- Timestamp:
- 03/12/14 15:16:54 (11 years ago)
- Location:
- Dev/trunk/src
- Files:
-
- 9 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/css/qed.less
r506 r510 32 32 @import "widgets/LineWithActions.less"; 33 33 @import "model/widgets/ScaleWidget.less"; 34 @import "model/widgets/StringInput.less"; 35 @import "model/widgets/TextInput.less"; 36 @import "model/widgets/NumberInput.less"; 34 37 @import "model/widgets/MultipleChoiceWidget.less"; 35 38 @import "model/widgets/QuestionListView.less"; -
Dev/trunk/src/client/qed-client/model/classes/_Class.js
r506 r510 1 1 define([ 2 "../../lib/object", 2 3 "./_View", 3 4 "dojo/_base/array", … … 5 6 "dojo/_base/lang", 6 7 "dojo/date/stamp" 7 ], function( _View, array, declare, lang, stamp) {8 ], function(objectFuns, _View, array, declare, lang, stamp) { 8 9 9 10 var _Class = declare([_View],{ … … 24 25 obj = lang.clone(obj); 25 26 obj = this._serialize(obj) || obj; 26 this._s trip(obj);27 this._sanitize(obj); 27 28 return obj; 28 29 }, … … 65 66 return stamp.toISOString(date,{zulu:true,milliseconds:false}); 66 67 }, 67 _s trip: function(obj) {68 _sanitize: function(obj) { 68 69 if ( lang.isArray(obj) ) { 69 array.forEach(obj,this._s trip,this);70 array.forEach(obj,this._sanitize,this); 70 71 } else if ( lang.isObject(obj) ) { 71 for ( var prop in obj ) { 72 if ( obj.hasOwnProperty(prop) ) { 73 var v = obj[prop]; 74 if ( v === null || v === "" || (typeof v === "number" && isNaN(v)) ) { 75 delete obj[prop]; 76 } else { 77 this._strip(v); 78 } 72 objectFuns.forEach(obj,function(v,prop){ 73 if ( v === null || 74 v === "" || 75 (typeof v === "number" && isNaN(v)) ) { 76 delete obj[prop]; 77 } else { 78 this._sanitize(v); 79 79 } 80 } 80 81 },this); 81 82 } 82 83 83 } 84 84 }); -
Dev/trunk/src/client/qed-client/model/classes/responses.js
r509 r510 1 1 define([ 2 "../../lib/object", 2 3 "./_Class", 3 4 "./surveyRuns", … … 7 8 "dojo/_base/lang", 8 9 "dojo/_base/xhr" 9 ], function( _Class, surveyRuns, Deferred, declare, json, lang, xhr) {10 ], function(objectFuns, _Class, surveyRuns, Deferred, declare, json, lang, xhr) { 10 11 11 12 var Responses = declare([_Class],{ … … 29 30 }, 30 31 _serialize: function(obj) { 32 this._convertCheckAndRadio(obj.answers); 31 33 if (obj._surveyRun) { 32 34 obj._surveyRun = surveyRuns._doSerialize(obj._surveyRun); … … 84 86 return result; 85 87 },lang.hitch(this,'_deserializeError')); 88 }, 89 _convertCheckAndRadio: function(answers) { 90 // When we encounter an array, we assume it's really a 91 // checkbox value. 92 objectFuns.forEach(answers,function(v,prop){ 93 if ( lang.isArray(v) ) { 94 switch (v.length) { 95 case 0: 96 case 1: 97 answers[prop] = v[0]; 98 break; 99 default: 100 throw new Error("Responses cannot exist of array values."); 101 } 102 } 103 },this); 86 104 } 87 105 }); -
Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorPreview.js
r490 r510 23 23 value: item 24 24 }); 25 previewItem.showEdit(); 25 26 this.own(previewItem.on('destroy', 26 27 lang.hitch(this,'removeItem',id,true))); -
Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorPreviewItem.js
r508 r510 6 6 "dijit/_WidgetBase", 7 7 "dijit/_WidgetsInTemplateMixin", 8 "dojo/_base/array", 8 9 "dojo/_base/declare", 9 10 "dojo/_base/event", … … 15 16 "dojo/on", 16 17 "dojo/text!./templates/QuestionEditorPreviewItem.html" 17 ], function(_ComplexValueWidget, QuestionWidgetFactory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, event, fx, lang, domClass, domGeom, domStyle, on, template) {18 ], function(_ComplexValueWidget, QuestionWidgetFactory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, array, declare, event, fx, lang, domClass, domGeom, domStyle, on, template) { 18 19 return declare([_ComplexValueWidget], { 19 20 templateString: template, … … 24 25 foldDuration: [250, 250], 25 26 animation: null, 26 _editing: false,27 _editing: null, 27 28 _factory: new QuestionWidgetFactory(), 28 29 … … 36 37 this.own(this.editButton.on('click', 37 38 lang.hitch(this, 'onToggleEdit'))); 38 this.show Edit();39 this.showView(); 39 40 }, 40 41 _handleDestroy: function(evt) { … … 44 45 }, 45 46 _getValueAttr: function(value) { 46 if ( this._editing ) {47 if ( this._editing === true ) { 47 48 this.value = this.innerWidget.get('value'); 48 49 } … … 51 52 _setValueAttr: function(value) { 52 53 this.value = value; 53 if ( this._editing ) {54 if ( this._editing === true ) { 54 55 this._showEditWidget(); 55 56 } else { … … 57 58 } 58 59 }, 59 _setReadOnlyAttr: function() { 60 this.inherited(arguments); 60 _setReadOnlyAttr: function(readOnly) { 61 this._set('readOnly',readOnly); 62 this._setReadOnlyChildren(this.readOnly); 61 63 this._updateRemoveBtn(); 62 64 }, 63 _setDisabledAttr: function() { 64 this.inherited(arguments); 65 _setDisabledAttr: function(disabled) { 66 this._set('disabled',disabled); 67 this._setDisabledChildren(this.disabled); 65 68 this._updateRemoveBtn(); 66 69 }, 67 70 _updateRemoveBtn: function() { 71 var node = this.removeButton.domNode; 68 72 if ( this.readOnly || this.disabled ) { 69 domClass.add( this.removeButton.domNode, 'dijitHidden');73 domClass.add(node, 'dijitHidden'); 70 74 } else { 71 domClass.remove( this.removeButton.domNode, 'dijitHidden');75 domClass.remove(node, 'dijitHidden'); 72 76 } 73 77 }, 78 _setDisabledChildren: function(disabled) { 79 array.forEach(this._getDescendantFormWidgets(),function(widget){ 80 widget.set('disabled',disabled); 81 }); 82 }, 83 _setReadOnlyChildren: function(readOnly) { 84 array.forEach(this._getDescendantFormWidgets(),function(widget){ 85 widget.set('readOnly',readOnly); 86 }); 87 }, 74 88 validate: function() { 75 return !this._editing|| this.innerWidget.validate();89 return this._editing === false || this.innerWidget.validate(); 76 90 }, 77 91 focus: function() { 78 if ( this._editing ) {92 if ( this._editing === true ) { 79 93 this.innerWidget.focus(); 80 94 } 81 95 }, 82 96 showView: function() { 83 if ( this._editing ) {97 if ( this._editing === true ) { 84 98 if (!this.innerWidget.validate || this.innerWidget.validate() ) { 85 99 this.value = this.innerWidget.get('value'); … … 89 103 }, 90 104 showEdit: function() { 91 if ( !this._editing) {105 if ( this._editing === false ) { 92 106 this._showEditWidget(); 93 107 } 94 108 }, 95 109 onToggleEdit: function(evt) { 96 if ( this._editing) {110 if ( this._editing === true ) { 97 111 this.showView(); 98 112 } else { … … 106 120 // on it,but we don't know the actual code here. 107 121 var newWidget = this._factory.createViewWidget( lang.mixin({code:""},this.value) ); 108 if ( newWidget !== null) {122 if ( newWidget ) { 109 123 this._destroyInnerWidget(); 110 124 this.innerWidget = newWidget; 111 this.innerWidget.set('readOnly',true);112 125 this.addChild(this.innerWidget); 126 this._setReadOnlyChildren(true); 127 this._setDisabledChildren(true); 113 128 this.titleNode.innerHTML = this.value.type+" [preview]"; 114 129 domClass.replace(this.editButton.iconNode, "rftIconEdit", "rftIconAccept"); … … 119 134 _showEditWidget: function() { 120 135 var newWidget = this._factory.createEditWidget( this.value ); 121 if ( newWidget !== null) {136 if ( newWidget ) { 122 137 this._destroyInnerWidget(); 123 138 this.innerWidget = newWidget; 124 this.innerWidget.set('readOnly',this.readOnly);125 this.innerWidget.set('disabled',this.disabled);126 139 this.addChild(this.innerWidget); 140 this._setReadOnlyChildren(this.readOnly); 141 this._setDisabledChildren(this.disabled); 127 142 this.titleNode.innerHTML = this.value.type+" [editing]"; 128 143 domClass.replace(this.editButton.iconNode, "rftIconAccept", "rftIconEdit"); -
Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorToolkit.js
r502 r510 34 34 { type: "NumberInput" }, 35 35 { type: "ScaleInput" }, 36 { type: "SingleChoiceInput" }, 36 37 { type: "MultipleChoiceInput" } 37 38 ], … … 44 45 "NumberInput": "Number", 45 46 "ScaleInput": "Scale", 47 "SingleChoiceInput": "Single choice", 46 48 "MultipleChoiceInput": "Multiple choice" 47 49 }, … … 54 56 "NumberInput": "Number", 55 57 "ScaleInput": "Scale", 58 "SingleChoiceInput": "MultipleChoice", 56 59 "MultipleChoiceInput": "MultipleChoice" 57 60 }, -
Dev/trunk/src/client/qed-client/model/widgets/questions/Factory.js
r443 r510 1 1 define([ 2 "../../../lib/object", 2 3 "./HeaderConfigWidget", 3 4 "./HeaderWidget", … … 8 9 "./ScaleInputConfigWidget", 9 10 "./ScaleInputWidget", 11 "./SingleChoiceInputConfigWidget", 12 "./SingleChoiceInputWidget", 10 13 "./StringInputConfigWidget", 11 14 "./StringInputWidget", … … 16 19 "dijit/_WidgetBase", 17 20 "dojo/_base/declare" 18 ], function(HeaderConfigWidget, HeaderWidget, MultipleChoiceInputConfigWidget, MultipleChoiceInputWidget, NumberInputConfigWidget, NumberInputWidget, ScaleInputConfigWidget, ScaleInputWidget, StringInputConfigWidget, StringInputWidget, TextConfigWidget, TextInputConfigWidget, TextInputWidget, TextWidget, _WidgetBase, declare) { 21 ], function(objectFuns, HeaderConfigWidget, HeaderWidget, MultipleChoiceInputConfigWidget, MultipleChoiceInputWidget, NumberInputConfigWidget, NumberInputWidget, ScaleInputConfigWidget, ScaleInputWidget, SingleChoiceInputConfigWidget, SingleChoiceInputWidget, StringInputConfigWidget, StringInputWidget, TextConfigWidget, TextInputConfigWidget, TextInputWidget, TextWidget, _WidgetBase, declare) { 22 23 var DividerWidget = declare([_WidgetBase], { 24 postCreate: function() { 25 this.domNode.innerHTML = "<hr>"; 26 } 27 }); 28 29 var viewMap = { 30 Header: HeaderWidget, 31 Text: TextWidget, 32 Divider: DividerWidget, 33 StringInput: StringInputWidget, 34 TextInput: TextInputWidget, 35 NumberInput: NumberInputWidget, 36 MultipleChoiceInput: MultipleChoiceInputWidget, 37 SingleChoiceInput: SingleChoiceInputWidget, 38 ScaleInput: ScaleInputWidget 39 }; 40 var editMap = { 41 Header: HeaderConfigWidget, 42 Text: TextConfigWidget, 43 StringInput: StringInputConfigWidget, 44 TextInput: TextInputConfigWidget, 45 NumberInput: NumberInputConfigWidget, 46 MultipleChoiceInput: MultipleChoiceInputConfigWidget, 47 SingleChoiceInput: SingleChoiceInputConfigWidget, 48 ScaleInput: ScaleInputConfigWidget 49 }; 50 51 editMap = objectFuns.map(editMap,function(Ctor,type){ 52 return declare([Ctor],{ 53 _getValueAttr: function() { 54 var value = this.inherited(arguments); 55 value.type = type; 56 return value; 57 } 58 }); 59 }); 60 19 61 var factory = declare(null, { 20 62 createViewWidget: function(/*Object*/options) { … … 22 64 // type: "Header", "Text", "TextInput", etc. 23 65 // other type specific fields 24 var fun = this['create'+options.type+'ViewWidget'];25 var view = fun !== undefined ? fun(options) :null;66 var Ctor = viewMap[options.type]; 67 var view = Ctor && new Ctor(options) || null; 26 68 return view; 27 69 }, 28 70 createEditWidget: function(/*Object*/options) { 29 var fun = this['create'+options.type+'EditWidget']; 30 var view = fun !== undefined ? fun(options) : null; 31 return view; 32 }, 33 34 createHeaderViewWidget: function(config) { 35 return new HeaderWidget(config); 36 }, 37 createHeaderEditWidget: function(config) { 38 return new HeaderConfigWidget({ 39 value: config 71 var Ctor = editMap[options.type]; 72 var edit = Ctor && new Ctor({ 73 value: options 40 74 }); 41 }, 42 43 createTextViewWidget: function(config) { 44 return new TextWidget(config); 45 }, 46 createTextEditWidget: function(config) { 47 return new TextConfigWidget({ 48 value: config 49 }); 50 }, 51 52 createDividerViewWidget: function(options) { 53 return new DividerView({ 54 options: options 55 }); 56 }, 57 58 createStringInputViewWidget: function(config) { 59 return new StringInputWidget(config); 60 }, 61 createStringInputEditWidget: function(config) { 62 return new StringInputConfigWidget({ 63 value: config 64 }); 65 }, 66 67 createTextInputViewWidget: function(config) { 68 return new TextInputWidget(config); 69 }, 70 createTextInputEditWidget: function(config) { 71 return new TextInputConfigWidget({ 72 value: config 73 }); 74 }, 75 76 createNumberInputViewWidget: function(config) { 77 return new NumberInputWidget(config); 78 }, 79 createNumberInputEditWidget: function(config) { 80 return new NumberInputConfigWidget({ 81 value: config 82 }); 83 }, 84 85 createMultipleChoiceInputViewWidget: function(config) { 86 return new MultipleChoiceInputWidget(config); 87 }, 88 createMultipleChoiceInputEditWidget: function(config) { 89 return new MultipleChoiceInputConfigWidget({ 90 value: config 91 }); 92 }, 93 94 createScaleInputViewWidget: function(options) { 95 return new ScaleInputWidget(options); 96 }, 97 createScaleInputEditWidget: function(options) { 98 return new ScaleInputConfigWidget({ 99 value: options || {} 100 }); 101 } 102 }); 103 104 var DividerView = declare([_WidgetBase], { 105 postCreate: function() { 106 this.domNode.innerHTML = "<hr>"; 75 return edit || null; 107 76 } 108 77 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputConfigWidget.js
r506 r510 19 19 20 20 return declare([_ComplexValueWidget],{ 21 type: 'MultipleChoiceInput',22 21 baseClass: 'qedMultipleChoiceWidget', 23 22 templateString: template, … … 51 50 }); 52 51 }, 53 _getValueAttr: function() {54 var value = this.inherited(arguments);55 value.type = this.type;56 value.allowMultiple = value.allowMultiple.length > 0;57 return value;58 },59 _setValueAttr: function(value) {60 value.allowMultiple = value.allowMultiple ? ["on"] : [];61 return this.inherited(arguments);62 },63 52 onAddItem: function(evt) { 64 53 this.itemsWidget.appendItem({},true); -
Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputWidget.js
r508 r510 5 5 "dijit/_WidgetsInTemplateMixin", 6 6 "dijit/form/CheckBox", 7 "dijit/form/RadioButton",8 7 "dojo/_base/array", 9 8 "dojo/_base/declare", 10 9 "dojo/dom-construct", 11 10 "dojo/text!./templates/MultipleChoiceInputWidget.html" 12 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, CheckBox, RadioButton,array, declare, domConstruct, template) {11 ], function(_Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, CheckBox, array, declare, domConstruct, template) { 13 12 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 14 13 templateString: template, … … 18 17 19 18 domConstruct.empty(this.domNode); 20 var Ctor = this.allowMultiple === true ? CheckBox : RadioButton;21 19 array.forEach(this.items, function(item){ 22 20 var div = domConstruct.create("div", { 23 21 }, this.domNode, "last"); 24 var input = new C tor({25 name: this.code + (this.allowMultiple === true ? item.subcode : ''),26 value: this.allowMultiple === true ? null : item.subcode22 var input = new CheckBox({ 23 name: this.code + item.subcode, 24 value: 1 27 25 }).placeAt(div); 28 26 var label = domConstruct.create("label",{ -
Dev/trunk/src/client/qed-client/model/widgets/questions/NumberInputConfigWidget.js
r506 r510 5 5 ], function(_ComplexValueWidget, declare, template) { 6 6 return declare([_ComplexValueWidget],{ 7 type: 'NumberInput', 8 templateString: template, 9 _getValueAttr: function() { 10 var value = this.inherited(arguments); 11 value.type = this.type; 12 return value; 13 } 7 baseClass: 'qedNumberInputConfig', 8 templateString: template 14 9 }); 15 10 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/NumberInputWidget.js
r508 r510 10 10 templateString: template, 11 11 text: '', 12 subcode: '', 12 13 startup: function() { 13 14 if ( this._started ) { return; } -
Dev/trunk/src/client/qed-client/model/widgets/questions/ScaleInputConfigWidget.js
r490 r510 79 79 return false; 80 80 }, 81 _getValueAttr: function(){82 var value = this.inherited(arguments);83 value.type = 'ScaleInput';84 return value;85 },86 81 onNAChange: function(value) { 87 82 this._hasNA = value !== null && value !== ""; -
Dev/trunk/src/client/qed-client/model/widgets/questions/StringInputConfigWidget.js
r443 r510 5 5 ], function(_ComplexValueWidget, declare, template) { 6 6 return declare([_ComplexValueWidget],{ 7 type: 'StringInput', 8 templateString: template, 9 _getValueAttr: function() { 10 var value = this.inherited(arguments); 11 value.type = this.type; 12 return value; 13 } 7 baseClass: 'qedStringInputConfig', 8 templateString: template 14 9 }); 15 10 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/StringInputWidget.js
r508 r510 9 9 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 10 10 templateString: template, 11 text: '' 11 text: '', 12 subcode: '' 12 13 }); 13 14 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/TextConfigWidget.js
r443 r510 5 5 ], function(_ComplexValueWidget, declare, template) { 6 6 return declare([_ComplexValueWidget],{ 7 type: 'Text', 8 templateString: template, 9 _getValueAttr: function() { 10 var value = this.inherited(arguments); 11 value.type = this.type; 12 return value; 13 } 7 templateString: template 14 8 }); 15 9 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/TextInputConfigWidget.js
r506 r510 5 5 ], function(_ComplexValueWidget, declare, template) { 6 6 return declare([_ComplexValueWidget],{ 7 type: 'TextInput', 8 templateString: template, 9 _getValueAttr: function() { 10 var value = this.inherited(arguments); 11 value.type = this.type; 12 return value; 13 } 7 baseClass: 'qedTextInputConfig', 8 templateString: template 14 9 }); 15 10 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/TextInputWidget.js
r508 r510 10 10 templateString: template, 11 11 text: '', 12 subcode: '', 12 13 startup: function() { 13 14 if ( this._started ) { return; } -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/MultipleChoiceInputConfigRowWidget.html
r506 r510 1 1 <form> 2 <div data-dojo-type="dijit/form/ValidationTextBox" 3 data-dojo-props="required: true, placeholder: 'Subcode'" 2 <div data-dojo-type="dijit/form/CheckBox" 3 data-dojo-props="disabled: true, readOnly: true"></div> 4 <div data-dojo-type="dijit/form/ValidationTextBox" 5 data-dojo-props="required: true, placeholder: 'Subcode'" 4 6 class="subcode" 5 7 name="subcode"></div> 6 8 <div data-dojo-type="dijit/form/ValidationTextBox" 7 9 data-dojo-props="required: true, placeholder: 'Item text'" -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/MultipleChoiceInputConfigWidget.html
r506 r510 1 1 <form class="${baseClass}"> 2 <div>3 <label class="qedLabel" for="allowMultiple">Allow multiple</label>4 <div name="allowMultiple" data-dojo-type="dijit/form/CheckBox"></div>5 </div>6 2 <div data-dojo-attach-point="itemsNode"> 7 3 </div> -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/NumberInputConfigWidget.html
r506 r510 1 <form >1 <form class="${baseClass}"> 2 2 <div> 3 3 <label class="qedLabel" for="text">Subcode</label> 4 <div class="qedField "4 <div class="qedField subcode" 5 5 data-dojo-attach-point="subcodeBox" 6 6 data-dojo-type="dijit/form/ValidationTextBox" -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/StringInputConfigWidget.html
r506 r510 1 <form >1 <form class="${baseClass}"> 2 2 <div> 3 <label class="qedLabel" for=" text">Subcode</label>4 <div class="qedField "3 <label class="qedLabel" for="subcode">Subcode</label> 4 <div class="qedField subcode" 5 5 data-dojo-attach-point="subcodeBox" 6 6 data-dojo-type="dijit/form/ValidationTextBox" -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/TextConfigWidget.html
r461 r510 1 1 <form> 2 2 <label for="text" class="qedLabel">Text</label> 3 <textarea class="qedField" data-dojo-type="dijit/form/Textarea" name="text"></textarea> 3 <textarea class="qedField" 4 data-dojo-type="dijit/form/Textarea" 5 data-dojo-props="required: true" 6 name="text"></textarea> 4 7 </form> -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/TextInputConfigWidget.html
r506 r510 1 <form >1 <form class="${baseClass}"> 2 2 <div> 3 3 <label class="qedLabel" for="text">Subcode</label> 4 <div class="qedField "4 <div class="qedField subcode" 5 5 data-dojo-attach-point="subcodeBox" 6 6 data-dojo-type="dijit/form/ValidationTextBox" -
Dev/trunk/src/client/qed-client/widgets/LineWithActionsWidget.js
r494 r510 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 ],function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){ 1 define([ 2 "../lib/object", 3 "dijit/_TemplatedMixin", 4 "dijit/_WidgetBase", 5 "dijit/_WidgetsInTemplateMixin", 6 "dijit/form/Button", 7 "dojo/_base/declare", 8 "dojo/_base/event", 9 "dojo/_base/lang", 10 "dojo/dom", 11 "dojo/dom-class", 12 "dojo/on", 13 "dojo/text!./templates/LineWithActionsWidget.html" 14 ], function(objectFuns, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button, declare, event, lang, dom, domClass, on, templateString) { 13 15 return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{ 14 16 templateString: templateString, … … 33 35 return; 34 36 } 35 for (var action in this.actions) { 36 if ( this.actions.hasOwnProperty(action) ) { 37 var properties; 38 if (this.actions[action].properties.blockButton === true) { 39 properties = lang.mixin({ 40 baseClass: 'rftBlockButton', 41 label: "Default", 42 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, 43 title: this.actions[action].properties.tooltip, 44 onClick: lang.hitch(this, function(action, e){ 45 if ( action.callback ) { action.callback(e); } 46 if ( e ) { event.stop(e); } 47 return false; 48 }, this.actions[action]) 49 }, this.actions[action].properties); 50 new Button(properties).placeAt(this.buttonsNode); 51 } else { 52 properties = lang.mixin({ 53 baseClass: 'rftInlineButton', 54 label: "Default", 55 showLabel: false, 56 iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon, 57 title: this.actions[action].properties.tooltip, 58 onClick: lang.hitch(this, function(action, e){ 59 if ( action.callback ) { action.callback(e); } 60 if ( e ) { event.stop(e); } 61 return false; 62 }, this.actions[action]) 63 }, this.actions[action].properties); 64 new Button(properties).placeAt(this.buttonsNode); 65 } 37 objectFuns.forEach(this.actions, function(value,action){ 38 var properties; 39 if (value.properties.blockButton === true) { 40 properties = lang.mixin({ 41 baseClass: 'rftBlockButton', 42 label: "Default", 43 iconClass: 'rftIcon rftIcon'+value.properties.icon, 44 title: value.properties.tooltip, 45 onClick: lang.hitch(this, function(action, e){ 46 if ( action.callback ) { action.callback(e); } 47 if ( e ) { event.stop(e); } 48 return false; 49 }, value) 50 }, value.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'+value.properties.icon, 58 title: value.properties.tooltip, 59 onClick: lang.hitch(this, function(action, e){ 60 if ( action.callback ) { action.callback(e); } 61 if ( e ) { event.stop(e); } 62 return false; 63 }, value) 64 }, value.properties); 65 new Button(properties).placeAt(this.buttonsNode); 66 66 } 67 } 67 },this); 68 68 }, 69 69 refresh: function() { -
Dev/trunk/src/client/qed-client/widgets/ObjectBox.js
r472 r510 1 1 define([ 2 'dojo/_base/declare', 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 './LineWithActionsWidget', 8 'dojo/text!./templates/ObjectBox.html' 9 ], function(declare, lang, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, LineWithActionsWidget, template){ 2 "../lib/object", 3 "./LineWithActionsWidget", 4 "dijit/_TemplatedMixin", 5 "dijit/_WidgetBase", 6 "dijit/_WidgetsInTemplateMixin", 7 "dojo/_base/declare", 8 "dojo/_base/lang", 9 "dojo/text!./templates/ObjectBox.html" 10 ], function(objectFuns, LineWithActionsWidget, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, lang, template) { 10 11 return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], { 11 12 baseClass: "rftObjectBox", … … 39 40 }, 40 41 _createLine3Actions: function() { 41 var line3Actions = {}; 42 for (var action in this.actions) { 43 if ( this.actions.hasOwnProperty(action) ) { 44 line3Actions[action] = { 45 callback: lang.hitch(this, function(callback){ 46 if ( this.value ) { callback(this.value); } 47 }, this.actions[action]), 48 properties: { 49 blockButton: true, 50 label: action, 51 icon: action.charAt(0).toUpperCase()+action.slice(1) 52 } 53 }; 54 } 55 } 56 return line3Actions; 42 return objectFuns.map(this.actions,function(value,name){ 43 return { 44 callback: lang.hitch(this, function(callback){ 45 if ( this.value ) { callback(this.value); } 46 }, value), 47 properties: { 48 blockButton: true, 49 label: name, 50 icon: name.charAt(0).toUpperCase()+name.slice(1) 51 } 52 }; 53 },this); 57 54 }, 58 55 _showInfoBox: function() {}, -
Dev/trunk/src/client/qed-client/widgets/Selector.js
r495 r510 1 1 define([ 2 "../lib/object", 2 3 "./LineWithActionsWidget", 3 4 "dijit/_Container", … … 16 17 "dojo/query", 17 18 "dojo/text!./templates/Selector.html" 18 ], function( LineWithActionsWidget, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, registry, baseArray, declare, event, lang, Source, domClass, domConstruct, fx, query, templateString) {19 ], function(objectFuns, LineWithActionsWidget, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, registry, baseArray, declare, event, lang, Source, domClass, domConstruct, fx, query, templateString) { 19 20 20 21 function get(selector, item) { … … 62 63 }, 63 64 _createTitleLine: function() { 64 var actions = {};65 var action = null;66 65 var userActions = 67 66 lang.isFunction(this.selectedActions) ? 68 67 this.selectedActions() : 69 68 this.selectedActions; 70 if ( userActions ) { 71 for (var actionName in userActions) { 72 if ( userActions.hasOwnProperty(actionName) ) { 73 action = userActions[actionName]; 74 actions[actionName] = { 75 callback: action.callback && 76 lang.hitch(this,this._onSelectedAction, 77 action.callback), 78 properties: { 79 blockButton: true, 80 label: action.title || actionName, 81 icon: action.icon, 82 tooltip: action.description 83 } 84 85 }; 86 } 87 } 88 } 89 69 70 var actions = objectFuns.map(userActions||{},function(action,actionName){ 71 return { 72 callback: action.callback && 73 lang.hitch(this,this._onSelectedAction, 74 action.callback), 75 properties: { 76 blockButton: true, 77 label: action.title || actionName, 78 icon: action.icon, 79 tooltip: action.description 80 } 81 82 }; 83 }, this); 90 84 this._titleLine = new LineWithActionsWidget({ 91 85 title: this.title, … … 205 199 }, 206 200 _createLineNode: function(item) { 207 var actions = {};208 201 var userActions = 209 202 lang.isFunction(this.itemActions) ? 210 203 this.itemActions(item) : 211 204 this.itemActions; 212 if (userActions) { 213 for (var actionName in userActions) { 214 if ( userActions.hasOwnProperty(actionName) ) { 215 var action = userActions[actionName]; 216 actions[actionName] = { 217 callback: action.callback && 218 lang.partial(action.callback,item,this), 219 properties: { 220 blockButton: false, 221 showLabel: false, 222 icon: action.icon + " black", 223 tooltip: action.description 224 } 225 }; 226 } 227 } 228 } 205 var actions = objectFuns.map(userActions||{},function(action,actionName){ 206 return { 207 callback: action.callback && 208 lang.partial(action.callback,item,this), 209 properties: { 210 blockButton: false, 211 showLabel: false, 212 icon: action.icon + " black", 213 tooltip: action.description 214 } 215 }; 216 }, this); 229 217 var w = new LineWithActionsWidget({ 230 218 title: get(this.itemTitle,item), -
Dev/trunk/src/client/qed-client/widgets/TabbedBrowser.js
r495 r510 1 1 define([ 2 "../lib/object", 2 3 "./Selector", 3 4 "dijit/layout/ContentPane", … … 9 10 "dojo/when", 10 11 "dojox/widget/Standby" 11 ], function( Selector, ContentPane, TabContainer, array, declare, lang, win, when, Standby) {12 ], function(objectFuns, Selector, ContentPane, TabContainer, array, declare, lang, win, when, Standby) { 12 13 return declare([TabContainer],{ 13 14 tabPosition: 'left-h', … … 121 122 removeItem: function(item) { 122 123 var cmap = this._dataMap; 123 for ( var cat in cmap ) { 124 if ( cmap.hasOwnProperty(cat) ) { 125 var tmap = cmap[cat]; 126 for ( var top in tmap ) { 127 if ( tmap.hasOwnProperty(top) ) { 128 var widget = tmap[top]._widget; 129 if ( widget ) { widget.removeItem(item); } 130 } 131 } 132 } 133 } 124 objectFuns.forEach(cmap,function(tmap,cat){ 125 objectFuns.forEach(tmap,function(topObj,top){ 126 var widget = topObj._widget; 127 if ( widget ) { widget.removeItem(item); } 128 },this); 129 },this); 134 130 }, 135 131 _busy: function() { -
Dev/trunk/src/server/config/couchdb-schema.json
r509 r510 114 114 { "$ref": "#/definitions/content/NumberInput" }, 115 115 { "$ref": "#/definitions/content/ScaleInput" }, 116 { "$ref": "#/definitions/content/SingleChoiceInput" }, 116 117 { "$ref": "#/definitions/content/MultipleChoiceInput" } 117 118 ] … … 200 201 "additionalProperties": false 201 202 }, 203 "SingleChoiceInput": { 204 "type": "object", 205 "properties": { 206 "type": { "type": "string", "pattern": "^SingleChoiceInput$" }, 207 "items": { "type": "array", "items": { 208 "type": "object", 209 "properties": { 210 "text": { "$ref": "#/definitions/nonEmptyString" }, 211 "value": { "$ref": "#/definitions/nonEmptyString" } 212 }, 213 "required": ["text","value"], 214 "additionalProperties": false 215 } }, 216 "otherItem": { 217 "type": "object", 218 "properties": { 219 "text": { "$ref": "#/definitions/nonEmptyString" }, 220 "value": { "$ref": "#/definitions/nonEmptyString" } 221 }, 222 "required": ["subcode","value"], 223 "additionalProperties": false 224 }, 225 "subcode": { "$ref": "#/definitions/codeString" } 226 }, 227 "required":["type","items","subcode"], 228 "additionalProperties": false 229 }, 202 230 "MultipleChoiceInput": { 203 231 "type": "object", 204 232 "properties": { 205 233 "type": { "type": "string", "pattern": "^MultipleChoiceInput$" }, 206 "allowMultiple": { "type": "boolean" },207 234 "items": { "type": "array", "items": { 208 235 "type": "object",
Note: See TracChangeset
for help on using the changeset viewer.