Changeset 406
- Timestamp:
- 09/03/12 18:14:37 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/config/docs.json
r386 r406 19 19 } 20 20 }, 21 "rft/q1": {22 "__configAction": "update",23 "_id": "q1",24 "title": "How long have you worked here?",25 "categories": [26 "Professional background"27 ],28 "topic": "Work experience",29 "type": "Question"30 },31 "rft/q2": {32 "__configAction": "update",33 "_id": "q2",34 "title": "How many years have you been employed here?",35 "categories": [36 "Respondent personals",37 "Professional background"38 ],39 "topic": "Work experience",40 "type": "Question"41 },42 "rft/q3": {43 "__configAction": "update",44 "_id": "q3",45 "title": "Have you worked here longer than 10 years?",46 "categories": [47 "Respondent personals"48 ],49 "topic": "Work experience",50 "type": "Question"51 },52 "rft/q4": {53 "__configAction": "update",54 "_id": "q4",55 "title": "Rate your experience at your current employer from 1 to 10.",56 "type": "Question"57 },58 21 "rft/_design/default": { 59 22 "__configAction": "replace", 60 23 "_id": "_design/default", 61 24 "language": "javascript", 62 "validate_doc_update": "function(newDoc, oldDoc, userCtx, secObj) { if (oldDoc && oldDoc.published) { throw({forbidden: 'Published documents cannot be modified.'});} }",25 "validate_doc_update": "function(newDoc, oldDoc, userCtx, secObj) { if(oldDoc&&oldDoc.published){throw({forbidden:'Published documents cannot be modified.'});} if (!newDoc.type){throw({forbidden:'Documents must have a type field.'});} }", 63 26 "views": { 64 27 "by_type": { -
Dev/branches/rest-dojo-ui/client/rft/elastic/ElasticSearchFilteringSelect.js
r382 r406 2 2 'dojo/_base/declare', 3 3 'dijit/form/FilteringSelect' 4 5 6 4 ], function(declare, FilteringSelect) { 5 return declare("rft.elastic.ElasticSearchFilteringSelect", FilteringSelect, { 6 // custom min input character count to trigger search 7 7 minKeyCount: 3, 8 8 … … 15 15 this.inherited(arguments); 16 16 } 17 17 }); 18 18 }) -
Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.html
r399 r406 10 10 11 11 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" data-rft-attach-point="questionsPane"> 12 <form data-dojo-type="dijit.form.Form" data-rft-attach-point="questionsForm" 13 data-rft-attach-event="onSubmit:_onSubmit" 14 style="overflow: auto"> 15 <div data-rft-attach-point="questionsAnchor"></div> 16 </form> 12 17 </div> 13 18 -
Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js
r399 r406 23 23 store.query(null,{keys:this.survey.questions,include_docs:true}) 24 24 .forEach(function(question){ 25 array.forEach(question.content,function(item){ 26 var w = f.createViewWidget(item); 25 array.forEach(question.content || [],function(item){ 26 var w = f.createViewWidget(item,{ 27 name: question.code+'.'+item.code 28 }); 27 29 if ( w !== null ) { 28 w.placeAt(this.questionsPane.containerNode,'last'); 29 w.startup(); 30 w.placeAt(this.questionsAnchor,'before'); 30 31 } 31 32 },this); … … 37 38 }, 38 39 _onSubmit: function(evt) { 40 var value = this.questionsForm.get('value'); 41 this.questionsPane.set('content','<pre>'+JSON.stringify(value)+'</pre>'); 39 42 event.stop(evt); 40 43 return false; -
Dev/branches/rest-dojo-ui/client/rft/store.js
r402 r406 1 define(['dojo/_base/declare','dojo/_base/json','dojo/_base/lang','dojo/_base/array','dojo/_base/Deferred','dojo/_base/xhr','dojo/store/util/QueryResults'], 2 function(declare,json,lang,array,Deferred,xhr,QueryResults){ 1 define([ 2 'dojo/_base/array', 3 'dojo/_base/declare', 4 'dojo/_base/Deferred', 5 'dojo/_base/json', 6 'dojo/_base/lang', 7 'dojo/_base/xhr', 8 'dojo/store/util/QueryResults' 9 ],function(array,declare,Deferred,json,lang,xhr,QueryResults){ 3 10 4 var CouchStore = declare(null, { 5 /** dojo.Store implementation for CouchDB 6 * 7 * See for details on the REST API, the wiki 8 * at http://wiki.apache.org/couchdb/HTTP_Document_API. 9 */ 10 target: "", 11 accepts: "application/json", 12 idProperty: "_id", 13 revProperty: "_rev", 14 _responseIdProperty: "id", 15 _responseRevProperty: "rev", 16 constructor: function(options){ 17 declare.safeMixin(this, options); 18 }, 19 getIdentity: function(object){ 20 return object[this.idProperty]; 21 }, 22 getRevision: function(object){ 23 return object[this.revProperty]; 24 }, 25 get: function(id){ 26 var dfd = new Deferred(); 27 xhr("GET", { 28 url: this.target + id, 29 handleAs: "json", 30 headers: { 31 Accept: this.accepts 11 var CouchStore = declare(null, { 12 /** dojo.Store implementation for CouchDB 13 * 14 * See for details on the REST API, the wiki 15 * at http://wiki.apache.org/couchdb/HTTP_Document_API. 16 */ 17 target: "", 18 accepts: "application/json", 19 idProperty: "_id", 20 revProperty: "_rev", 21 _responseIdProperty: "id", 22 _responseRevProperty: "rev", 23 constructor: function(options){ 24 declare.safeMixin(this, options); 25 }, 26 getIdentity: function(object){ 27 return object[this.idProperty]; 28 }, 29 getRevision: function(object){ 30 return object[this.revProperty]; 31 }, 32 get: function(id){ 33 var dfd = new Deferred(); 34 xhr("GET", { 35 url: this.target + id, 36 handleAs: "json", 37 headers: { 38 Accept: this.accepts 39 } 40 }).then(function(result){ 41 if ( result.error ) { 42 dfd.reject(result.reason); 43 } else { 44 dfd.resolve(result); 45 } 46 }, function(err){ 47 dfd.reject(err); 48 }); 49 return dfd.promise; 50 }, 51 put: function(object, options){ 52 // summary: 53 // put an object in CouchDB 54 // object: Object 55 // The object to put 56 // options: Object 57 // Options object as 58 // id: String 59 // 60 options = options || {}; 61 62 var dfd = new Deferred(); 63 var id = options.id ? options.id : this.getIdentity(object); 64 var hasId = typeof id != "undefined"; 65 xhr(hasId ? "PUT" : "POST", { 66 url: hasId ? this.target + id : this.target, 67 postData: json.toJson(object), 68 handleAs: "json", 69 headers:{ 70 "Content-Type": "application/json", 71 Accept: this.accepts 72 } 73 }).then(lang.hitch(this,function(result){ 74 if ( result.error ) { 75 dfd.reject(result.reason); 76 } else { 77 object[this.idProperty] = result[this._responseIdProperty]; 78 object[this.revProperty] = result[this._responseRevProperty]; 79 dfd.resolve(object); 80 } 81 }), function(err){ 82 dfd.reject(err); 83 }); 84 return dfd.promise; 85 }, 86 add: function(object, options){ 87 return this.put(object,options); 88 }, 89 remove: function(id,rev){ 90 var dfd = new Deferred(); 91 xhr("DELETE",{ 92 url: this.target + id, 93 headers: { 94 'If-Match': rev 95 } 96 }).then(function(result){ 97 if ( result.error ) { 98 dfd.reject(result.reason); 99 } else { 100 dfd.resolve(); 101 } 102 },function(err){ 103 dfd.reject(err); 104 }); 105 return dfd.promise; 106 }, 107 query: function(query, options){ 108 // summary: 109 // query a couchdb view 110 // query: String 111 // name of a couchdb view you want to query, relative to the current database 112 // options: Object 113 // options object as 114 // start: Number 115 // Start results at this item 116 // count: Number 117 // Number of items to return 118 // sort: [{attribute:'key',descending:true|false}] 119 // CouchDB only support sorting by key, so only 'key' 120 // is allowed as attribute value. Multiple sort items 121 // are ignored. 122 // key: String|Array|Object 123 // Return only values with this key. 124 // Excludes start/endkey usage. 125 // startkey: String|Array|Object 126 // Return values starting from this key. 127 // endkey: String|Array|Object 128 // Return values with key lower than this key. 129 // include_docs: true|false 130 // Return the full documents instead of the view 131 // values. 132 // reduce: true|false 133 // Execute reduce on the view or not. Default depends 134 // on if a reduce function is defined on the view. 135 // group: true|false 136 // Should values be grouped per key or not? Default 137 // is false. 138 // group_level: Number 139 // When group = true and the key is an array, 140 // determines which elements starting from the first 141 // are used for grouping. Default is 0. 142 // get_keys: true|false 143 // Instead of returning the values or documents, 144 // return the array of keys as the result. 145 // This does not affect the forPairs function. 146 options = options || {}; 147 148 var dfd = new Deferred(); 149 var queryOpts = {}; 150 if ( !query ) { 151 query = '_all_docs'; 152 } 153 154 if (!lang.isString(query)) { 155 console.warn("Query must be a view name"); 156 } 157 158 // Standard options 159 if (options.start >= 0) { 160 queryOpts.skip = options.start; 161 } 162 if (options.count >= 0) { 163 queryOpts.limit = options.count; 164 } 165 if (options.sort) { 166 if (options.sort[0]) { 167 if (options.sort[0].attribute && options.sort[0].attribute !== "key") { 168 console.warn("Can only sort on key"); 32 169 } 33 }).then(function(result){ 34 if ( result.error ) { 35 dfd.reject(result.reason); 170 if (options.sort[0].descending) { 171 queryOpts.descending = true; 172 } 173 } 174 if (options.sort.length > 1) { 175 console.warn("multiple sort fields not supported"); 176 } 177 } 178 179 // Custom options 180 if (options.key !== undefined) { 181 queryOpts.key = options.key; 182 } else if (options.keys !== undefined) { 183 queryOpts.keys = options.keys; 184 } else if (options.startkey !== undefined || options.endkey !== undefined) { 185 queryOpts.startkey = options.startkey; 186 queryOpts.endkey = options.endkey; 187 } 188 if (options.include_docs !== undefined) { 189 queryOpts.include_docs = options.include_docs; 190 } 191 if (options.reduce !== undefined) { 192 queryOpts.reduce = options.reduce; 193 } 194 if (options.group !== undefined) { 195 queryOpts.group = options.group; 196 if (options.group_level !== undefined) { 197 queryOpts.group_level = options.group_level; 198 } 199 } 200 201 for (var qp in queryOpts) { 202 queryOpts[qp] = json.toJson(queryOpts[qp]); 203 } 204 query += '?' + xhr.objectToQuery(queryOpts); 205 206 xhr("GET", { 207 url: this.target + query, 208 handleAs: "json", 209 headers: { 210 Accept: this.accepts 211 } 212 }).then(function(result){ 213 if (result.error) { 214 dfd.reject(result.reason); 215 } else { 216 var results; 217 var values = array.map(result.rows,function(result){ 218 return options.include_docs === true ? result.doc : result.value; 219 }); 220 var keys = array.map(result.rows,function(result){ 221 return result.key; 222 }); 223 if (options.get_keys === true) { 224 results = keys; 225 results.values = values; 36 226 } else { 37 dfd.resolve(result); 227 results = values; 228 results.keys = keys; 38 229 } 39 }, function(err){ 40 dfd.reject(err); 230 dfd.resolve(results); 231 } 232 },function(err){ 233 dfd.reject(err); 234 }); 235 return CouchResults(dfd.promise); 236 } 237 }); 238 239 function CouchResults(results) { 240 results = QueryResults(results); 241 results.forPairs = function(callback,thisObject) { 242 callback = lang.hitch(thisObject,callback); 243 return Deferred.when(results,function(results) { 244 var values = results.values || results; 245 var keys = results.keys || results; 246 return array.forEach(values, function(value,index) { 247 callback(value,keys[index],index); 41 248 }); 42 return dfd.promise; 43 }, 44 put: function(object, options){ 45 // summary: 46 // put an object in CouchDB 47 // object: Object 48 // The object to put 49 // options: Object 50 // Options object as 51 // id: String 52 // 53 options = options || {}; 54 55 var dfd = new Deferred(); 56 var id = options.id ? options.id : this.getIdentity(object); 57 var hasId = typeof id != "undefined"; 58 xhr(hasId ? "PUT" : "POST", { 59 url: hasId ? this.target + id : this.target, 60 postData: json.toJson(object), 61 handleAs: "json", 62 headers:{ 63 "Content-Type": "application/json", 64 Accept: this.accepts 65 } 66 }).then(lang.hitch(this,function(result){ 67 if ( result.error ) { 68 dfd.reject(result.reason); 69 } else { 70 object[this.idProperty] = result[this._responseIdProperty]; 71 object[this.revProperty] = result[this._responseRevProperty]; 72 dfd.resolve(object); 73 } 74 }), function(err){ 75 dfd.reject(err); 76 }); 77 return dfd.promise; 78 }, 79 add: function(object, options){ 80 return this.put(object,options); 81 }, 82 remove: function(id,rev){ 83 var dfd = new Deferred(); 84 xhr("DELETE",{ 85 url: this.target + id, 86 headers: { 87 'If-Match': rev 88 } 89 }).then(function(result){ 90 if ( result.error ) { 91 dfd.reject(result.reason); 92 } else { 93 dfd.resolve(); 94 } 95 },function(err){ 96 dfd.reject(err); 97 }); 98 return dfd.promise; 99 }, 100 query: function(query, options){ 101 // summary: 102 // query a couchdb view 103 // query: String 104 // name of a couchdb view you want to query, relative to the current database 105 // options: Object 106 // options object as 107 // start: Number 108 // Start results at this item 109 // count: Number 110 // Number of items to return 111 // sort: [{attribute:'key',descending:true|false}] 112 // CouchDB only support sorting by key, so only 'key' 113 // is allowed as attribute value. Multiple sort items 114 // are ignored. 115 // key: String|Array|Object 116 // Return only values with this key. 117 // Excludes start/endkey usage. 118 // startkey: String|Array|Object 119 // Return values starting from this key. 120 // endkey: String|Array|Object 121 // Return values with key lower than this key. 122 // include_docs: true|false 123 // Return the full documents instead of the view 124 // values. 125 // reduce: true|false 126 // Execute reduce on the view or not. Default depends 127 // on if a reduce function is defined on the view. 128 // group: true|false 129 // Should values be grouped per key or not? Default 130 // is false. 131 // group_level: Number 132 // When group = true and the key is an array, 133 // determines which elements starting from the first 134 // are used for grouping. Default is 0. 135 // get_keys: true|false 136 // Instead of returning the values or documents, 137 // return the array of keys as the result. 138 // This does not affect the forPairs function. 139 options = options || {}; 140 141 var dfd = new Deferred(); 142 var queryOpts = {}; 143 if ( !query ) { 144 query = '_all_docs'; 145 } 146 147 if (!lang.isString(query)) { 148 console.warn("Query must be a view name"); 149 } 150 151 // Standard options 152 if (options.start >= 0) { 153 queryOpts.skip = options.start; 154 } 155 if (options.count >= 0) { 156 queryOpts.limit = options.count; 157 } 158 if (options.sort) { 159 if (options.sort[0]) { 160 if (options.sort[0].attribute && options.sort[0].attribute !== "key") { 161 console.warn("Can only sort on key"); 162 } 163 if (options.sort[0].descending) { 164 queryOpts.descending = true; 165 } 166 } 167 if (options.sort.length > 1) { 168 console.warn("multiple sort fields not supported"); 169 } 170 } 171 172 // Custom options 173 if (options.key !== undefined) { 174 queryOpts.key = options.key; 175 } else if (options.keys !== undefined) { 176 queryOpts.keys = options.keys; 177 } else if (options.startkey !== undefined || options.endkey !== undefined) { 178 queryOpts.startkey = options.startkey; 179 queryOpts.endkey = options.endkey; 180 } 181 if (options.include_docs !== undefined) { 182 queryOpts.include_docs = options.include_docs; 183 } 184 if (options.reduce !== undefined) { 185 queryOpts.reduce = options.reduce; 186 } 187 if (options.group !== undefined) { 188 queryOpts.group = options.group; 189 if (options.group_level !== undefined) { 190 queryOpts.group_level = options.group_level; 191 } 192 } 193 194 for (var qp in queryOpts) { 195 queryOpts[qp] = json.toJson(queryOpts[qp]); 196 } 197 query += '?' + xhr.objectToQuery(queryOpts); 198 199 xhr("GET", { 200 url: this.target + query, 201 handleAs: "json", 202 headers: { 203 Accept: this.accepts 204 } 205 }).then(function(result){ 206 if (result.error) { 207 dfd.reject(result.reason); 208 } else { 209 var results; 210 var values = array.map(result.rows,function(result){ 211 return options.include_docs === true ? result.doc : result.value; 212 }); 213 var keys = array.map(result.rows,function(result){ 214 return result.key; 215 }); 216 if (options.get_keys === true) { 217 results = keys; 218 results.values = values; 219 } else { 220 results = values; 221 results.keys = keys; 222 } 223 dfd.resolve(results); 224 } 225 },function(err){ 226 dfd.reject(err); 227 }); 228 return CouchResults(dfd.promise); 229 } 230 }); 231 232 function CouchResults(results) { 233 results = QueryResults(results); 234 results.forPairs = function(callback,thisObject) { 235 callback = lang.hitch(thisObject,callback); 236 return Deferred.when(results,function(results) { 237 var values = results.values || results; 238 var keys = results.keys || results; 239 return array.forEach(values, function(value,index) { 240 callback(value,keys[index],index); 241 }); 242 }); 243 } 244 return results; 245 } 246 247 return new CouchStore({target: 'data/rft/'}); 248 249 }); 249 }); 250 }; 251 return results; 252 } 253 254 return new CouchStore({target: 'data/rft/'}); 255 256 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/Breadcrumbs.js
r405 r406 6 6 'dojo/topic', 7 7 'dijit/_WidgetBase' 8 ], function(declare, baseArray, Button, domClass, topic, _WidgetBase){ 9 return declare('rft.ui.Breadcrumbs', [_WidgetBase], { 10 _crumbs: [], 11 12 _last: function(){ 13 return this._crumbs[this._crumbs.length-1]; 14 }, 15 _getIndexOf: function(label) { 16 dojo.forEach(this._crumbs, function(crumb, index){ 17 if (crumb.label == label) { 18 return index; 19 } 20 }, this); 21 return -1; 22 }, 23 24 addCrumb: function(label, path) { 25 this._crumbs.push({ 26 label: label, 27 path:path 28 }); 29 }, 30 _removeAfter: function(index) { 31 var removals = this._crumbs.slice(index+1); 32 this._crumbs = this._crumbs.slice(0, index+1); 33 dojo.forEach(removals, function(removal){ 34 removal.widget.destroyRecursive(false); // boolean "keepDOMnode" 35 }, this); 36 this._highlightLast(); 37 }, 38 39 _highlightLast: function() { 40 domClass.add(this._last().widget, "breadcrumbCurrent"); 41 }, 42 _unhighlightLast: function() { 43 domClass.remove(this._last(), "breadcrumbCurrent"); 44 }, 45 46 _changeTo: function(label, path) { 47 // TODO: Differentiate between navigating backwards and sideways/forward! 48 var index = baseArray.indexOf({label:label , path:path}); 49 //var index = this._getIndexOf(label); // Use this if passing path as an argument is not possible! 50 if (index >= 0) this._removeAfter(index); 51 this._addCrumb(label, path); 52 this._createBreadcrumbs(); 53 }, 54 55 _createBreadcrumb: function(label, path) { 56 return new Button({ 57 baseClass: "breadcrumb", 58 label: label, 59 showlabel: true, 60 iconClass: "dijitNoIcon", 61 onClick: lang.hitch(this, function(){ 62 rft.api.loadPage(path); // TODO: fix this call! 63 }) 64 }); 65 }, 66 _createBreadcrumbs: function() { 67 dojo.forEach(this._crumbs, function(crumb, index){ 68 if (!crumb.widget) { 69 crumb.widget = this._createBreadcrumb(crumb.label, crumb.path); 70 } 71 }, this); 72 this._highlightLast(); 73 }, 74 startup: function() { 75 if ( this._started ){ return; } 76 this.inherited(arguments); 77 // TODO: start page crumb creation? 78 this._createBreadCrumbs(); 79 this._setupEvents(); 80 this.inherited(arguments); 81 }, 82 _setupEvents: function() { 83 // TODO: Bind changeTo() listener to an "onLoadPage" event exposed by rft.api! 84 topic.subscribe("rft/content/goTo", this._changeTo(label, path)); 85 } 86 }); 8 ], function(declare, baseArray, Button, domClass, topic, _WidgetBase){ 9 return declare('rft.ui.Breadcrumbs', [_WidgetBase], { 10 _crumbs: [], 11 12 _last: function(){ 13 return this._crumbs[this._crumbs.length-1]; 14 }, 15 _getIndexOf: function(label) { 16 dojo.forEach(this._crumbs, function(crumb, index){ 17 if (crumb.label == label) { 18 return index; 19 } 20 }, this); 21 return -1; 22 }, 23 24 addCrumb: function(label, path) { 25 this._crumbs.push({ 26 label: label, 27 path:path 28 }); 29 }, 30 _removeAfter: function(index) { 31 var removals = this._crumbs.slice(index+1); 32 this._crumbs = this._crumbs.slice(0, index+1); 33 dojo.forEach(removals, function(removal){ 34 removal.widget.destroyRecursive(false); // boolean "keepDOMnode" 35 }, this); 36 this._highlightLast(); 37 }, 38 39 _highlightLast: function() { 40 domClass.add(this._last().widget, "breadcrumbCurrent"); 41 }, 42 _unhighlightLast: function() { 43 domClass.remove(this._last(), "breadcrumbCurrent"); 44 }, 45 46 _changeTo: function(label, path) { 47 // TODO: Differentiate between navigating backwards and sideways/forward! 48 var index = baseArray.indexOf({label:label , path:path}); 49 //var index = this._getIndexOf(label); // Use this if passing path as an argument is not possible! 50 if (index >= 0) this._removeAfter(index); 51 this._addCrumb(label, path); 52 this._createBreadcrumbs(); 53 }, 54 55 _createBreadcrumb: function(label, path) { 56 return new Button({ 57 baseClass: "breadcrumb", 58 label: label, 59 showlabel: true, 60 iconClass: "dijitNoIcon", 61 onClick: lang.hitch(this, function(){ 62 rft.api.loadPage(path); // TODO: fix this call! 63 }) 64 }); 65 }, 66 _createBreadcrumbs: function() { 67 dojo.forEach(this._crumbs, function(crumb, index){ 68 if (!crumb.widget) { 69 crumb.widget = this._createBreadcrumb(crumb.label, crumb.path); 70 } 71 }, this); 72 this._highlightLast(); 73 }, 74 startup: function() { 75 if ( this._started ){ return; } 76 this.inherited(arguments); 77 // TODO: start page crumb creation? 78 this._createBreadCrumbs(); 79 this._setupEvents(); 80 this.inherited(arguments); 81 }, 82 _setupEvents: function() { 83 // TODO: Bind changeTo() listener to an "onLoadPage" event exposed by rft.api! 84 topic.subscribe("rft/content/goTo", this._changeTo(label, path)); 85 } 87 86 }); 88 89 /* Breadcrumbs system, which automatically generates styled buttons in the topBar. 90 * Updates are triggered through a "changePage" subscription to "rft/connect/goTo" (method that loads pages in rft.connect.js) 91 * 92 * Todo: Startup() does not handle initial creation well. No initial breadcrumb is created on page load. What happens when I refresh the page, do all previous crumbs disappear? 93 * Todo: Pages should have a label/name besides the path, for display in the breadcrumbs bar. Perhaps the page main title? (Generate this header dynamically?) 94 * Todo: Put connect.publish("rft/content/goTo", args); call in rft/content, to trigger breadcrumbs updates 95 * This method uses path and 'args'(?) instead of label and path, change terminology accordingly? 96 * Todo: breadcrumbs do not have context yet, unless we can somehow create that context from the path. Split path at "/" char, lookup label/title for each step? 97 * (See before!) 98 * 99 */ 87 }); 88 89 /* Breadcrumbs system, which automatically generates styled buttons in the topBar. 90 * Updates are triggered through a "changePage" subscription to "rft/connect/goTo" (method that loads pages in rft.connect.js) 91 * 92 * Todo: Startup() does not handle initial creation well. No initial breadcrumb is created on page load. What happens when I refresh the page, do all previous crumbs disappear? 93 * Todo: Pages should have a label/name besides the path, for display in the breadcrumbs bar. Perhaps the page main title? (Generate this header dynamically?) 94 * Todo: Put connect.publish("rft/content/goTo", args); call in rft/content, to trigger breadcrumbs updates 95 * This method uses path and 'args'(?) instead of label and path, change terminology accordingly? 96 * Todo: breadcrumbs do not have context yet, unless we can somehow create that context from the path. Split path at "/" char, lookup label/title for each step? 97 * (See before!) 98 * 99 */ -
Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidget.js
r405 r406 1 1 define(['dojo/_base/declare', 2 'dojo/_base/lang', 3 'dojo/on', 4 'dojo/dom', 5 'dojo/_base/event', 6 'dojo/dom-class', 7 'dijit/form/Button', 8 'dijit/_WidgetBase', 9 'dijit/_TemplatedMixin', 10 'dijit/_WidgetsInTemplateMixin', 11 'dojo/text!./templates/LineWithActionsWidget.html' 12 ], 13 function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 14 return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 15 templateString: templateString, 16 baseClass: 'rftLineWithButtons', 17 title: '', 18 selectable: false, 19 userObject: null, 2 'dojo/_base/lang', 3 'dojo/on', 4 'dojo/dom', 5 'dojo/_base/event', 6 'dojo/dom-class', 7 'dijit/form/Button', 8 'dijit/_WidgetBase', 9 'dijit/_TemplatedMixin', 10 'dijit/_WidgetsInTemplateMixin', 11 'dojo/text!./templates/LineWithActionsWidget.html' 12 ],function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 13 return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 14 templateString: templateString, 15 baseClass: 'rftLineWithButtons', 16 title: '', 17 selectable: false, 18 userObject: null, 20 19 21 actions: null, 22 postCreate: function() { 23 dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection! 24 on(this.domNode,'click',lang.hitch(this,'_onClick')); 25 }, 26 startup: function() { 27 if ( this._started ){ return; } 28 this.inherited(arguments); 29 this._setupActions(); 30 domClass.add(this.domNode, "inheritBgColor bg"); 31 this.refresh(); 32 }, 33 _setupActions: function() { 34 if ( this.actions === null ) { 35 return; 20 actions: null, 21 postCreate: function() { 22 dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection! 23 on(this.domNode,'click',lang.hitch(this,'_onClick')); 24 }, 25 startup: function() { 26 if ( this._started ){ return; } 27 this.inherited(arguments); 28 this._setupActions(); 29 domClass.add(this.domNode, "inheritBgColor bg"); 30 this.refresh(); 31 }, 32 _setupActions: function() { 33 if ( this.actions === null ) { 34 return; 35 } 36 for (var action in this.actions) { 37 var properties; 38 if (this.actions[action].properties.blockButton === true) { 39 properties = lang.mixin({ 40 baseClass: 'rftBlockButton', 41 "class": "inheritBgColor light", 42 label: "Default", 43 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, 44 title: this.actions[action].properties.tooltip, 45 onClick: lang.hitch(this, function(action, e){ 46 action.callback && action.callback(e); 47 event.stop(e); 48 return false; 49 }, this.actions[action]) 50 }, this.actions[action].properties); 51 new Button(properties).placeAt(this.buttonsNode); 52 } else { 53 properties = lang.mixin({ 54 baseClass: 'rftInlineButton', 55 label: "Default", 56 showLabel: false, 57 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, 58 title: this.actions[action].properties.tooltip, 59 onClick: lang.hitch(this, function(action, e){ 60 action.callback && action.callback(e); 61 event.stop(e); 62 return false; 63 }, this.actions[action]) 64 }, this.actions[action].properties); 65 new Button(properties).placeAt(this.buttonsNode); 36 66 } 37 for (var action in this.actions) {38 var properties;39 if (this.actions[action].properties.blockButton == true) {40 properties = lang.mixin({41 baseClass: 'rftBlockButton',42 "class": "inheritBgColor light",43 label: "Default",44 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,45 title: this.actions[action].properties.tooltip,46 onClick: lang.hitch(this, function(action, e){47 action.callback && action.callback(e);48 event.stop(e);49 return false;50 }, this.actions[action])51 }, this.actions[action].properties);52 new Button(properties).placeAt(this.buttonsNode);53 } else {54 properties = lang.mixin({55 baseClass: 'rftInlineButton',56 label: "Default",57 showLabel: false,58 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,59 title: this.actions[action].properties.tooltip,60 onClick: lang.hitch(this, function(action, e){61 action.callback && action.callback(e);62 event.stop(e);63 return false;64 }, this.actions[action])65 }, this.actions[action].properties);66 new Button(properties).placeAt(this.buttonsNode);67 }68 }69 },70 refresh: function() {71 this.titleNode.innerHTML = this.title;72 },73 _onClick: function(e){74 var preventDefault = this.onClick(e) === false;75 if (preventDefault) {76 event.stop(e);77 }78 return !preventDefault;79 },80 onClick: function(e) {81 },82 _setTitleAttr: function(value){83 this.title = value;84 this.refresh();85 67 } 86 }); 68 }, 69 refresh: function() { 70 this.titleNode.innerHTML = this.title; 71 }, 72 _onClick: function(e){ 73 var preventDefault = this.onClick(e) === false; 74 if (preventDefault) { 75 event.stop(e); 76 } 77 return !preventDefault; 78 }, 79 onClick: function(e) { 80 }, 81 _setTitleAttr: function(value){ 82 this.title = value; 83 this.refresh(); 84 } 87 85 }); 86 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/ObjectBox.js
r405 r406 7 7 'rft/ui/LineWithActionsWidget', 8 8 'dojo/text!./templates/ObjectBox.html', 9 ], function(declare, lang, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, LineWithActionsWidget, template){ 10 return declare('rft.ui.ObjectBox', [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { 11 baseClass: "rftObjectBox", 12 templateString: template, 13 value: null, 14 actions: null, 15 startup: function() { 16 if ( this._started ){ return; } 17 this.inherited(arguments); 18 this.line1 = new LineWithActionsWidget({ 19 actions: { 20 "inspectIcon": { 21 callback: lang.hitch(this, this._showInfoBox), 22 properties: { 23 blockButton: false, 24 icon: "Inspect" 25 } 9 ], function(declare, lang, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, LineWithActionsWidget, template){ 10 return declare('rft.ui.ObjectBox', [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { 11 baseClass: "rftObjectBox", 12 templateString: template, 13 value: null, 14 actions: null, 15 startup: function() { 16 if ( this._started ){ return; } 17 this.inherited(arguments); 18 this.line1 = new LineWithActionsWidget({ 19 actions: { 20 "inspectIcon": { 21 callback: lang.hitch(this, this._showInfoBox), 22 properties: { 23 blockButton: false, 24 icon: "Inspect" 26 25 } 27 26 } 28 }).placeAt(this.line1Node);29 this.line2 = new LineWithActionsWidget({30 }).placeAt(this.line1Node);31 var line3Actions = this._createLine3Actions();32 this.line3 = new LineWithActionsWidget({33 actions: line3Actions34 }).placeAt(this.line1Node);35 this.line1.startup();36 this.line2.startup();37 this.line3.startup();38 this.inherited(arguments);39 },40 _createLine3Actions: function() {41 var line3Actions = {};42 for (var action in this.actions) {43 line3Actions[action] = {44 callback: lang.hitch(this, function(callback){45 this.value && callback(this.value);46 }, this.actions[action]),47 properties: {48 blockButton: true,49 label: action,50 icon: action.charAt(0).toUpperCase()+action.slice(1)51 }52 };53 27 } 54 return line3Actions; 55 }, 56 _showInfoBox: function() { 57 alert(this.value.description); 58 }, 59 _setValueAttr: function(value) { 60 this.value = value; 61 this._refresh(); 62 }, 63 _getValueAttr: function(value) { 64 this.value = value; 65 }, 66 _refresh: function() { 67 if ( this.value !== null ) { 68 this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || ''); 69 this.line1.set('title', this.value.title || ''); 70 this.line2.set('title', this.value.subTitle || ''); 71 this.line3.set('title', this.value.lowerTitle || ''); 72 } 28 }).placeAt(this.line1Node); 29 this.line2 = new LineWithActionsWidget({ 30 }).placeAt(this.line1Node); 31 var line3Actions = this._createLine3Actions(); 32 this.line3 = new LineWithActionsWidget({ 33 actions: line3Actions 34 }).placeAt(this.line1Node); 35 this.line1.startup(); 36 this.line2.startup(); 37 this.line3.startup(); 38 this.inherited(arguments); 39 }, 40 _createLine3Actions: function() { 41 var line3Actions = {}; 42 for (var action in this.actions) { 43 line3Actions[action] = { 44 callback: lang.hitch(this, function(callback){ 45 this.value && callback(this.value); 46 }, this.actions[action]), 47 properties: { 48 blockButton: true, 49 label: action, 50 icon: action.charAt(0).toUpperCase()+action.slice(1) 51 } 52 }; 73 53 } 74 }); 54 return line3Actions; 55 }, 56 _showInfoBox: function() { 57 alert(this.value.description); 58 }, 59 _setValueAttr: function(value) { 60 this.value = value; 61 this._refresh(); 62 }, 63 _getValueAttr: function(value) { 64 this.value = value; 65 }, 66 _refresh: function() { 67 if ( this.value !== null ) { 68 this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || ''); 69 this.line1.set('title', this.value.title || ''); 70 this.line2.set('title', this.value.subTitle || ''); 71 this.line3.set('title', this.value.lowerTitle || ''); 72 } 73 } 74 }); 75 75 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/Selector.js
r405 r406 13 13 'dojo/text!./templates/Selector.html', 14 14 'dojo/dom-class', 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 15 ],function( 16 declare, 17 baseArray, 18 registry, 19 lang, 20 event, 21 fx, 22 _WidgetBase, 23 _TemplatedMixin, 24 _WidgetsInTemplateMixin, 25 _Container, 26 LineWithActionsWidget, 27 templateString, 28 domClass 29 ){ 30 return declare('rft.ui.Selector',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 31 templateString: templateString, 32 baseClass: 'rftSelector', 33 33 34 35 36 37 38 39 40 34 title: "", 35 selectedActions: null, 36 itemActions: null, 37 // main selector action: Object 38 // title: 39 // description: 40 // icon: 41 41 42 43 44 45 42 _folded: true, 43 _titleLine: null, 44 _selectorLine: null, 45 _selectedItem: null, 46 46 47 48 49 50 47 startup: function() { 48 if ( this._started ){ return; } 49 this.inherited(arguments); 50 domClass.add(this.selectedColorNode, "pending"); 51 51 52 53 52 this._createTitleLine(); 53 this._createSelectorLine(); 54 54 55 fx.wipeOut({ 56 node: this.optionsNode 57 }).play(); 58 }, 59 _createTitleLine: function() { 60 var actions = {}; 61 var action = null; 62 if ( this.selectedActions !== null ) { 63 for (var actionName in this.selectedActions) { 64 action = this.selectedActions[actionName]; 65 actions[actionName] = { 66 callback: action.callback && 67 lang.hitch(this,this._onSelectedAction, 68 action.callback), 69 properties: { 70 blockButton: true, 71 label: action.title || actionName, 72 icon: action.icon, 73 tooltip: action.description 74 } 75 76 }; 77 } 78 } 79 80 this._titleLine = new LineWithActionsWidget({ 81 title: this.title, 82 actions: actions 83 },this.titleNode); 84 this._titleLine.startup(); 85 }, 86 _createSelectorLine: function() { 87 this._selectorLine = new LineWithActionsWidget({ 88 title: 'None', 89 actions: { 90 "Toggle dropdown" : { 91 callback: lang.hitch(this, this.onToggle), 92 properties: { 93 blockButton: true, 94 showLabel: false, 95 icon: "HalfArrowDown" 96 } 97 } 98 } 99 },this.selectedItemNode); 100 this._selectorLine.startup(); 101 this._selectorLine.on('click',lang.hitch(this, this.onToggle)); 102 }, 103 _onSelect: function(item, widget) { 104 this._selectedItem = item; 105 this.onToggle(); 106 this._selectorLine.set("title", item.title); 107 baseArray.forEach(this.optionsNode.childNodes, function(node){ 108 var line = registry.byNode(node); 109 if (line) { 110 if (line === widget) { 111 domClass.add(line.domNode, "inheritBgColor light"); 112 } else { 113 domClass.remove(line.domNode, "inheritBgColor light"); 114 } 115 } 116 }, this); 117 this.onSelect(item); 118 }, 119 _onSelectedAction: function(callback) { 120 if (this._selectedItem && callback) { 121 callback(this._selectedItem); 122 } 123 }, 124 125 onToggle: function(evt) { 126 if (this._folded) { 127 var downArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowDown", this._selectorLine.buttonsNode)[0]; 128 if (downArrowIcon){ 129 domClass.replace(downArrowIcon, "rftIconHalfArrowUp", "rftIconHalfArrowDown"); 130 } 131 fx.wipeIn({ 132 node: this.optionsNode 133 }).play(); 134 this._folded = false; 135 } else { 136 var upArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowUp", this._selectorLine.buttonsNode)[0]; 137 if (upArrowIcon){ 138 domClass.replace(upArrowIcon, "rftIconHalfArrowDown", "rftIconHalfArrowUp"); 139 } 55 140 fx.wipeOut({ 56 141 node: this.optionsNode 57 142 }).play(); 58 }, 59 _createTitleLine: function() { 60 var actions = {}; 61 var action = null; 62 if ( this.selectedActions !== null ) { 63 for (var actionName in this.selectedActions) { 64 action = this.selectedActions[actionName]; 65 actions[actionName] = { 66 callback: action.callback && 67 lang.hitch(this,this._onSelectedAction, 68 action.callback), 69 properties: { 70 blockButton: true, 71 label: action.title || actionName, 72 icon: action.icon, 73 tooltip: action.description 74 } 143 this._folded = true; 144 } 145 evt && event.stop(evt); 146 return false; 147 }, 75 148 76 }; 77 } 78 } 79 80 this._titleLine = new LineWithActionsWidget({ 81 title: this.title, 82 actions: actions 83 },this.titleNode); 84 this._titleLine.startup(); 85 }, 86 _createSelectorLine: function() { 87 this._selectorLine = new LineWithActionsWidget({ 88 title: 'None', 89 actions: { 90 "Toggle dropdown" : { 91 callback: lang.hitch(this, this.onToggle), 92 properties: { 93 blockButton: true, 94 showLabel: false, 95 icon: "HalfArrowDown" 96 } 97 } 98 } 99 },this.selectedItemNode); 100 this._selectorLine.startup(); 101 this._selectorLine.on('click',lang.hitch(this, this.onToggle)); 102 }, 103 _onSelect: function(item, widget) { 104 this._selectedItem = item; 105 this.onToggle(); 106 this._selectorLine.set("title", item.title); 107 baseArray.forEach(this.optionsNode.childNodes, function(node){ 108 var line = registry.byNode(node); 109 if (line) { 110 if (line === widget) { 111 domClass.add(line.domNode, "inheritBgColor light"); 112 } else { 113 domClass.remove(line.domNode, "inheritBgColor light"); 114 } 115 } 116 }, this); 117 this.onSelect(item); 118 }, 119 _onSelectedAction: function(callback) { 120 if (this._selectedItem && callback) { 121 callback(this._selectedItem); 122 } 123 }, 124 125 onToggle: function(evt) { 126 if (this._folded) { 127 var downArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowDown", this._selectorLine.buttonsNode)[0]; 128 if (downArrowIcon){ 129 domClass.replace(downArrowIcon, "rftIconHalfArrowUp", "rftIconHalfArrowDown"); 130 } 131 fx.wipeIn({ 132 node: this.optionsNode 133 }).play(); 134 this._folded = false; 135 } else { 136 var upArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowUp", this._selectorLine.buttonsNode)[0]; 137 if (upArrowIcon){ 138 domClass.replace(upArrowIcon, "rftIconHalfArrowDown", "rftIconHalfArrowUp"); 139 } 140 fx.wipeOut({ 141 node: this.optionsNode 142 }).play(); 143 this._folded = true; 144 } 145 evt && event.stop(evt); 146 return false; 147 }, 148 149 addItem: function(item) { 150 var actions = {}; 151 var action; 152 if (this.itemActions) { 153 for (var actionName in this.itemActions) { 154 action = this.itemActions[actionName]; 155 actions[actionName] = { 156 callback: function(){ 157 action.callback && action.callback(item); 158 }, 159 properties: { 160 blockButton: false, 161 showLabel: false, 162 icon: action.icon + " black", 163 tooltip: action.description 164 } 149 addItem: function(item) { 150 var actions = {}; 151 var action; 152 if (this.itemActions) { 153 for (var actionName in this.itemActions) { 154 action = this.itemActions[actionName]; 155 actions[actionName] = { 156 callback: function(){ 157 action.callback && action.callback(item); 158 }, 159 properties: { 160 blockButton: false, 161 showLabel: false, 162 icon: action.icon + " black", 163 tooltip: action.description 165 164 } 166 165 } 167 166 } 168 var w = new LineWithActionsWidget({ 169 title: item.title, 170 actions: actions 171 }).placeAt(this.optionsNode); 172 w.startup(); 173 w.on("click", lang.hitch(this, this._onSelect, item, w)); 174 }, 167 } 168 var w = new LineWithActionsWidget({ 169 title: item.title, 170 actions: actions 171 }).placeAt(this.optionsNode); 172 w.startup(); 173 w.on("click", lang.hitch(this, this._onSelect, item, w)); 174 }, 175 175 176 177 176 onSelect: function(item) {} 177 }); 178 178 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/content/ContentWidgetFactory.js
r404 r406 18 18 ],function(array, declare, lang, domConstruct, _TemplatedMixin, _WidgetBase, _Container, Button, CheckBox, NumberSpinner, RadioButton, Textarea, TextBox, TableContainer, _EditableListMixin, OrderedList) { 19 19 var factory = declare('rft.ui.content.ContentWidgetFactory', [], { 20 /* No default type, all should be valid */21 20 createViewWidget: function(/*Object*/options) { 22 21 // options: Object … … 151 150 _textBox: null, 152 151 postCreate: function() { 153 this._textBox = new TextBox(); 152 this._textBox = new TextBox({ 153 name: this.options.code || '' 154 }); 154 155 this.addChild(this._textBox); 155 156 this._textBox.startup(); … … 197 198 _textArea: null, 198 199 postCreate: function() { 199 this._textArea = new Textarea(); 200 this._textArea = new Textarea({ 201 name: this.options.code 202 }); 200 203 this._textArea.set('maxLength', this.options.maxLength || 1000); 201 204 this._textArea.set('value', this.options.defaultValue || ""); … … 256 259 postCreate: function() { 257 260 this._numberInput = new NumberSpinner({ 261 name: this.options.code || '', 258 262 constraints: { 259 263 min: this.options.min, … … 333 337 334 338 var ctor = this.options.multiple === true ? CheckBox : RadioButton; 335 array.forEach(this.options.items ,function(item){339 array.forEach(this.options.items || [],function(item){ 336 340 table.addChild(new ctor({ 341 name: this.options.code || '', 337 342 title: item 338 343 })); -
Dev/branches/rest-dojo-ui/client/rft/ui/lists/AccountListView.js
r396 r406 1 1 define([ 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 4 'dojo/dom-construct', 5 5 '../LineWithActionsWidget', 6 6 './OrderedList' 7 8 9 10 11 12 13 14 15 16 7 ],function( 8 declare, 9 lang, 10 domConstruct, 11 LineWithActionsWidget, 12 OrderedList 13 ) { 14 return declare('rft.ui.lists.AccountListView',[OrderedList],{ 15 baseClass: 'rftAccountListView', 16 type: 'account', 17 17 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "green", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete" 34 } 35 } 36 } 37 }); 38 w.startup(); 39 return w.domNode; 40 } 41 }); 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "green", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete" 34 } 35 } 36 } 37 }); 38 w.startup(); 39 return w.domNode; 40 } 42 41 }); 42 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/lists/MultipleChoiceListView.js
r396 r406 5 5 '../LineWithActionsWidget', 6 6 './OrderedList' 7 8 9 10 11 12 13 14 15 16 7 ],function( 8 declare, 9 lang, 10 domConstruct, 11 LineWithActionsWidget, 12 OrderedList 13 ) { 14 return declare('rft.ui.lists.MultipleChoiceListView',[OrderedList],{ 15 baseClass: 'rftMultipleChoiceListView', 16 type: 'multipleChoiceOption', 17 17 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "orange", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete" 34 } 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "orange", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete" 35 34 } 36 35 } 37 } );38 w.startup();39 return w.domNode;40 }41 } );36 } 37 }); 38 w.startup(); 39 return w.domNode; 40 } 42 41 }); 42 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/lists/QuestionListView.js
r396 r406 5 5 '../LineWithActionsWidget', 6 6 './OrderedList' 7 8 9 10 11 12 13 14 15 16 7 ],function( 8 declare, 9 lang, 10 domConstruct, 11 LineWithActionsWidget, 12 OrderedList 13 ){ 14 return declare('rft.ui.lists.QuestionListView',[OrderedList],{ 15 baseClass: 'rftSurveyListView', 16 type: 'question', 17 17 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "inheritBgColor", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 label: "Remove" 35 } 36 }, 37 "Info" : { 38 callback: function(){ item.description && alert(item.description); }, 39 properties: { 40 blockButton: false, 41 icon: "Inspect", 42 label: "Show info" 43 } 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "inheritBgColor", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 label: "Remove" 35 } 36 }, 37 "Info" : { 38 callback: function(){ item.description && alert(item.description); }, 39 properties: { 40 blockButton: false, 41 icon: "Inspect", 42 label: "Show info" 44 43 } 45 44 } 46 } );47 w.startup();48 return w.domNode;49 }50 } );45 } 46 }); 47 w.startup(); 48 return w.domNode; 49 } 51 50 }); 51 });
Note: See TracChangeset
for help on using the changeset viewer.