From 9dc6017e5a0beb0f77fcc5b69b5d07004e05b0e9 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 26 Jun 2011 21:07:00 +0200 Subject: [PATCH] fixed tree table --- htdocs/frontend/javascripts/entities.js | 10 ++++---- htdocs/frontend/javascripts/entity.js | 34 ++++++++++++++----------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/htdocs/frontend/javascripts/entities.js b/htdocs/frontend/javascripts/entities.js index 3146047..0287d92 100644 --- a/htdocs/frontend/javascripts/entities.js +++ b/htdocs/frontend/javascripts/entities.js @@ -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'); } diff --git a/htdocs/frontend/javascripts/entity.js b/htdocs/frontend/javascripts/entity.js index 7a2ae0f..8afd4ff 100644 --- a/htdocs/frontend/javascripts/entity.js +++ b/htdocs/frontend/javascripts/entity.js @@ -199,9 +199,9 @@ Entity.prototype.getDOMDetails = function(edit) { return table.append(data); }; -Entity.prototype.getDOMRow = function() { +Entity.prototype.getDOMRow = function(parent) { var row = $('') - .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($('') - .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($('') + .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'