- Timestamp:
- 03/10/14 16:07:00 (11 years ago)
- Location:
- Dev/trunk/src/client/qed-client
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorPreviewItem.js
r443 r500 1 1 define([ 2 "../../widgets/_ComplexValueWidget", 2 3 "./questions/Factory", 3 4 "dijit/_Container", … … 14 15 "dojo/on", 15 16 "dojo/text!./templates/QuestionEditorPreviewItem.html" 16 ], function( QuestionWidgetFactory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, event, fx, lang, domClass, domGeom, domStyle, on, template) {17 return declare([_ WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], {17 ], function(_ComplexValueWidget, QuestionWidgetFactory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, event, fx, lang, domClass, domGeom, domStyle, on, template) { 18 return declare([_ComplexValueWidget], { 18 19 templateString: template, 19 20 baseClass: "qedQuestionEditorPreviewItem", … … 87 88 this._destroyInnerWidget(); 88 89 this.innerWidget = newWidget; 89 this.innerWidget.placeAt(this.containerNode); 90 this.innerWidget.startup(); 90 this.addChild(this.innerWidget); 91 91 this.innerWidget.set('readOnly',true); 92 92 this.titleNode.innerHTML = this.value.type+" [preview]"; … … 101 101 this._destroyInnerWidget(); 102 102 this.innerWidget = newWidget; 103 this.innerWidget.placeAt(this.containerNode); 104 this.innerWidget.startup(); 103 this.addChild(this.innerWidget); 105 104 this.titleNode.innerHTML = this.value.type+" [editing]"; 106 105 domClass.replace(this.editButton.iconNode, "rftIconAccept", "rftIconEdit"); … … 111 110 _destroyInnerWidget: function() { 112 111 if ( this.innerWidget !== null ) { 112 this.removeChild(this.innerWidget); 113 113 this.innerWidget.destroyRecursive(); 114 this.innerWidget = null; 114 115 } 115 116 }, -
Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputWidget.js
r495 r500 32 32 _getValueAttr: function() { 33 33 var value = this.inherited(arguments); 34 if ( this.allowMultiple === true ) {34 /*if ( this.allowMultiple === true ) { 35 35 return value; 36 36 } else { 37 return value.choice .length > 0;38 } 37 return value.choice; //.length > 0; 38 }*/ 39 39 }, 40 40 _setValueAttr: function(value) { -
Dev/trunk/src/client/qed-client/model/widgets/templates/QuestionEditorPreviewItem.html
r443 r500 1 < div>1 <form> 2 2 <div class="topBorder inheritBgColor bg dojoDndHandle"> 3 3 <span class="title" data-dojo-attach-point="titleNode">Default title</span> … … 13 13 </div> 14 14 </div> 15 </ div>15 </form> -
Dev/trunk/src/client/qed-client/pages/_ObjectPage.js
r492 r500 22 22 _load: function() { 23 23 if ( this.object ) { 24 this._refresh( );24 this._refresh(true); 25 25 } else if ( this.objectId ) { 26 26 if ( this.objectId === "new" ) { 27 27 this.object = this.classStore.create(); 28 this._refresh(); 28 this.markDirty(); 29 this._refresh(true); 29 30 } else { 30 31 this.classStore.load(this.objectId) 31 .then(lang.hitch(this,'_setObject'), 32 lang.hitch(this,function(err){ 33 this.die(err.error); 34 })); 32 .then(lang.hitch(this,function(object){ 33 this._setObject(object,true); 34 }),lang.hitch(this,function(err){ 35 this.die(err.error); 36 })); 35 37 } 36 38 } else { 37 this.die("No valid uid or object passed!");39 this.die("No valid id or object passed!"); 38 40 } 39 41 }, 40 _setObject: function(object ) {42 _setObject: function(object,initial) { 41 43 this.object = object; 42 44 if ( this.objectId === "new" ) { 43 45 this.go(this.classStore.getObjectPath(this.object),{},true); 44 46 } 45 this._refresh(); 47 this.markClean(); 48 this._refresh(initial); 46 49 }, 47 _refresh: function( ) {},50 _refresh: function(initial) {}, 48 51 _save: function() { 49 52 return this.classStore.save(this.object) 50 53 .then(lang.hitch(this,function(object){ 51 this.markClean();52 54 this._setObject(object); 53 55 this.notify(this.classStore.getName()+" successfully saved."); -
Dev/trunk/src/client/qed-client/pages/question.js
r498 r500 23 23 this._load(); 24 24 }, 25 _refresh: function() { 26 this.propertiesForm.set('value',this.object,null); 27 this.contentList.set('value',this.object.content,null); 28 this._internalRefresh(); 29 }, 30 _internalRefresh: function(){ 25 _refresh: function(initial) { 26 if ( initial === true ) { 27 this.propertiesForm.set('value',this.object,null); 28 this.contentList.set('value',this.object.content,null); 29 } 31 30 this.titleNode.innerHTML = this.object.title || ""; 32 31 }, … … 34 33 this._updateObject(); 35 34 this.markDirty(); 36 this._ internalRefresh();35 this._refresh(); 37 36 }, 38 37 _handleContentChange: function() { 39 38 this._updateObject(); 40 39 this.markDirty(); 41 this._ internalRefresh();40 this._refresh(); 42 41 }, 43 42 _updateObject: function() { -
Dev/trunk/src/client/qed-client/pages/survey.js
r498 r500 61 61 this.questionList.startup(); 62 62 }, 63 _refresh: function() { 64 this.propertiesForm.set('value',{survey:this.object},null); 65 this.questionList.set('value',this.object.questions,null); 66 this._internalRefresh(); 67 }, 68 _internalRefresh: function() { 63 _refresh: function(initial) { 64 if ( initial === true ) { 65 this.propertiesForm.set('value',{survey:this.object},null); 66 this.questionList.set('value',this.object.questions,null); 67 } 69 68 this.titleNode.innerHTML = this.object.title || "(set title in properties)"; 70 69 }, … … 75 74 this.object.questions = this.questionList.get('value'); 76 75 this.markDirty(); 77 this._ internalRefresh();76 this._refresh(); 78 77 }, 79 78 _onShowProperties: function(evt) { … … 86 85 lang.mixin(this.object, this.propertiesForm.get('value').survey); 87 86 this.markDirty(); 88 this._ internalRefresh();87 this._refresh(); 89 88 if ( evt ) { event.stop(evt); } 90 89 return false; -
Dev/trunk/src/client/qed-client/pages/surveyRun.js
r498 r500 29 29 this._load(); 30 30 }, 31 _refresh: function() { 32 this.surveySummaryWidget.set('value',this.object.survey,null); 33 this.surveyRunWidget.set('value',this.object,null); 34 this._internalRefresh(); 35 this._loadResponses(); 36 }, 37 _internalRefresh: function() { 31 _refresh: function(initial) { 32 if ( initial === true ) { 33 this.surveySummaryWidget.set('value',this.object.survey,null); 34 this.surveyRunWidget.set('value',this.object,null); 35 this._loadResponses(); 36 } 38 37 this.titleNode.innerHTML = this.object.title || ""; 39 38 if ( this.object.mode === "open" ) { … … 77 76 this._updateObject(); 78 77 this.markDirty(); 79 this._ internalRefresh();78 this._refresh(); 80 79 }, 81 80 _buildGeneralURL: function(surveyRun) { -
Dev/trunk/src/client/qed-client/widgets/ListWidget.js
r494 r500 14 14 name: "", 15 15 value: null, 16 disabled: false, 17 readOnly: false, 16 18 multiple: true, 17 19 type: "text", … … 20 22 */ 21 23 container: Source, 24 _onChangeActive: false, 22 25 buildRendering: function() { 23 26 this.inherited(arguments); … … 50 53 }); 51 54 this.source = new this.container(this.domNode,sourceParams); 52 this.own(this.source.on('Drop',lang.hitch(this,'_handleChange'))); 55 this.own(this.source.on('Drop', 56 lang.hitch(this,'_handleDrop'))); 57 this.own(on(this.domNode,'change', 58 lang.hitch(this,'_handleChange'))); 53 59 }, 54 60 creator: function(item, hint) { … … 92 98 return this.value; 93 99 }, 94 _setValueAttr: function(value ) {100 _setValueAttr: function(value,priorityChange) { 95 101 this.clear(); 96 102 this.appendItems(value || []); … … 158 164 this.inherited(arguments); 159 165 }, 160 _handleChange: function() { 161 this.value = this._getValueAttr(); 162 this.onChange(this.value); 166 _handleChange: function(evt) { 167 if ( evt.target !== this.domNode ) { 168 if ( this._onChangeActive && !(this.readOnly || this.disabled) ) { 169 this.emit('change',this.get('value')); 170 } 171 if ( evt ) { event.stop(evt); } 172 return false; 173 } 174 return true; 163 175 }, 164 onChange: function(value) {} 176 _handleDrop: function() { 177 if ( this._onChangeActive && !(this.readOnly || this.disabled) ) { 178 this.emit('change',this.get('value')); 179 } 180 } 165 181 }); 166 182 }); -
Dev/trunk/src/client/qed-client/widgets/_ComplexValueMixin.js
r493 r500 11 11 return declare([_Container, _FormMixin], { 12 12 name: "", 13 value: null, 13 14 disabled: false, 14 15 readOnly: false, 15 _changeActive: false, 16 _onChangeActive: false, 17 constructor: function() { 18 this._listenerMap = {}; 19 }, 20 buildRendering: function() { 21 // capture child change events 22 this.inherited(arguments); 23 this.own(on(this.domNode,'change', 24 lang.hitch(this,'_handleChange'))); 25 }, 26 create: function() { 27 this.inherited(arguments); 28 this._onChangeActive = true; 29 }, 16 30 postCreate: function() { 17 31 this.inherited(arguments); … … 24 38 if (this._started) { return; } 25 39 this.inherited(arguments); 26 this._connectChildren();27 this._changeActive = true;28 },29 _connectChildren: function() {30 var children = this._getDescendantFormWidgets();31 array.forEach(children, lang.hitch(this,function(child) {32 this.own(child.on('change',lang.hitch(this,'_handleChange')));33 }));34 40 }, 35 41 _setDisabledAttr: function(value) { … … 41 47 // Yuk, this function is taken directly from _FromMixin only 42 48 // to add the priorityChange parameter 49 _getValueAttr: function() { 50 this.value = this.inherited(arguments); 51 return this.value; 52 }, 43 53 _setValueAttr: function(obj, priorityChange) { 54 this.value = obj; 55 44 56 var map = { }; 45 57 array.forEach(this._getDescendantFormWidgets(), function(widget){ … … 84 96 } 85 97 }, 86 _handleChange: function() { 87 if ( this._changeActive ) { 88 this.onChange(this.get('value')); 98 _handleChange: function(evt) { 99 if ( evt.target !== this.domNode ) { 100 if ( this._onChangeActive && !(this.readOnly || this.disabled) ) { 101 this.emit('change',this.get('value')); 102 } 103 if ( evt ) { event.stop(evt); } 104 return false; 89 105 } 106 return true; 90 107 }, 91 onChange: function(){},92 108 _handleSubmit: function(evt) { 93 109 var node = this.domNode;
Note: See TracChangeset
for help on using the changeset viewer.