aboutsummaryrefslogtreecommitdiff
path: root/js/panels/binding/edit-binding-view.reel/edit-binding-view.js
diff options
context:
space:
mode:
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.js81
1 files changed, 76 insertions, 5 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 c3ef7384..c9f946f5 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
@@ -83,13 +83,16 @@ exports.EditBindingView = Montage.create(Component, {
83 this.sourceObjectField.hints = this.objectIdentifiers; 83 this.sourceObjectField.hints = this.objectIdentifiers;
84 84
85 if(value.sourceObject) { 85 if(value.sourceObject) {
86 this.sourceObjectIdentifier = value.sourceObject.identifier || ''; 86 this.sourceObjectIdentifier = value.sourceObject.identifier || value.sourceObject._montage_metadata.label;
87 this.sourceObjectPropertyPath = value.sourceObjectPropertyPath || ''; 87 this.sourceObjectPropertyPath = value.sourceObjectPropertyPath || '';
88 } 88 }
89 89
90 if(value.boundObject) { 90 if(value.boundObject) {
91 this.boundObjectIdentifier = value.boundObject.identifier || ''; 91 this.boundObjectIdentifier = value.boundObject.identifier || '';
92 this.boundObjectPropertyPath = value.boundObjectPropertyPath || ''; 92 this.boundObjectPropertyPath = value.boundObjectPropertyPath || '';
93 this.isNewBinding = false;
94 } else {
95 this.isNewBinding = true;
93 } 96 }
94 97
95 this.oneway = value.oneway; 98 this.oneway = value.oneway;
@@ -99,14 +102,20 @@ exports.EditBindingView = Montage.create(Component, {
99 }, 102 },
100 103
101 /* ------------------- 104 /* -------------------
102 Save/Close button handlers 105 Form properties
103 ------------------- */ 106 ------------------- */
104 107
108 dirty: { value: null },
109 isNewBinding : { value: null },
110
105 "sourceObjectField" : {value: null, enumerable: true }, 111 "sourceObjectField" : {value: null, enumerable: true },
106 "boundObjectField" : {value: null, enumerable: true }, 112 "boundObjectField" : {value: null, enumerable: true },
107 "sourceObjectPropertyPathField" : {value: null, enumerable: true }, 113 "sourceObjectPropertyPathField" : {value: null, enumerable: true },
108 "boundObjectPropertyPathField" : {value: null, enumerable: true }, 114 "boundObjectPropertyPathField" : {value: null, enumerable: true },
109 "directionCheckbox" : {value: null, enumerable: true }, 115 "directionCheckbox" : {value: null, enumerable: true },
116 "deleteButton" : {value: null },
117 "saveButton" : {value: null },
118 "cancelButton" : {value: null },
110 119
111 clearForm : { 120 clearForm : {
112 value: function() { 121 value: function() {
@@ -115,24 +124,86 @@ exports.EditBindingView = Montage.create(Component, {
115 field.value = ''; 124 field.value = '';
116 } 125 }
117 } 126 }
127 this.dirty = false;
128 }
129 },
130
131 saveForm : {
132 value: function() {
133 var controller = this.application.ninja.objectsController,
134 newBindingArgs = {
135 sourceObject : this.getObjectFromIdentifierValue(this.sourceObjectField.value),
136 sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value,
137 boundObject : this.getObjectFromIdentifierValue(this.boundObjectField.value),
138 boundObjectPropertyPath : this.boundObjectPropertyPathField.value,
139 oneway: this.oneway
140 };
141
142 if(this.isNewBinding) {
143 controller.addBinding(newBindingArgs);
144 } else {
145 controller.editBinding(this.bindingArgs, newBindingArgs);
146 }
147
148 controller.currentObject = controller.currentObject;
149 }
150 },
151
152 getObjectFromIdentifierValue : {
153 value: function(id) {
154 var identifiers = this.getObjectIdentifiers(),
155 objects = this.application.ninja.objectsController.objects;
156
157 return objects[identifiers.indexOf(id)];
118 } 158 }
119 }, 159 },
120 160
121 /* ------------------- 161 /* -------------------
122 Save/Close button handlers 162 Save/Cancel/Delete button handlers
123 ------------------- */ 163 ------------------- */
124 164
125 handleCloseButtonAction : { 165 handleCancelButtonAction : {
166 value: function(e) {
167 this.clearForm();
168 this.parentComponent.editing = false;
169 }
170 },
171
172 handleDeleteButtonAction : {
173 value: function(e) {
174 var controller = this.application.ninja.objectsController;
175
176 controller.removeBinding(this.bindingArgs);
177 controller.currentObject = controller.currentObject;
178
179 this.parentComponent.editing = false;
180 }
181 },
182 handleSaveButtonAction : {
126 value: function(e) { 183 value: function(e) {
184 this.saveForm();
127 this.parentComponent.editing = false; 185 this.parentComponent.editing = false;
128 } 186 }
129 }, 187 },
130 188
189
190 /* -------------------
191 Dirty handler
192 ------------------- */
193
194 handleEvent : {
195 value: function(e) {
196 if(e._event.type === 'change') {
197 this.dirty = true;
198 }
199 }
200 },
201
131 /* ------------------- 202 /* -------------------
132 Draw Cycle 203 Draw Cycle
133 ------------------- */ 204 ------------------- */
134 205
135 willDraw : { 206 prepareForDraw : {
136 value: function() { 207 value: function() {
137 208
138 } 209 }