Changeset 288 for Dev/branches/rest-dojo-ui/client
- Timestamp:
- 02/24/12 16:09:22 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft
- Files:
-
- 3 added
- 9 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/css/main.css
r281 r288 34 34 width: 150px; 35 35 } 36 37 .rftMultipleChoiceWidget { 38 display: table; 39 } 40 41 .rftMultipleChoiceWidget .row { 42 display: table-row; 43 } 44 45 .rftMultipleChoiceWidget .rowBox { 46 display: table-cell; 47 } 48 49 .rftMultipleChoiceWidget .rowText { 50 display: table-cell; 51 width: 100px; 52 } 53 54 .rftMultipleChoiceWidget .rowBtn { 55 display: table-cell; 56 width: 30px; 57 } -
Dev/branches/rest-dojo-ui/client/rft/pages/questions.html
r281 r288 6 6 <div data-dojo-type="dijit.Dialog" title="Question" data-rft-attach-point="questionDialog"> 7 7 <form data-dojo-type="dijit.form.Form" data-rft-attach-point="questionForm" data-rft-attach-event="onSubmit:onSaveQuestion"> 8 <fieldset> 9 <input data-dojo-type="dijit.form.TextBox" name="uid" type="text" class="dijitHidden" /> 10 <label for="code" class="loginLabel">Code</label> 11 <input data-dojo-type="dijit.form.TextBox" name="code" type="text" class="loginInput" /> 12 <label for="question" class="loginLabel">Title</label> 13 <input data-dojo-type="dijit.form.TextBox" name="title" type="text" class="loginInput" /> 14 <label for="question" class="loginLabel">Description</label> 15 <input data-dojo-type="dijit.form.Textarea" name="description" type="text" class="loginInput"/> 16 <label for="category" class="loginLabel">Category</label> 17 <input data-dojo-type="dijit.form.TextBox" name="category" type="text" class="loginInput" /> 18 </fieldset> 19 <fieldset> 20 <div data-dojo-type="rft.ui.QuestionWidget" data-rft-attach-point="questionWidget" ></div> 21 </fieldset> 8 <div data-dojo-type="rft.ui.QuestionWidget" data-rft-attach-point="questionWidget"></div> 22 9 <div style="float: right;"> 23 10 <button type="button" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onCancelQuestion">Cancel</button> -
Dev/branches/rest-dojo-ui/client/rft/pages/questions.js
r281 r288 1 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event', 2 'dojo/_base/Deferred','dojo/ store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane',2 'dojo/_base/Deferred','dojo/dom-construct','dojo/store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane', 3 3 'rft/ui/_Page','rft/ui/LineWithActionsWidget'], 4 function(declare,lang,array,event,Deferred, JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) {4 function(declare,lang,array,event,Deferred,domConstruct,JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) { 5 5 return declare('rft.pages.questions',[_Page],{ 6 6 constructor: function() { … … 13 13 idProperty: 'uid' 14 14 }); 15 this._refresh( );15 this._refresh(true); 16 16 }, 17 _refresh: function( ) {17 _refresh: function(initial) { 18 18 Deferred.when( this._store.query() ).then(lang.hitch(this,function(results){ 19 19 array.forEach(results,lang.hitch(this,'_addQuestion')); 20 initial && this.accordion.selectChild(true); 20 21 })); 21 22 }, … … 50 51 var category = q.category || 'Unsorted'; 51 52 var widgets = this.accordion.getChildren(); 52 var containerWidget; 53 var lastIndex = 'last'; 53 var containerWidget = null; 54 var placeNode = this.accordion.domNode; 55 var placePos = 'last'; 54 56 array.some(widgets,lang.hitch(this,function(widget,idx) { 55 57 if ( widget.title == category ) { … … 57 59 return true; 58 60 } else if ( widget.title > category ) { 59 lastIndex = idx; 61 placeNode = widget.domNode; 62 placePos = "before"; 60 63 return true; 61 64 } … … 67 70 }); 68 71 containerWidget.startup(); 69 this.accordion.addChild(containerWidget,lastIndex);72 domConstruct.place(containerWidget.domNode,placeNode,placePos); 70 73 } 71 74 return containerWidget; … … 87 90 _editQuestion: function(question) { 88 91 this.questionForm.reset(); 89 this.questionForm.set('value',question);90 92 this.questionWidget.set('value',question); 91 93 this.questionDialog.show(); 92 94 }, 93 95 onSaveQuestion: function(evt) { 94 var value = this.questionForm.get('value'); 95 var subvalue = this.questionWidget.get('value'); 96 lang.mixin(value,subvalue); 96 var value = this.questionWidget.get('value'); 97 97 Deferred.when( this._store.put(value) ) 98 98 .then(lang.hitch(this,function(){ -
Dev/branches/rest-dojo-ui/client/rft/run.js
r281 r288 1 1 require([ 2 // functions required for run 3 'dojo/_base/window','dojo/parser', 'rft/ui/LoginDialog', 4 'dojo/dom', 'dojo/_base/connect', 'rft/auth', 'rft/content', 5 'dojo/domReady!', 6 7 // general widgets 2 8 'dojo/data/ObjectStore', 3 9 'dojo/store/JsonRest', … … 23 29 'rft/ui/QuestionWidget', 24 30 'rft/ui/TitleGroup', 25 'rft/pages/questions' // could this be done dynamically? 26 ]); 27 28 require(['dojo/_base/window','dojo/parser', 'rft/ui/LoginDialog', 29 'dojo/dom', 'dojo/_base/connect', 'rft/auth', 'rft/content', 30 'dojo/domReady!' ], 31 32 // pages -> load dynamically? 33 'rft/pages/questions'], 31 34 function(win,parser,LoginDialog,dom,connect,auth,content) { 32 35 parser.parse(); -
Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidget.js
r275 r288 1 define(['dojo/_base/declare','dojo/_base/lang','dijit/form/Button','dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dojo/text!rft/ui/LineWithActionsWidget.html'], 1 define(['dojo/_base/declare','dojo/_base/lang','dijit/form/Button', 2 'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin', 3 'dojo/text!./templates/LineWithActionsWidget.html'], 2 4 function(declare,lang,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 3 5 return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ -
Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.js
r274 r288 1 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dijit/Dialog', 2 'dijit/_WidgetsInTemplateMixin','../auth', 'dojo/text!./ LoginDialog.html',2 'dijit/_WidgetsInTemplateMixin','../auth', 'dojo/text!./templates/LoginDialog.html', 3 3 '../content','dijit/form/Form','dijit/form/Button','dijit/form/TextBox'], 4 4 function (declare, lang, event, Dialog, _WidgetsInTemplateMixin, auth, template, content) { -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js
r281 r288 1 require(['dojo/_base/declare','dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dojo/text!rft/ui/QuestionWidget.html','dijit/form/TextBox'], 2 function(declare,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox){ 3 declare('rft.ui.QuestionWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 1 define(['dojo/_base/declare','dojo/dom-construct','dijit/_WidgetBase', 2 'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin', 3 'dojo/text!./templates/QuestionWidget.html','dijit/form/TextBox', 4 'dijit/form/Textarea','./MultipleChoiceWidget'], 5 function(declare,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){ 6 return declare('rft.ui.QuestionWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 4 7 templateString: templateString, 5 8 mode: 'view', // view || edit 6 type: 'string', 7 _w: null, 9 name: '', 10 _type: null, 11 _widgetCache: null, 12 constructor: function() { 13 this.inherited(arguments); 14 this._widgetCache = {}; 15 }, 8 16 postCreate: function() { 9 this. _setType(this.type);17 this.typeSelector.set('disabled', this.mode == 'edit'); 10 18 }, 11 _setType: function(type) { 12 if ( !this._w || this.type != type ) { 13 if ( this._w ) { 14 this._w.destroy(); 15 this._w = null; 16 } 17 this.type = type; 18 switch(type) { 19 case 'string': 20 this._getStringWidget().placeAt(this.typeDetails); 21 break; 22 case 'text': 23 break; 24 case 'multipleChoice': 25 break; 26 } 27 } 28 }, 29 _getStringWidget: function() { 30 if ( !this._stringWidget ) { 31 this._stringWidget = new TextBox({ 32 name: 'answers', 33 disabled: this.mode == 'view' 34 }); 35 } 36 return this._stringWidget; 19 _setValueAttr: function(value) { 20 value.type && this._onTypeChange(value.type); 21 this.ourForm.set('value',value); 37 22 }, 38 23 _getValueAttr: function() { 39 24 return this.ourForm.get('value'); 40 25 }, 41 _setValueAttr: function(value) { 42 return this.ourForm.set('value',value); 26 _onTypeChange: function(type) { 27 if ( this._type == type ) return; 28 this._type = type; 29 domConstruct.empty(this.typeDetails); 30 var widget = this._getTypeWidget(type); 31 widget && widget.placeAt(this.typeDetails,'only'); 32 }, 33 _getTypeWidget: function(type) { 34 var widget = this._widgetCache[type]; 35 if (!widget) { 36 switch(type) { 37 case 'string': 38 widget = new TextBox({ 39 name: 'answers', 40 disabled: this.mode == 'view' 41 }); 42 break; 43 case 'text': 44 widget = new Textarea({ 45 name: 'answers', 46 disabled: this.mode == 'view', 47 style: 'min-height: 120px' 48 }); 49 break; 50 case 'singleChoice': 51 case 'multipleChoice': 52 widget = new MultipleChoiceWidget({ 53 name: 'answers', 54 mode: this.mode, 55 allowMultiple: type == 'multipleChoice' 56 }); 57 break; 58 } 59 this._widgetCache[type] = widget; 60 } 61 return widget; 43 62 } 44 63 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/TitleGroup.js
r281 r288 1 require(['dojo/_base/declare','dojo/_base/query','dijit/registry','dojox/widget/TitleGroup'],function(declare,query,registry,TitleGroup){ 2 declare('rft.ui.TitleGroup',[TitleGroup],{ 3 getChildren: function() { 4 return query("> .dijitTitlePane", this.domNode) 5 .map(function(node){ 6 return registry.byNode(node); 7 }); 8 } 1 require(['dojo/_base/declare','dojo/_base/query','dijit/registry','dojox/widget/TitleGroup'], 2 function(declare,query,registry,TitleGroup){ 3 return declare('rft.ui.TitleGroup',[TitleGroup],{ 4 getChildren: function() { 5 return query("> .dijitTitlePane", this.domNode) 6 .map(function(node){ 7 return registry.byNode(node); 8 }); 9 } 10 }); 9 11 }); 10 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/_Page.js
r274 r288 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser','dojo/query','dojo/dom-attr','dojo/_base/connect','dijit','dijit/_WidgetBase','dijit/_Container','dijit/_Contained'], 1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/parser', 2 'dojo/query','dojo/dom-attr','dojo/_base/connect','dijit','dijit/_WidgetBase', 3 'dijit/_Container','dijit/_Contained'], 2 4 function(declare,lang,array,parser,query,attr,connect,dijit,_WidgetBase,_Container,_Contained){ 3 5 return declare('rft.ui._Page',[_WidgetBase],{ -
Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionWidget.html
r281 r288 1 1 <div> 2 2 <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="ourForm"> 3 <select data-dojo-type="dijit.form.Select" data-dojo-attach-point="typeSelector" name="type"> 4 <option value="string" selected>String</option> 5 <option value="text">Text</option> 6 <option value="multipleChoice">Multiple choice</option> 7 </select> 8 <div data-dojo-attach-point="typeDetails"> 9 </div> 3 <fieldset> 4 <input data-dojo-type="dijit.form.TextBox" name="uid" type="text" class="dijitHidden" /> 5 <label for="code" class="loginLabel">Code</label> 6 <input data-dojo-type="dijit.form.TextBox" name="code" type="text" class="loginInput" /> 7 <label for="question" class="loginLabel">Title</label> 8 <input data-dojo-type="dijit.form.TextBox" name="title" type="text" class="loginInput" /> 9 <label for="question" class="loginLabel">Description</label> 10 <input data-dojo-type="dijit.form.Textarea" name="description" type="text" class="loginInput"/> 11 <label for="category" class="loginLabel">Category</label> 12 <input data-dojo-type="dijit.form.TextBox" name="category" type="text" class="loginInput" /> 13 </fieldset> 14 <fieldset> 15 <select data-dojo-type="dijit.form.Select" data-dojo-attach-point="typeSelector" data-dojo-attach-event="onChange:_onTypeChange" name="type"> 16 <option value="string" selected>String</option> 17 <option value="text">Text</option> 18 <option value="singleChoice">Single choice</option> 19 <option value="multipleChoice">Multiple choice</option> 20 </select> 21 <div data-dojo-attach-point="typeDetails"></div> 22 </fieldset> 10 23 </form> 11 24 </div>
Note: See TracChangeset
for help on using the changeset viewer.