From 62c7c2ac7b72c7e89611d064eef1f4f77a54696d Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 13 Jun 2012 19:08:46 -0700 Subject: Edit Binding - Binding improvements to show icon and save form --- .../edit-binding-view.reel/edit-binding-view.css | 9 +- .../edit-binding-view.reel/edit-binding-view.html | 24 ++- .../edit-binding-view.reel/edit-binding-view.js | 173 ++++++++++++++++++--- 3 files changed, 167 insertions(+), 39 deletions(-) (limited to 'js/panels/binding') diff --git a/js/panels/binding/edit-binding-view.reel/edit-binding-view.css b/js/panels/binding/edit-binding-view.reel/edit-binding-view.css index 23585aca..01feb5cc 100644 --- a/js/panels/binding/edit-binding-view.reel/edit-binding-view.css +++ b/js/panels/binding/edit-binding-view.reel/edit-binding-view.css @@ -33,7 +33,6 @@ display: -webkit-box; -webkit-box-orient: horizontal; -webkit-box-flex: 1; - overflow: hidden; } .object-container:first-child { margin-right: 5px; @@ -47,10 +46,7 @@ width: 40px; -webkit-box-flex: 0; } -.object-icon-container > div { - height: 100%; - width: 100%; -} + .edit-object-binding .object-icon { -webkit-transform: scale(.75); height: 100%; @@ -93,8 +89,9 @@ .buttons-container { background-color: #474747; + padding: 5px 0; position: absolute; - bottom: 5px; + bottom: 0; width: 100%; } 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 e2cbdd1d..91a5426f 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 @@ -21,7 +21,9 @@ "directionCheckbox" : {"@": "directionCheckbox" }, "saveButton":{ "@": "saveButton" }, "cancelButton":{ "@": "cancelButton" }, - "deleteButton":{ "@": "deleteButton" } + "deleteButton":{ "@": "deleteButton" }, + "sourceObjectIconElement": {"#": "source-object-icon"}, + "boundObjectIconElement": {"#": "bound-object-icon"} } }, "sourceObjectField": { @@ -31,7 +33,7 @@ "element": {"#": "sourceObjectField"} }, "bindings": { - "value": {"<-": "@owner.sourceObjectIdentifier"} + "value": {"<<->": "@owner.sourceObjectIdentifier"} }, "listeners" : [ { @@ -47,7 +49,7 @@ "element": {"#": "boundObjectField"} }, "bindings": { - "value": {"<-": "@owner.boundObjectIdentifier"} + "value": {"<<->": "@owner.boundObjectIdentifier"} }, "listeners" : [ { @@ -64,7 +66,7 @@ "identifier": "sourceProperty" }, "bindings": { - "value": {"<-": "@owner.sourceObjectPropertyPath"} + "value": {"<<->": "@owner.sourceObjectPropertyPath"} }, "listeners" : [ { @@ -81,7 +83,7 @@ "identifier": "boundProperty" }, "bindings": { - "value": {"<-": "@owner.boundObjectPropertyPath"} + "value": {"<<->": "@owner.boundObjectPropertyPath"} }, "listeners" : [ { @@ -147,14 +149,10 @@
- -
-
-
-
+
Test @@ -164,9 +162,7 @@
-
-
-
+
Test @@ -175,12 +171,10 @@
-
-
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 @@ */ var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + Converter = require("montage/core/converter/converter").Converter; -exports.EditBindingView = Montage.create(Component, { +var editBindingView = exports.EditBindingView = Montage.create(Component, { + sourceObjectIconElement : { value: null }, + boundObjectIconElement : { value: null }, objectIdentifiers : { value: null @@ -22,25 +25,90 @@ exports.EditBindingView = Montage.create(Component, { }, /* ------------------- - Binding Properties + Object Identifier (for associating with object) ------------------- */ + _sourceObjectIdentifier : { value: null }, sourceObjectIdentifier : { - value: "", - distinct: true - }, - sourceObjectPropertyPath : { - value: "", - distinct: true + get : function() { return this._sourceObjectIdentifier; }, + set : function(value) { + if(value === this._sourceObjectIdentifier) { return; } + + this._sourceObjectIdentifier = value; + + this.needsDraw = true; + } }, + + _boundObjectIdentifier : { value: null }, boundObjectIdentifier : { - value: "", - distinct: true + get : function() { return this._boundObjectIdentifier; }, + set : function(value) { + if(value === this._boundObjectIdentifier) { return; } + + this._boundObjectIdentifier = value; + + this.needsDraw = true; + } + }, + + + /* ------------------- + Binding Properties + ------------------- */ + + _sourceObject : { value: null }, + sourceObject : { + get : function() { return this._sourceObject; }, + set : function(value) { + if(value === this._sourceObject) { return; } + + this._sourceObject = value; + + this.needsDraw = true; + } + }, + + _boundObject : { value: null }, + boundObject : { + get : function() { return this._boundObject; }, + set : function(value) { + if(value === this._boundObject) { return; } + console.log("Bound Object being set to ", value); + this._boundObject = value; + + this.needsDraw = true; + } + }, + + _sourceObjectPropertyPath : { value: null }, + sourceObjectPropertyPath : { + get : function() { return this._sourceObjectPropertyPath; }, + set : function(value) { + console.log("Source Object Property Path being set to ", value); + + if(value === this._sourceObjectPropertyPath) { return; } + + + + this._sourceObjectPropertyPath = value; + + this.needsDraw = true; + } }, + + _boundObjectPropertyPath : { value: null }, boundObjectPropertyPath : { - value: "", - distinct: true + get : function() { return this._boundObjectPropertyPath; }, + set : function(value) { + if(value === this._boundObjectPropertyPath) { return; } + + this._boundObjectPropertyPath = value; + + this.needsDraw = true; + } }, + _oneway: { value: null }, @@ -130,13 +198,15 @@ exports.EditBindingView = Montage.create(Component, { saveForm : { value: function() { + debugger; + var controller = this.application.ninja.objectsController, newBindingArgs = { - sourceObject : this.getObjectFromIdentifierValue(this.sourceObjectField.value), - sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value, - boundObject : this.getObjectFromIdentifierValue(this.boundObjectField.value), - boundObjectPropertyPath : this.boundObjectPropertyPathField.value, - oneway: this.oneway + sourceObject : this.sourceObject, + sourceObjectPropertyPath : this.sourceObjectPropertyPathField.value, // TODO: shouldn't need to do this (get from bound property) + boundObject : this.boundObject, + boundObjectPropertyPath : this.boundObjectPropertyPathField.value, // TODO: shouldn't need to do this + oneway: this.oneway }; if(this.isNewBinding) { @@ -201,9 +271,76 @@ exports.EditBindingView = Montage.create(Component, { Draw Cycle ------------------- */ + templateDidLoad : { + value: function() { + + + Object.defineBinding(this, 'sourceObject', { + boundObject: this, + boundObjectPropertyPath: 'sourceObjectIdentifier', + oneway: false, + converter : objectIdentifierConverter.create() + }); + + Object.defineBinding(this, 'boundObject', { + boundObject: this, + boundObjectPropertyPath: 'boundObjectIdentifier', + oneway: false, + converter : objectIdentifierConverter.create() + }); + + } + }, + prepareForDraw : { value: function() { } + }, + + draw : { + value: function() { + var defaultIconClass = 'object-icon', + controller = this.application.ninja.objectsController, + category; + + this.sourceObjectIconElement.className = defaultIconClass; + this.boundObjectIconElement.className = defaultIconClass; + + if(this.sourceObject) { + category = controller.getObjectCategory(this.sourceObject).toLowerCase(); + + if(category) { + this.sourceObjectIconElement.classList.add('object-icon-'+category); + } + } + + if(this.boundObject) { + category = controller.getObjectCategory(this.boundObject).toLowerCase() || null; + + if(category) { + this.boundObjectIconElement.classList.add('object-icon-'+category); + } + } + } + } +}); + +var objectIdentifierConverter = exports.ObjectIdentifierConverter = Montage.create(Converter, { + convert: { + value: function(identifier) { + if(!identifier) { return null; } + + var identifiers = editBindingView.getObjectIdentifiers(), + objects = editBindingView.application.ninja.objectsController.objects; + + return objects[identifiers.indexOf(identifier)]; + } + }, + revert: { + value: function(object) { + console.log("converter revert"); + return object.identifier; + } } }); \ No newline at end of file -- cgit v1.2.3