aboutsummaryrefslogtreecommitdiff
path: root/js/panels/binding/edit-binding-view.reel/edit-binding-view.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-06-15 15:02:30 -0700
committerArmen Kesablyan2012-06-15 15:02:30 -0700
commit022e2ba65070ee1e5eb2d4b197b88768a1ea3f4f (patch)
tree57ee0bd85f89d8b9c880337e14224536690810a4 /js/panels/binding/edit-binding-view.reel/edit-binding-view.js
parent60e9ea67e0f6d0cf167b6d5068e2e01db5f67966 (diff)
parent62c7c2ac7b72c7e89611d064eef1f4f77a54696d (diff)
downloadninja-022e2ba65070ee1e5eb2d4b197b88768a1ea3f4f.tar.gz
Merge pull request #13 from ericguzman/binding
Added Objects Tray
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.js173
1 files changed, 155 insertions, 18 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 10f427af..62a47aaf 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
@@ -5,10 +5,13 @@
5 </copyright> */ 5 </copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component,
9 Converter = require("montage/core/converter/converter").Converter;
9 10
10 11
11exports.EditBindingView = Montage.create(Component, { 12var editBindingView = exports.EditBindingView = Montage.create(Component, {
13 sourceObjectIconElement : { value: null },
14 boundObjectIconElement : { value: null },
12 15
13 objectIdentifiers : { 16 objectIdentifiers : {
14 value: null 17 value: null
@@ -22,25 +25,90 @@ exports.EditBindingView = Montage.create(Component, {
22 }, 25 },
23 26
24 /* ------------------- 27 /* -------------------
25 Binding Properties 28 Object Identifier (for associating with object)
26 ------------------- */ 29 ------------------- */
27 30
31 _sourceObjectIdentifier : { value: null },
28 sourceObjectIdentifier : { 32 sourceObjectIdentifier : {
29 value: "", 33 get : function() { return this._sourceObjectIdentifier; },
30 distinct: true 34 set : function(value) {
31 }, 35 if(value === this._sourceObjectIdentifier) { return; }
32 sourceObjectPropertyPath : { 36
33 value: "", 37 this._sourceObjectIdentifier = value;
34 distinct: true 38
39 this.needsDraw = true;
40 }
35 }, 41 },
42
43 _boundObjectIdentifier : { value: null },
36 boundObjectIdentifier : { 44 boundObjectIdentifier : {
37 value: "", 45 get : function() { return this._boundObjectIdentifier; },
38 distinct: true 46 set : function(value) {
47 if(value === this._boundObjectIdentifier) { return; }
48
49 this._boundObjectIdentifier = value;
50
51 this.needsDraw = true;
52 }
53 },
54
55
56 /* -------------------
57 Binding Properties
58 ------------------- */
59
60 _sourceObject : { value: null },
61 sourceObject : {
62 get : function() { return this._sourceObject; },
63 set : function(value) {
64 if(value === this._sourceObject) { return; }
65
66 this._sourceObject = value;
67
68 this.needsDraw = true;
69 }
70 },
71
72 _boundObject : { value: null },
73 boundObject : {
74 get : function() { return this._boundObject; },
75 set : function(value) {
76 if(value === this._boundObject) { return; }
77 console.log("Bound Object being set to ", value);
78 this._boundObject = value;
79
80 this.needsDraw = true;
81 }
82 },
83
84 _sourceObjectPropertyPath : { value: null },
85 sourceObjectPropertyPath : {
86 get : function() { return this._sourceObjectPropertyPath; },
87 set : function(value) {
88 console.log("Source Object Property Path being set to ", value);
89
90 if(value === this._sourceObjectPropertyPath) { return; }
91
92
93
94 this._sourceObjectPropertyPath = value;
95
96 this.needsDraw = true;
97 }
39 }, 98 },
99
100 _boundObjectPropertyPath : { value: null },
40 boundObjectPropertyPath : { 101 boundObjectPropertyPath : {
41 value: "", 102 get : function() { return this._boundObjectPropertyPath; },
42 distinct: true 103 set : function(value) {
104 if(value === this._boundObjectPropertyPath) { return; }
105
106 this._boundObjectPropertyPath = value;
107
108 this.needsDraw = true;
109 }
43 }, 110 },
111
44 _oneway: { 112 _oneway: {
45 value: null 113 value: null
46 }, 114 },
@@ -130,13 +198,15 @@ exports.EditBindingView = Montage.create(Component, {
130 198
131 saveForm : { 199 saveForm : {
132 value: function() { 200 value: function() {
201 debugger;
202
133 var controller = this.application.ninja.objectsController, 203 var controller = this.application.ninja.objectsController,
134 newBindingArgs = { 204 newBindingArgs = {
135 sourceObject : this.getObjectFromIdentifierValue(this.sourceObjectField.value), 205 sourceObject : this.sourceObject,
136 sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value, 206 sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value, // TODO: shouldn't need to do this (get from bound property)
137 boundObject : this.getObjectFromIdentifierValue(this.boundObjectField.value), 207 boundObject : this.boundObject,
138 boundObjectPropertyPath : this.boundObjectPropertyPathField.value, 208 boundObjectPropertyPath : this.boundObjectPropertyPathField.value, // TODO: shouldn't need to do this
139 oneway: this.oneway 209 oneway: this.oneway
140 }; 210 };
141 211
142 if(this.isNewBinding) { 212 if(this.isNewBinding) {
@@ -201,9 +271,76 @@ exports.EditBindingView = Montage.create(Component, {
201 Draw Cycle 271 Draw Cycle
202 ------------------- */ 272 ------------------- */
203 273
274 templateDidLoad : {
275 value: function() {
276
277
278 Object.defineBinding(this, 'sourceObject', {
279 boundObject: this,
280 boundObjectPropertyPath: 'sourceObjectIdentifier',
281 oneway: false,
282 converter : objectIdentifierConverter.create()
283 });
284
285 Object.defineBinding(this, 'boundObject', {
286 boundObject: this,
287 boundObjectPropertyPath: 'boundObjectIdentifier',
288 oneway: false,
289 converter : objectIdentifierConverter.create()
290 });
291
292 }
293 },
294
204 prepareForDraw : { 295 prepareForDraw : {
205 value: function() { 296 value: function() {
206 297
207 } 298 }
299 },
300
301 draw : {
302 value: function() {
303 var defaultIconClass = 'object-icon',
304 controller = this.application.ninja.objectsController,
305 category;
306
307 this.sourceObjectIconElement.className = defaultIconClass;
308 this.boundObjectIconElement.className = defaultIconClass;
309
310 if(this.sourceObject) {
311 category = controller.getObjectCategory(this.sourceObject).toLowerCase();
312
313 if(category) {
314 this.sourceObjectIconElement.classList.add('object-icon-'+category);
315 }
316 }
317
318 if(this.boundObject) {
319 category = controller.getObjectCategory(this.boundObject).toLowerCase() || null;
320
321 if(category) {