Changeset 303 for Dev/branches/rest-dojo-ui/client
- Timestamp:
- 03/04/12 15:48:42 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/questions.js
r288 r303 1 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event', 2 'dojo/_base/Deferred','dojo/dom-construct',' dojo/store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane',2 'dojo/_base/Deferred','dojo/dom-construct','rft/store','dijit/TitlePane', 3 3 'rft/ui/_Page','rft/ui/LineWithActionsWidget'], 4 function(declare,lang,array,event,Deferred,domConstruct, JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) {4 function(declare,lang,array,event,Deferred,domConstruct,store,TitlePane,_Page,LineWithActionsWidget) { 5 5 return declare('rft.pages.questions',[_Page],{ 6 6 constructor: function() { … … 9 9 }, 10 10 onVisit: function() { 11 this._store = new JsonRest({ 12 target:"../server/api.php/data/Question/", 13 idProperty: 'uid' 14 }); 11 this._store = store.getStore('Question'); 15 12 this._refresh(true); 16 13 }, 17 14 _refresh: function(initial) { 18 Deferred.when( this._store.query() ).then(lang.hitch(this,function(results){ 15 Deferred.when( this._store.query() ) 16 .then(lang.hitch(this,function(results){ 19 17 array.forEach(results,lang.hitch(this,'_addQuestion')); 20 18 initial && this.accordion.selectChild(true); … … 22 20 }, 23 21 _addQuestion: function(q) { 24 var uid = q. uid;22 var uid = q.getUid(); 25 23 var question = this.questions[uid]; 26 24 if ( !question ) { … … 54 52 var placeNode = this.accordion.domNode; 55 53 var placePos = 'last'; 56 array.some(widgets,lang.hitch(this,function(widget ,idx) {54 array.some(widgets,lang.hitch(this,function(widget) { 57 55 if ( widget.title == category ) { 58 56 containerWidget = widget; -
Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html
r274 r303 24 24 var submitHandler = lang.hitch(that,function(evt){ 25 25 var newObj = this.form.get('value'); 26 debugger;27 26 // mixin newObj in obj. 28 27 // store.put(newObj); -
Dev/branches/rest-dojo-ui/client/rft/pages/survey.html
r292 r303 1 1 <div data-dojo-type="rft.pages.survey"> 2 2 <h1 data-rft-attach-point="header">(default)</h1> 3 <div>Created by <span data-rft-attach-point="creator"></span><div> 3 4 <form data-dojo-type="dijit.form.Form" data-rft-attach-point="form" data-rft-attach-event="onSubmit:onSave"> 4 5 <div style="display: block; clear: both;"> -
Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
r292 r303 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dojo/_base/Deferred',' dojo/store/JsonRest','rft/ui/_Page'],2 function(declare,lang,event,Deferred, JsonRest,_Page){1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dojo/_base/Deferred','rft/store','rft/ui/_Page'], 2 function(declare,lang,event,Deferred,store,_Page){ 3 3 return declare('rft.pages.survey',[_Page],{ 4 4 object: null, 5 5 postCreate: function() { 6 6 this.inherited(arguments); 7 this._store = new JsonRest({ 8 target:"../server/api.php/data/Survey/", 9 idProperty: 'uid' 10 }); 7 this._store = store.getStore('Survey'); 11 8 }, 12 9 onVisit: function() { … … 16 13 this.object = obj; 17 14 this.setFields(obj); 15 return Deferred.when( obj.creator && store.dereference(obj.creator) ); 16 })) 17 .then(lang.hitch(this,function(obj){ 18 this.creator.innerHTML = (obj && obj.email) || 'unknown'; 18 19 })); 19 20 } else { -
Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js
r292 r303 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/ store/JsonRest','dojo/data/ObjectStore','rft/content','rft/ui/_Page'],2 function(declare,lang, JsonRest,ObjectStore,content,_Page){1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/Deferred','dojo/data/ObjectStore','rft/auth','rft/store','rft/content','rft/ui/_Page'], 2 function(declare,lang,Deferred,ObjectStore,auth,store,content,_Page){ 3 3 return declare('rft.pages.surveys',[_Page],{ 4 4 selectedObject: null, 5 5 postCreate: function() { 6 this._store = new JsonRest({ 7 target:"../server/api.php/data/Survey/", 8 idProperty: 'uid' 9 }); 6 this._store = store.getStore('Survey'); 10 7 }, 11 8 onVisit: function() { … … 14 11 this.grid.on('rowclick',lang.hitch(this,function(evt){ 15 12 this.selectedObject = evt.grid.getItem(evt.rowIndex); 16 this.btnEdit.set('disabled',! !this.selectedObject);13 this.btnEdit.set('disabled',!this.selectedObject); 17 14 })); 18 15 19 16 this.grid.on('rowdblclick',lang.hitch(this,function(evt){ 20 17 var obj = evt.grid.getItem(evt.rowIndex); 21 content.goTo('/survey',{uid:obj. uid});18 content.goTo('/survey',{uid:obj.getUid()}); 22 19 })); 23 20 24 21 this.btnNew.on('click',lang.hitch(this,function(){ 25 this._store.add({},function(obj) { 26 content.goTo('/survey',{uid:this.selectedObject.uid}); 22 Deferred.when( this._store.add({'creator':auth.getUser()}) ) 23 .then(function(obj) { 24 content.goTo('/survey',{uid:obj.getUid()}); 27 25 }); 28 26 })); … … 30 28 this.btnEdit.on('click',lang.hitch(this,function(){ 31 29 if ( this.selectedObject ) { 32 content.goTo('/survey',{uid:this.selectedObject. uid});30 content.goTo('/survey',{uid:this.selectedObject.getUid()}); 33 31 } 34 32 -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js
r288 r303 1 define(['dojo/_base/declare','dojo/ dom-construct','dijit/_WidgetBase',1 define(['dojo/_base/declare','dojo/_base/lang','dojo/dom-construct','dijit/_WidgetBase', 2 2 'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin', 3 3 'dojo/text!./templates/QuestionWidget.html','dijit/form/TextBox', 4 4 'dijit/form/Textarea','./MultipleChoiceWidget'], 5 function(declare, domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){5 function(declare,lang,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){ 6 6 return declare('rft.ui.QuestionWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 7 7 templateString: templateString, 8 8 mode: 'view', // view || edit 9 9 name: '', 10 value: null, 10 11 _type: null, 11 12 _widgetCache: null, 12 13 constructor: function() { 13 14 this.inherited(arguments); 15 this.value = {}; 14 16 this._widgetCache = {}; 15 17 }, 16 18 postCreate: function() { 19 this._resetValue = this.value; 17 20 this.typeSelector.set('disabled', this.mode == 'edit'); 18 21 }, 19 22 _setValueAttr: function(value) { 20 value.type && this._onTypeChange(value.type); 23 this.value = value; 24 this._onTypeChange(value.type || 'string'); 21 25 this.ourForm.set('value',value); 22 26 }, 23 27 _getValueAttr: function() { 24 return this.ourForm.get('value'); 28 var value = this.ourForm.get('value'); 29 lang.mixin(this.value,value); 30 return this._question; 25 31 }, 26 32 _onTypeChange: function(type) { … … 60 66 } 61 67 return widget; 68 }, 69 reset: function() { 70 this.ourForm.reset(); 71 this._setValueAttr(this._resetValue); 62 72 } 63 73 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionWidget.html
r288 r303 2 2 <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="ourForm"> 3 3 <fieldset> 4 <input data-dojo-type="dijit.form.TextBox" name="uid" type="text" class="dijitHidden" />5 4 <label for="code" class="loginLabel">Code</label> 6 5 <input data-dojo-type="dijit.form.TextBox" name="code" type="text" class="loginInput" />
Note: See TracChangeset
for help on using the changeset viewer.