aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/rule-list.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/css-panel/rule-list.reel')
-rw-r--r--js/panels/css-panel/rule-list.reel/rule-list.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/js/panels/css-panel/rule-list.reel/rule-list.js b/js/panels/css-panel/rule-list.reel/rule-list.js
index 4ed3ec11..8d179248 100644
--- a/js/panels/css-panel/rule-list.reel/rule-list.js
+++ b/js/panels/css-panel/rule-list.reel/rule-list.js
@@ -25,7 +25,7 @@ exports.RuleList = Montage.create(Component, {
25 console.log('list: ', list); 25 console.log('list: ', list);
26 this._rules = list; 26 this._rules = list;
27 27
28 ///// remove previsouly added rules 28 ///// remove previously added rules
29 if(this.childComponents){ 29 if(this.childComponents){
30 this.childComponents.forEach(function(ruleComponent) { 30 this.childComponents.forEach(function(ruleComponent) {
31 this.removeRule(ruleComponent); 31 this.removeRule(ruleComponent);
@@ -50,7 +50,10 @@ exports.RuleList = Montage.create(Component, {
50 value: [], 50 value: [],
51 distinct: true 51 distinct: true
52 }, 52 },
53 53 rulesToRemove : {
54 value: [],
55 distinct: true
56 },
54 addRule: { 57 addRule: {
55 value: function(rule) { 58 value: function(rule) {
56 var componentBase = this.supportedRules[rule.type], 59 var componentBase = this.supportedRules[rule.type],
@@ -73,6 +76,14 @@ exports.RuleList = Montage.create(Component, {
73 } 76 }
74 }, 77 },
75 78
79 removeRule : {
80 value: function(rule) {
81 this.childComponents.splice(this.childComponents.indexOf(rule), 1);
82 this.rulesToRemove.push(rule);
83 this.needsDraw = true;
84 }
85 },
86
76 update : { 87 update : {
77 value: function() { 88 value: function() {
78 this.childComponents.forEach(function(component) { 89 this.childComponents.forEach(function(component) {
@@ -106,11 +117,18 @@ exports.RuleList = Montage.create(Component, {
106 this.rulesToDraw.forEach(function(component) { 117 this.rulesToDraw.forEach(function(component) {
107 this.element.appendChild(component.element); 118 this.element.appendChild(component.element);
108 this._needsScrollToBottom = this.needsDraw = true; 119 this._needsScrollToBottom = this.needsDraw = true;
120 this.childComponents.push(component);
109 component.needsDraw = true; 121 component.needsDraw = true;
110 }, this); 122 }, this);
111 123
124 //// Iterate through all rules that need draw and append them
125 this.rulesToRemove.forEach(function(component) {
126 this.element.removeChild(component.element);
127 }, this);
128
112 ///// Null out any rules that were just drawn 129 ///// Null out any rules that were just drawn
113 this.rulesToDraw.length = 0; 130 this.rulesToDraw.length = 0;
131 this.rulesToRemove.length = 0;
114 } 132 }
115 } 133 }
116}); 134});