diff options
author | Armen Kesablyan | 2012-06-18 19:12:32 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-18 19:12:32 -0700 |
commit | 1b2e102b3519994c79b63be44fccb79cf5712fef (patch) | |
tree | f38534a7d8a3dc75909419a4bd823db73f771435 /js/panels/binding/edit-binding-view.reel/edit-binding-view.js | |
parent | 2fcb74d0b204ce2999b70fa9a46fc58a558344d8 (diff) | |
parent | e04903ed2d2e6754119550cb071e03878bb1b14b (diff) | |
download | ninja-1b2e102b3519994c79b63be44fccb79cf5712fef.tar.gz |
Merge pull request #16 from ericguzman/binding
Objects Tray - Moved to stage object from binding view
Diffstat (limited to 'js/panels/binding/edit-binding-view.reel/edit-binding-view.js')
-rw-r--r-- | js/panels/binding/edit-binding-view.reel/edit-binding-view.js | 83 |
1 files changed, 45 insertions, 38 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 62a47aaf..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 | |||
@@ -65,6 +65,10 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
65 | 65 | ||
66 | this._sourceObject = value; | 66 | this._sourceObject = value; |
67 | 67 | ||
68 | if(value) { | ||
69 | this.sourceObjectPropertyPathField.hints = this.application.ninja.objectsController.getPropertiesFromObject(value); | ||
70 | } | ||
71 | |||
68 | this.needsDraw = true; | 72 | this.needsDraw = true; |
69 | } | 73 | } |
70 | }, | 74 | }, |
@@ -74,9 +78,12 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
74 | get : function() { return this._boundObject; }, | 78 | get : function() { return this._boundObject; }, |
75 | set : function(value) { | 79 | set : function(value) { |
76 | if(value === this._boundObject) { return; } | 80 | if(value === this._boundObject) { return; } |
77 | console.log("Bound Object being set to ", value); | ||
78 | this._boundObject = value; | 81 | this._boundObject = value; |
79 | 82 | ||
83 | if(value) { | ||
84 | this.boundObjectPropertyPathField.hints = this.application.ninja.objectsController.getPropertiesFromObject(value); | ||
85 | } | ||
86 | |||
80 | this.needsDraw = true; | 87 | this.needsDraw = true; |
81 | } | 88 | } |
82 | }, | 89 | }, |
@@ -85,12 +92,8 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
85 | sourceObjectPropertyPath : { | 92 | sourceObjectPropertyPath : { |
86 | get : function() { return this._sourceObjectPropertyPath; }, | 93 | get : function() { return this._sourceObjectPropertyPath; }, |
87 | set : function(value) { | 94 | set : function(value) { |
88 | console.log("Source Object Property Path being set to ", value); | ||
89 | |||
90 | if(value === this._sourceObjectPropertyPath) { return; } | 95 | if(value === this._sourceObjectPropertyPath) { return; } |
91 | 96 | ||
92 | |||
93 | |||
94 | this._sourceObjectPropertyPath = value; | 97 | this._sourceObjectPropertyPath = value; |
95 | 98 | ||
96 | this.needsDraw = true; | 99 | this.needsDraw = true; |
@@ -144,26 +147,27 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
144 | // clear form values | 147 | // clear form values |
145 | this.clearForm(); | 148 | this.clearForm(); |
146 | 149 | ||
147 | // set up hints for hintable components | 150 | if(value) { |
148 | this.objectIdentifiers = this.getObjectIdentifiers(); | 151 | // set up hints for hintable components |
149 | console.log("setting hints to ", this.objectIdentifiers); | 152 | this.objectIdentifiers = this.getObjectIdentifiers(); |
150 | this.boundObjectField.hints = this.objectIdentifiers; | 153 | this.boundObjectField.hints = this.objectIdentifiers; |
151 | this.sourceObjectField.hints = this.objectIdentifiers; | 154 | this.sourceObjectField.hints = this.objectIdentifiers; |
152 | 155 | ||
153 | if(value.sourceObject) { | 156 | if(value.sourceObject) { |
154 | this.sourceObjectIdentifier = value.sourceObject.identifier || value.sourceObject._montage_metadata.label; | 157 | this.sourceObjectIdentifier = value.sourceObject.identifier || value.sourceObject._montage_metadata.label; |
155 | this.sourceObjectPropertyPath = value.sourceObjectPropertyPath || ''; | 158 | this.sourceObjectPropertyPath = value.sourceObjectPropertyPath || ''; |
156 | } | 159 | } |
157 | 160 | ||
158 | if(value.boundObject) { | 161 | if(value.boundObject) { |
159 | this.boundObjectIdentifier = value.boundObject.identifier || ''; | 162 | this.boundObjectIdentifier = value.boundObject.identifier || ''; |
160 | this.boundObjectPropertyPath = value.boundObjectPropertyPath || ''; | 163 | this.boundObjectPropertyPath = value.boundObjectPropertyPath || ''; |
161 | this.isNewBinding = false; | 164 | this.isNewBinding = false; |
162 | } else { | 165 | } else { |
163 | this.isNewBinding = true; | 166 | this.isNewBinding = true; |
164 | } | 167 | } |
165 | 168 | ||
166 | this.oneway = value.oneway; | 169 | this.oneway = value.oneway; |
170 | } | ||
167 | 171 | ||
168 | this.needsDraw = true; | 172 | this.needsDraw = true; |
169 | } | 173 | } |
@@ -187,25 +191,29 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
187 | 191 | ||
188 | clearForm : { | 192 | clearForm : { |
189 | value: function() { | 193 | value: function() { |
190 | for(var field in this) { | 194 | var fields = ["sourceObjectField", |
191 | if(this.hasOwnProperty(field)) { | 195 | "boundObjectField", |
192 | field.value = ''; | 196 | "sourceObjectPropertyPathField", |
193 | } | 197 | "boundObjectPropertyPathField"]; |
194 | } | 198 | |
199 | fields.forEach(function(fieldName) { | ||
200 | this[fieldName].value = ""; | ||
201 | }, this); | ||
202 | |||
203 | this._bindingArgs = null; | ||
204 | |||
195 | this.dirty = false; | 205 | this.dirty = false; |
196 | } | 206 | } |
197 | }, | 207 | }, |
198 | 208 | ||
199 | saveForm : { | 209 | saveForm : { |
200 | value: function() { | 210 | value: function() { |
201 | debugger; | ||
202 | |||
203 | var controller = this.application.ninja.objectsController, | 211 | var controller = this.application.ninja.objectsController, |
204 | newBindingArgs = { | 212 | newBindingArgs = { |
205 | sourceObject : this.sourceObject, | 213 | sourceObject : this.sourceObject, |
206 | sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value, // TODO: shouldn't need to do this (get from bound property) | 214 | sourceObjectPropertyPath : this.sourceObjectPropertyPath, |
207 | boundObject : this.boundObject, | 215 | boundObject : this.boundObject, |
208 | boundObjectPropertyPath : this.boundObjectPropertyPathField.value, // TODO: shouldn't need to do this | 216 | boundObjectPropertyPath : this.boundObjectPropertyPath, |
209 | oneway: this.oneway | 217 | oneway: this.oneway |
210 | }; | 218 | }; |
211 | 219 | ||
@@ -273,8 +281,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
273 | 281 | ||
274 | templateDidLoad : { | 282 | templateDidLoad : { |
275 | value: function() { | 283 | value: function() { |
276 | |||
277 | |||
278 | Object.defineBinding(this, 'sourceObject', { | 284 | Object.defineBinding(this, 'sourceObject', { |
279 | boundObject: this, | 285 | boundObject: this, |
280 | boundObjectPropertyPath: 'sourceObjectIdentifier', | 286 | boundObjectPropertyPath: 'sourceObjectIdentifier', |
@@ -288,7 +294,6 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
288 | oneway: false, | 294 | oneway: false, |
289 | converter : objectIdentifierConverter.create() | 295 | converter : objectIdentifierConverter.create() |
290 | }); | 296 | }); |
291 | |||
292 | } | 297 | } |
293 | }, | 298 | }, |
294 | 299 | ||
@@ -304,23 +309,26 @@ var editBindingView = exports.EditBindingView = Montage.create(Component, { | |||
304 | controller = this.application.ninja.objectsController, | 309 | controller = this.application.ninja.objectsController, |
305 | category; | 310 | category; |
306 | 311 | ||
307 | this.sourceObjectIconElement.className = defaultIconClass; | ||
308 | this.boundObjectIconElement.className = defaultIconClass; | ||
309 | |||
310 | if(this.sourceObject) { | 312 | if(this.sourceObject) { |
313 | this.sourceObjectIconElement.classList.remove('no-object'); | ||
311 | category = controller.getObjectCategory(this.sourceObject).toLowerCase(); | 314 | category = controller.getObjectCategory(this.sourceObject).toLowerCase(); |
312 | 315 | ||
313 | if(category) { | 316 | if(category) { |
314 | this.sourceObjectIconElement.classList.add('object-icon-'+category); | 317 | this.sourceObjectIconElement.classList.add('object-icon-'+category); |
315 | } | 318 | } |
319 | } else { | ||
320 | this.sourceObjectIconElement.classList.add('no-object'); | ||
316 | } | 321 | } |
317 | 322 | ||
318 | if(this.boundObject) { | 323 | if(this.boundObject) { |
324 | this.boundObjectIconElement.classList.remove('no-object'); | ||
319 | category = controller.getObjectCategory(this.boundObject).toLowerCase() || null; | 325 | category = controller.getObjectCategory(this.boundObject).toLowerCase() || null; |
320 | 326 | ||
321 | if(category) { | 327 | if(category) { |
322 | this.boundObjectIconElement.classList.add('object-icon-'+category); | 328 | this.boundObjectIconElement.classList.add('object-icon-'+category); |
323 | } | 329 | } |
330 | } else { | ||