aboutsummaryrefslogtreecommitdiff
path: root/js/panels/binding/edit-binding-view.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/binding/edit-binding-view.reel')
-rw-r--r--js/panels/binding/edit-binding-view.reel/edit-binding-view.js74
1 files changed, 31 insertions, 43 deletions
diff --git a/js/panels/binding/edit-binding-view.reel/edit-binding-view.js b/js/panels/binding/edit-binding-view.reel/edit-binding-view.js
index 5ee8c65a..46fe9681 100644
--- a/js/panels/binding/edit-binding-view.reel/edit-binding-view.js
+++ b/js/panels/binding/edit-binding-view.reel/edit-binding-view.js
@@ -32,7 +32,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
32 sourceObjectIdentifier : { 32 sourceObjectIdentifier : {
33 get : function() { return this._sourceObjectIdentifier; }, 33 get : function() { return this._sourceObjectIdentifier; },
34 set : function(value) { 34 set : function(value) {
35 console.log("Source object IDENTIFIER changed");
36 if(value === this._sourceObjectIdentifier) { return; } 35 if(value === this._sourceObjectIdentifier) { return; }
37 36
38 this._sourceObjectIdentifier = value; 37 this._sourceObjectIdentifier = value;
@@ -45,7 +44,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
45 boundObjectIdentifier : { 44 boundObjectIdentifier : {
46 get : function() { return this._boundObjectIdentifier; }, 45 get : function() { return this._boundObjectIdentifier; },
47 set : function(value) { 46 set : function(value) {
48 console.log("Bound object IDENTIFIER changed");
49 if(value === this._boundObjectIdentifier) { return; } 47 if(value === this._boundObjectIdentifier) { return; }
50 48
51 this._boundObjectIdentifier = value; 49 this._boundObjectIdentifier = value;
@@ -69,7 +67,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
69 67
70 if(value) { 68 if(value) {
71 this.sourceObjectPropertyPathField.hints = this.application.ninja.objectsController.getPropertiesFromObject(value); 69 this.sourceObjectPropertyPathField.hints = this.application.ninja.objectsController.getPropertiesFromObject(value);
72 console.log("Setting hints to: ", this.sourceObjectPropertyPathField.hints);
73 } 70 }
74 71
75 this.needsDraw = true; 72 this.needsDraw = true;
@@ -81,12 +78,10 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
81 get : function() { return this._boundObject; }, 78 get : function() { return this._boundObject; },
82 set : function(value) { 79 set : function(value) {
83 if(value === this._boundObject) { return; } 80 if(value === this._boundObject) { return; }
84 console.log("Bound Object being set to ", value);
85 this._boundObject = value; 81 this._boundObject = value;
86 82
87 if(value) { 83 if(value) {
88 this.boundObjectPropertyPathField.hints = this.application.ninja.objectsController.getPropertiesFromObject(value); 84 this.boundObjectPropertyPathField.hints = this.application.ninja.objectsController.getPropertiesFromObject(value);
89 console.log("Setting hints to: ", this.boundObjectPropertyPathField.hints);
90 } 85 }
91 86
92 this.needsDraw = true; 87 this.needsDraw = true;
@@ -97,12 +92,8 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
97 sourceObjectPropertyPath : { 92 sourceObjectPropertyPath : {
98 get : function() { return this._sourceObjectPropertyPath; }, 93 get : function() { return this._sourceObjectPropertyPath; },
99 set : function(value) { 94 set : function(value) {
100 console.log("Source Object Property Path being set to ", value);
101
102 if(value === this._sourceObjectPropertyPath) { return; } 95 if(value === this._sourceObjectPropertyPath) { return; }
103 96
104
105
106 this._sourceObjectPropertyPath = value; 97 this._sourceObjectPropertyPath = value;
107 98
108 this.needsDraw = true; 99 this.needsDraw = true;
@@ -156,27 +147,28 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
156 // clear form values 147 // clear form values
157 this.clearForm(); 148 this.clearForm();
158 149
159 // set up hints for hintable components 150 if(value) {
160 this.objectIdentifiers = this.getObjectIdentifiers(); 151 // set up hints for hintable components
161 console.log("setting hints to ", this.objectIdentifiers); 152 this.objectIdentifiers = this.getObjectIdentifiers();
162 this.boundObjectField.hints = this.objectIdentifiers; 153 this.boundObjectField.hints = this.objectIdentifiers;
163 this.sourceObjectField.hints = this.objectIdentifiers; 154 this.sourceObjectField.hints = this.objectIdentifiers;
155
156 if(value.sourceObject) {
157 this.sourceObjectIdentifier = value.sourceObject.identifier || value.sourceObject._montage_metadata.label;
158 this.sourceObjectPropertyPath = value.sourceObjectPropertyPath || '';
159 }
164 160
165 if(value.sourceObject) { 161 if(value.boundObject) {
166 this.sourceObjectIdentifier = value.sourceObject.identifier || value.sourceObject._montage_metadata.label; 162 this.boundObjectIdentifier = value.boundObject.identifier || '';
167 this.sourceObjectPropertyPath = value.sourceObjectPropertyPath || ''; 163 this.boundObjectPropertyPath = value.boundObjectPropertyPath || '';
168 } 164 this.isNewBinding = false;
165 } else {
166 this.isNewBinding = true;
167 }
169 168
170 if(value.boundObject) { 169 this.oneway = value.oneway;
171 this.boundObjectIdentifier = value.boundObject.identifier || '';
172 this.boundObjectPropertyPath = value.boundObjectPropertyPath || '';
173 this.isNewBinding = false;
174 } else {
175 this.isNewBinding = true;
176 } 170 }
177 171
178 this.oneway = value.oneway;
179
180 this.needsDraw = true; 172 this.needsDraw = true;
181 } 173 }
182 }, 174 },
@@ -199,25 +191,29 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
199 191
200 clearForm : { 192 clearForm : {
201 value: function() { 193 value: function() {
202 for(var field in this) { 194 var fields = ["sourceObjectField",
203 if(this.hasOwnProperty(field)) { 195 "boundObjectField",
204 field.value = ''; 196 "sourceObjectPropertyPathField",
205 } 197 "boundObjectPropertyPathField"];
206 } 198
199 fields.forEach(function(fieldName) {
200 this[fieldName].value = "";
201 }, this);
202
203 this._bindingArgs = null;
204
207 this.dirty = false; 205 this.dirty = false;
208 } 206 }
209 }, 207 },
210 208
211 saveForm : { 209 saveForm : {
212 value: function() { 210 value: function() {
213 debugger;
214
215 var controller = this.application.ninja.objectsController, 211 var controller = this.application.ninja.objectsController,
216 newBindingArgs = { 212 newBindingArgs = {
217 sourceObject : this.sourceObject, 213 sourceObject : this.sourceObject,
218 sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value, // TODO: shouldn't need to do this (get from bound property) 214 sourceObjectPropertyPath : this.sourceObjectPropertyPath,
219 boundObject : this.boundObject, 215 boundObject : this.boundObject,
220 boundObjectPropertyPath : this.boundObjectPropertyPathField.value, // TODO: shouldn't need to do this 216 boundObjectPropertyPath : this.boundObjectPropertyPath,
221 oneway: this.oneway 217 oneway: this.oneway
222 }; 218 };
223 219
@@ -274,7 +270,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
274 handleEvent : { 270 handleEvent : {
275 value: function(e) { 271 value: function(e) {
276 if(e._event.type === 'change') { 272 if(e._event.type === 'change') {
277 console.log("here we are");
278 this.dirty = true; 273 this.dirty = true;
279 } 274 }
280 } 275 }
@@ -286,8 +281,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
286 281
287 templateDidLoad : { 282 templateDidLoad : {
288 value: function() { 283 value: function() {
289
290
291 Object.defineBinding(this, 'sourceObject', { 284 Object.defineBinding(this, 'sourceObject', {
292 boundObject: this, 285 boundObject: this,
293 boundObjectPropertyPath: 'sourceObjectIdentifier', 286 boundObjectPropertyPath: 'sourceObjectIdentifier',
@@ -301,7 +294,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
301 oneway: false, 294 oneway: false,
302 converter : objectIdentifierConverter.create() 295 converter : objectIdentifierConverter.create()
303 }); 296 });
304
305 } 297 }
306 }, 298 },
307 299
@@ -317,9 +309,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, {
317 controller = this.application.ninja.objectsController, 309 controller = this.application.ninja.objectsController,
318 category; 310 category;
319 311
320 this.sourceObjectIconElement.className = defaultIconClass;
321 this.boundObjectIconElement.className = defaultIconClass;
322
323 if(this.sourceObject) { 312 if(this.sourceObject) {
324 this.sourceObjectIconElement.classList.remove('no-object'); 313 this.sourceObjectIconElement.classList.remove('no-object');
325 category = controller.getObjectCategory(this.sourceObject).toLowerCase(); 314 category = controller.getObjectCategory(this.sourceObject).toLowerCase();