Changeset 359 for Dev/branches/rest-dojo-ui/client/rft/ui/ObjectBox.js
- Timestamp:
- 07/12/12 17:07:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/ObjectBox.js
r350 r359 11 11 baseClass: "rftObjectBox", 12 12 templateString: template, 13 14 constructor: function() { 15 this.title = ""; 16 this.subTitle = ""; 17 this.lowerTitle = ""; 18 this.objectType = "SessionTemplate"; 19 this.actions = {} 20 21 }, 22 postCreate: function() { 13 value: null, 14 actions: null, 15 startup: function() { 23 16 this.line1 = new LineWithActionsWidget({ 24 title: this.title || "Untitled",25 17 modifiers: 'green', 26 18 actions: { 27 19 "inspectIcon": { 28 callback: lang.hitch(this, "_inspectObject"),20 callback: lang.hitch(this, this._showInfoBox), 29 21 properties: { 30 22 blockButton: false, … … 36 28 }).placeAt(this.line1Node); 37 29 this.line2 = new LineWithActionsWidget({ 38 title: this.subTitle || "", 39 modifiers: 'green', 40 actions: {} 30 modifiers: 'green' 41 31 }).placeAt(this.line1Node); 42 32 var line3Actions = this._createLine3Actions(); 43 33 this.line3 = new LineWithActionsWidget({ 44 title: this.lowerTitle || "",45 34 modifiers: 'green', 46 35 actions: line3Actions … … 52 41 }, 53 42 _createLine3Actions: function() { 54 var ac = {}; 55 if (this.actions["edit"]) { 56 ac["edit"] = { 57 callback: lang.hitch(this, "_editObject", this.actions["edit"]), 58 properties: { 59 blockButton: true, 60 label: "Edit/View", 61 modifiers: "trans", 62 icon: "Edit" 63 } 64 }; 65 delete this.actions["edit"]; 66 } 67 if (this.actions["delete"]) { 68 ac["delete"] = { 69 callback: lang.hitch(this, "_deleteObject", this.actions["delete"]), 70 properties: { 71 blockButton: true, 72 label: "Delete", 73 modifiers: "trans", 74 icon: "Delete" 75 } 76 }; 77 delete this.actions["delete"]; 78 } 79 for (action in this.actions) { 80 ac[action] = { 81 callback: lang.hitch(this, this.actions[action]), 43 var line3Actions = {}; 44 for (var action in this.actions) { 45 line3Actions[action] = { 46 callback: lang.hitch(this, function(callback){ 47 this.value && callback(this.value); 48 }, this.actions[action]), 82 49 properties: { 83 50 blockButton: true, … … 86 53 icon: action.charAt(0).toUpperCase()+action.slice(1) 87 54 } 88 } 55 }; 89 56 } 90 return ac;57 return line3Actions; 91 58 }, 92 93 _setObjectReference: function(identifier) { 94 // TODO: Set this ObjectBox to refer to a certain database object 95 }, 96 _getObjectInfo: function() { 97 // TODO: Query the database and retrieve a JSON array of object properties 98 }, 99 _inspectObject: function() { 100 // TODO: Get object information (or retrieve from cache), then display in popup 101 }, 102 _editObject: function(customFunction) { 103 // TODO: Pass an edit call to the page script, along with reference to the object contained in this ObjectBox 104 alert("Default edit code"); 105 customFunction(); 106 }, 107 _deleteObject: function(customFunction) { 108 // TODO: Pass a delete call to the page script, along with reference to the object contained in this ObjectBox 109 customFunction(); 110 }, 111 112 113 _setTitleAttr: function(value) { 114 this.title = value; 115 if (this.line1 && this.line1.set) { 116 this.line1.set('title', this.title); 59 _showInfoBox: function() { 60 alert(this.value.description); 61 }, 62 _setValueAttr: function(value) { 63 this.value = value; 64 this._refresh(); 65 }, 66 _getValueAttr: function(value) { 67 this.value = value; 68 }, 69 _refresh: function() { 70 if ( this.value !== null ) { 71 this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || ''); 72 this.line1.set('title', this.value.title || ''); 73 this.line2.set('title', this.value.subTitle || ''); 74 this.line3.set('title', this.value.lowerTitle || ''); 75 } 117 76 } 118 }, 119 _setSubTitleAttr: function(value) { 120 this.subTitle = value; 121 if (this.line2 && this.line2.set) { 122 this.line2.set('title', this.subTitle); 123 } 124 }, 125 _setLowerTitleAttr: function(value) { 126 this.lowerTitle = value; 127 if (this.line3 && this.line3.set) { 128 this.line3.set('title', this.lowerTitle); 129 } 130 }, 131 _setObjectTypeAttr: function(value) { 132 this.objectType = value; 133 this.iconNode.className = "rftIcon typeIcon rftIcon"+this.objectType; 134 }, 135 136 /* This is an experiment to embed the creation function in the ObjectBox class itself. This method cannot be static, but can be called externally as such: 137 * rft.ui.ObjectBox().CreateNew(args, ref, loc); 138 * TODO: Check with Hendrik if I should do this or not! 139 * */ 140 CreateNew: function(arguments, reference, location) { 141 var newBox = new rft.ui.ObjectBox(arguments); 142 newBox.startup(); 143 newBox.placeAt(reference, location); 144 } 77 }); 145 78 }); 146 });
Note: See TracChangeset
for help on using the changeset viewer.