fixed tree table

This commit is contained in:
Steffen Vogel 2011-06-26 21:07:00 +02:00
parent 3edf0e6654
commit 9dc6017e5a
2 changed files with 24 additions and 20 deletions

View file

@ -98,9 +98,9 @@ vz.entities.showTable = function() {
vz.entities.sort(Entity.compare);
var c = 0; // for colors
this.each(function(entity) {
this.each(function(entity, parent) {
entity.color = vz.options.plot.colors[c++ % vz.options.plot.colors.length];
$('#entity-list tbody').append(entity.getDOMRow());
$('#entity-list tbody').append(entity.getDOMRow(parent));
}, true); // recursive!
/*
@ -143,15 +143,15 @@ vz.entities.showTable = function() {
queue.push(from.removeChild(child)); // remove from aggregator
}
else {
vz.uuids.remove(child.uuid); // remove from cookies
vz.uuids.save();
child.cookie = false; // remove from cookies
vz.entities.saveCookie();
}
} catch (e) {
vz.wui.dialogs.exception(e);
} finally {
$.when(queue).done(function() {
// wait for middleware
vz.entities.loadDetails().done(vz.entities.showTable);
$.when(from.loadDetails(), to.loadDetails).done(vz.entities.showDetails);
});
$(this).dialog('close');
}

View file

@ -199,9 +199,9 @@ Entity.prototype.getDOMDetails = function(edit) {
return table.append(data);
};
Entity.prototype.getDOMRow = function() {
Entity.prototype.getDOMRow = function(parent) {
var row = $('<tr>')
.addClass((this.parent) ? 'child-of-entity-' + this.parent.uuid : '')
.addClass((parent) ? 'child-of-entity-' + parent.uuid : '')
.addClass((this.definition.model == 'Volkszaehler\\Model\\Aggregator') ? 'aggregator' : 'channel')
.addClass('entity')
.attr('id', 'entity-' + this.uuid)
@ -251,18 +251,20 @@ Entity.prototype.getDOMRow = function() {
)
)
.data('entity', this);
$('td.ops', row).prepend($('<input>')
.attr('type', 'image')
.attr('src', 'images/delete.png')
.attr('alt', 'delete')
.bind('click', this, function(event) {
vz.entities.remove(event.data);
vz.entities.saveCookie();
vz.entities.showTable();
vz.wui.drawPlot();
})
);
if (this.cookie) {
$('td.ops', row).prepend($('<input>')
.attr('type', 'image')
.attr('src', 'images/delete.png')
.attr('alt', 'delete')
.bind('click', this, function(event) {
vz.entities.remove(event.data);
vz.entities.saveCookie();
vz.entities.showTable();
vz.wui.drawPlot();
})
);
}
return row;
};
@ -314,10 +316,11 @@ Entity.prototype.addChild = function(child) {
if (this.definition.model != 'Volkszaehler\\Model\\Aggregator') {
throw new Exception('EntityException', 'Entity is not an Aggregator');
}
return vz.load({
controller: 'group',
identifier: this.uuid,
url: this.middleware,
data: {
uuid: child.uuid
},
@ -332,6 +335,7 @@ Entity.prototype.removeChild = function(child) {
return vz.load({
controller: 'group',
identifier: this.uuid,
url: this.middleware,
data: {
uuid: child.uuid,
operation: 'delete'