aboutsummaryrefslogtreecommitdiff
path: root/js/panels/binding
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/binding')
-rw-r--r--js/panels/binding/edit-binding-view.reel/edit-binding-view.html44
-rw-r--r--js/panels/binding/edit-binding-view.reel/edit-binding-view.js81
2 files changed, 115 insertions, 10 deletions
diff --git a/js/panels/binding/edit-binding-view.reel/edit-binding-view.html b/js/panels/binding/edit-binding-view.reel/edit-binding-view.html
index d07f4445..604d4871 100644
--- a/js/panels/binding/edit-binding-view.reel/edit-binding-view.html
+++ b/js/panels/binding/edit-binding-view.reel/edit-binding-view.html
@@ -18,7 +18,10 @@
18 "boundObjectField" : {"@": "boundObjectField" }, 18 "boundObjectField" : {"@": "boundObjectField" },
19 "sourceObjectPropertyPathField" : {"@": "sourceObjectPropertyPathField" }, 19 "sourceObjectPropertyPathField" : {"@": "sourceObjectPropertyPathField" },
20 "boundObjectPropertyPathField" : {"@": "boundObjectPropertyPathField" }, 20 "boundObjectPropertyPathField" : {"@": "boundObjectPropertyPathField" },
21 "directionCheckbox" : {"@": "directionCheckbox" } 21 "directionCheckbox" : {"@": "directionCheckbox" },
22 "saveButton":{ "@": "saveButton" },
23 "cancelButton":{ "@": "cancelButton" },
24 "deleteButton":{ "@": "deleteButton" }
22 } 25 }
23 }, 26 },
24 "sourceObjectField": { 27 "sourceObjectField": {
@@ -96,11 +99,40 @@
96 "checked": {"<-": "@owner.oneway"} 99 "checked": {"<-": "@owner.oneway"}
97 } 100 }
98 }, 101 },
99 "closeButton" : { 102 "cancelButton" : {
100 "prototype": "montage/ui/button.reel", 103 "prototype": "montage/ui/button.reel",
101 "properties": { 104 "properties": {
102 "element": {"#": "close-button" }, 105 "element": {"#": "cancel-button" },
103 "identifier": "closeButton" 106 "identifier": "cancelButton"
107 },
108 "listeners": [
109 {
110 "type": "action",
111 "listener": {"@": "owner" }
112 }
113 ]
114 },
115 "deleteButton" : {
116 "prototype": "montage/ui/button.reel",
117 "properties": {
118 "element": {"#": "delete-button" },
119 "identifier": "deleteButton"
120 },
121 "listeners": [
122 {
123 "type": "action",
124 "listener": {"@": "owner" }
125 }
126 ]
127 },
128 "saveButton" : {
129 "prototype": "montage/ui/button.reel",
130 "properties": {
131 "element": {"#": "save-button" },
132 "identifier": "saveButton"
133 },
134 "bindings" : {
135 "enabled": {"<<->": "@owner.dirty"}
104 }, 136 },
105 "listeners": [ 137 "listeners": [
106 { 138 {
@@ -139,7 +171,9 @@
139 </li> 171 </li>
140 </ul> 172 </ul>
141 173
142 <button data-montage-id="close-button" class="nj-skinned">Close</button> 174 <button data-montage-id="delete-button" class="nj-skinned .btn-delete">Delete</button>
175 <button data-montage-id="cancel-button" class="nj-skinned">Cancel</button>
176 <button data-montage-id="save-button" class="nj-skinned">Save</button>
143 177
144</div> 178</div>
145</body> 179</body>
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