- Timestamp:
- 03/09/14 14:23:42 (11 years ago)
- Location:
- Dev/trunk/src
- Files:
-
- 1 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/app/Notifications.js
r443 r492 3 3 return declare([Toaster],{ 4 4 positionDirection: "br-up", 5 duration: 30005 duration: 7000 6 6 }); 7 7 }); -
Dev/trunk/src/client/qed-client/app/Page.js
r491 r492 16 16 notify: lang.hitch(Content,'notify'), 17 17 markDirty: lang.hitch(Content,'markDirty'), 18 markClean: lang.hitch(Content,'markClean') 18 markClean: lang.hitch(Content,'markClean'), 19 isDirty: lang.hitch(Content,'isDirty') 19 20 }); 20 21 return Page; -
Dev/trunk/src/client/qed-client/css/variables.less
r443 r492 6 6 @headers: #999999; 7 7 @text: #ffffff; 8 @disabledtext: #777777; 8 9 9 10 // Colours -
Dev/trunk/src/client/qed-client/css/widgets/BlockButton.less
r443 r492 5 5 height: @button_block_height; 6 6 vertical-align: top; 7 color: @text; 8 9 &.dijitDisabled { 10 color: @disabledtext; 11 } 7 12 8 13 .dijitButtonContents { … … 18 23 padding: 0 @std_offset; 19 24 border: none; 20 color: @text;21 25 font-size: @button_block_font_size; 22 26 -
Dev/trunk/src/client/qed-client/css/widgets/InlineButton.less
r443 r492 3 3 height: @button_inline_height; 4 4 width: @button_inline_height; 5 color: @text; 6 7 &.dijitDisabled { 8 color: @disabledtext; 9 } 5 10 6 11 .dijitButtonNode { -
Dev/trunk/src/client/qed-client/css/widgets/LargeButton.less
r443 r492 7 7 height: @button_large_height; 8 8 padding: 3px; 9 color: @text; 9 10 10 11 &*, * { … … 15 16 } 16 17 18 &.dijitDisabled { 19 color: @disabledtext; 20 } 21 17 22 .dijitButtonNode { 18 23 … … 21 26 height: @button_large_height; 22 27 background: transparent; 23 color: @headers;24 28 font-size: @button_large_font_size; 25 29 .transition(0.3s); -
Dev/trunk/src/client/qed-client/model/classes/_Class.js
r490 r492 2 2 "./_View", 3 3 "dojo/_base/declare", 4 "dojo/_base/lang" 5 ], function(_View, declare, lang) { 4 "dojo/_base/lang", 5 "dojo/date/stamp" 6 ], function(_View, declare, lang, stamp) { 6 7 7 8 var _Class = declare([_View],{ … … 56 57 idOrObj : 57 58 this.getId(idOrObj)); 59 }, 60 _formatDate: function(date) { 61 return stamp.toISOString(date,{zulu:true,milliseconds:false}); 58 62 } 59 63 }); -
Dev/trunk/src/client/qed-client/model/classes/_View.js
r490 r492 5 5 "dojo/_base/json", 6 6 "dojo/_base/lang", 7 "dojo/date/stamp", 7 8 "dojo/store/util/QueryResults" 8 ], function(JsonRest, Deferred, declare, json, lang, queryResults) {9 ], function(JsonRest, Deferred, declare, json, lang, stamp, queryResults) { 9 10 10 11 var _View = declare([],{ … … 38 39 getCollectionPath: function() { 39 40 return '/'+this._collection; 41 }, 42 _parseDate: function(str) { 43 return stamp.fromISOString(str); 40 44 } 41 45 }); -
Dev/trunk/src/client/qed-client/model/classes/questions.js
r487 r492 1 1 define([ 2 2 "./_Class", 3 "dojo/_base/declare", 4 "dojo/date/stamp" 5 ], function(_Class, declare, stamp) { 3 "dojo/_base/declare" 4 ], function(_Class, declare) { 6 5 7 6 var Questions = declare([_Class],{ … … 20 19 _deserialize: function(obj) { 21 20 if (obj.publicationDate) { 22 obj.publicationDate = stamp.fromISOString(obj.publicationDate);21 obj.publicationDate = this._parseDate(obj.publicationDate); 23 22 } 24 23 }, 25 24 _serialize: function(obj) { 26 25 if (obj.publicationDate) { 27 obj.publicationDate = stamp.toISOString(obj.publicationDate);26 obj.publicationDate = this._formatDate(obj.publicationDate); 28 27 } 29 28 } -
Dev/trunk/src/client/qed-client/model/classes/responses.js
r490 r492 6 6 "dojo/_base/json", 7 7 "dojo/_base/lang", 8 "dojo/_base/xhr", 9 "dojo/date/stamp" 10 ], function(_Class, surveyRuns, Deferred, declare, json, lang, xhr, stamp) { 8 "dojo/_base/xhr" 9 ], function(_Class, surveyRuns, Deferred, declare, json, lang, xhr) { 11 10 12 11 var Responses = declare([_Class],{ … … 26 25 } 27 26 if (obj.publicationDate) { 28 obj.publicationDate = stamp.fromISOString(obj.publicationDate);27 obj.publicationDate = this._parseDate(obj.publicationDate); 29 28 } 30 29 }, … … 34 33 } 35 34 if (obj.publicationDate) { 36 obj.publicationDate = stamp.toISOString(obj.publicationDate);35 obj.publicationDate = this._formatDate(obj.publicationDate); 37 36 } 38 37 }, -
Dev/trunk/src/client/qed-client/model/classes/surveyRuns.js
r487 r492 2 2 "./_Class", 3 3 "./surveys", 4 "dojo/_base/declare", 5 "dojo/date/stamp" 6 ], function(_Class, surveys, declare, stamp) { 4 "dojo/_base/declare" 5 ], function(_Class, surveys, declare) { 7 6 8 7 var SurveyRuns = declare([_Class],{ … … 21 20 _deserialize: function(obj) { 22 21 if (obj.endDate) { 23 obj.endDate = stamp.fromISOString(obj.endDate);22 obj.endDate = this._parseDate(obj.endDate); 24 23 } 25 24 if (obj.startDate) { 26 obj.startDate = stamp.fromISOString(obj.startDate);25 obj.startDate = this._parseDate(obj.startDate); 27 26 } 28 27 if (obj.survey) { … … 32 31 _serialize: function(obj) { 33 32 if (obj.endDate) { 34 obj.endDate = stamp.toISOString(obj.endDate);33 obj.endDate = this._formatDate(obj.endDate); 35 34 } 36 35 if (obj.startDate) { 37 obj.startDate = stamp.toISOString(obj.startDate);36 obj.startDate = this._formatDate(obj.startDate); 38 37 } 39 38 if (obj.survey) { -
Dev/trunk/src/client/qed-client/model/classes/surveys.js
r490 r492 1 1 define([ 2 2 "./_Class", 3 "./questions", 4 "dojo/_base/array", 3 5 "dojo/_base/declare", 4 "dojo/date/stamp", 5 "dojo/store/JsonRest" 6 ], function(_Class, declare, stamp, JsonRest) { 6 "dojo/_base/lang" 7 ], function(_Class, questions, array, declare, lang) { 7 8 8 9 var Surveys = declare([_Class],{ … … 18 19 }, 19 20 _deserialize: function(obj) { 21 obj.questions = array.map(obj.questions, 22 lang.hitch(questions,'_doDeserialize')); 20 23 if (obj.publicationDate) { 21 obj.publicationDate = stamp.fromISOString(obj.publicationDate);24 obj.publicationDate = this._parseDate(obj.publicationDate); 22 25 } 23 26 }, 24 27 _serialize: function(obj) { 28 obj.questions = array.map(obj.questions, 29 lang.hitch(questions,'_doSerialize')); 25 30 if (obj.publicationDate) { 26 obj.publicationDate = stamp.toISOString(obj.publicationDate);31 obj.publicationDate = this._formatDate(obj.publicationDate); 27 32 } 28 33 }, -
Dev/trunk/src/client/qed-client/model/widgets/SurveyRunWidget.js
r457 r492 12 12 endDateBox.constraints.min = value; 13 13 }); 14 }, 15 _getValueAttr: function() { 16 var value = this.inherited(arguments); 17 if ( !value.startDate ) { delete value.startDate; } 18 if ( !value.endDate ) { delete value.endDate; } 19 value.respondentCanDeleteOwnResponse = value.respondentCanDeleteOwnResponse[0] === true; 20 return value; 14 21 } 15 22 }); -
Dev/trunk/src/client/qed-client/model/widgets/questions/templates/TextInputWidget.html
r461 r492 1 1 <form> 2 2 <p>${text}</p> 3 < div class="qedField" data-dojo-attach-point="textArea" data-dojo-type="dijit/form/Textarea" name="text"></div>3 <textarea class="qedField" data-dojo-attach-point="textArea" data-dojo-type="dijit/form/Textarea" name="text"></textarea> 4 4 </form> -
Dev/trunk/src/client/qed-client/model/widgets/templates/QuestionWidget.html
r443 r492 7 7 <input data-dojo-type="dijit/form/TextBox" name="title" type="text" class="loginInput" /> 8 8 <label for="question" class="loginLabel">Description</label> 9 < input data-dojo-type="dijit/form/Textarea" name="description" type="text" class="loginInput"/>9 <textarea data-dojo-type="dijit/form/Textarea" name="description" type="text" class="loginInput"></textarea> 10 10 <label for="category" class="loginLabel">Category</label> 11 11 <input data-dojo-type="dijit/form/TextBox" name="category" type="text" class="loginInput" /> -
Dev/trunk/src/client/qed-client/model/widgets/templates/SurveyRunWidget.html
r461 r492 3 3 <div> 4 4 <label for="mode" class="qedLabel">Description</label> 5 <textarea name="description" class="qedField" data-dojo-type="dijit/form/Textarea"></textarea> 5 <textarea name="description" class="qedField" 6 data-dojo-type="dijit/form/Textarea"></textarea> 6 7 </div> 7 8 8 9 <div> 9 10 <label for="startDate" class="qedLabel">Start date</label> 10 <input type="text" name="startDate" class="qedField" data-dojo-type="dijit/form/DateTextBox" data-dojo-attach-point="startDateBox" /> 11 <input type="text" name="startDate" class="qedField" 12 data-dojo-type="dijit/form/DateTextBox" 13 data-dojo-attach-point="startDateBox" /> 11 14 </div> 12 15 13 16 <div> 14 17 <label for="endDate" class="qedLabel">End date</label> 15 <input type="text" name="endDate" class="qedField" data-dojo-type="dijit/form/DateTextBox" data-dojo-attach-point="endDateBox" /> 18 <input type="text" name="endDate" class="qedField" 19 data-dojo-type="dijit/form/DateTextBox" 20 data-dojo-attach-point="endDateBox" /> 21 </div> 22 23 <div> 24 <label for="endDate" class="qedLabel">Allow respondents to delete their unsubmitted response</label> 25 <input type="text" name="respondentCanDeleteOwnResponse" 26 class="qedField" 27 data-dojo-type="dijit/form/CheckBox" 28 data-dojo-props="'value':true" /> 16 29 </div> 17 30 -
Dev/trunk/src/client/qed-client/model/widgets/templates/SurveyWidget.html
r461 r492 3 3 <input data-dojo-type="dijit/form/TextBox" name="title"/><br/> 4 4 <label for="description">Description</label> 5 < input data-dojo-type="dijit/form/Textarea" name="description"/><br/>5 <textarea data-dojo-type="dijit/form/Textarea" name="description"></textarea><br/> 6 6 </form> -
Dev/trunk/src/client/qed-client/pages/_ObjectPage.js
r491 r492 11 11 classStore: null, 12 12 constructor: function() { 13 if ( !this.classStore ) { throw new Error("Subclasses must specify a classStore."); } 13 if ( !this.classStore ) { 14 throw new Error("Subclasses must specify a classStore."); 15 } 16 }, 17 startup: function() { 18 if ( this._started ) { return; } 19 this.inherited(arguments); 20 this.markClean(); 14 21 }, 15 22 _load: function() { -
Dev/trunk/src/client/qed-client/pages/question.js
r490 r492 29 29 }, 30 30 _handlePropertiesChange: function() { 31 if ( this.propertiesForm.validate() ) { 32 lang.mixin(this.object,this.propertiesForm.get('value')); 33 } 31 lang.mixin(this.object,this.propertiesForm.get('value')); 34 32 this.markDirty(); 33 this._refresh(); 35 34 }, 36 35 _handleContentChange: function() { 37 if ( this.contentList.validate() ) { 38 this.object.content = this.contentList.get('value'); 39 } 36 this.object.content = this.contentList.get('value'); 40 37 this.markDirty(); 38 this._refresh(); 41 39 }, 42 40 _save: function() { 43 if ( this.propertiesForm.validate() && this.contentList.validate() ) { 44 lang.mixin(this.object,this.propertiesForm.get('value')); 45 this.object.content = this.contentList.get('value'); 41 if ( this._isValid ) { 46 42 return this.inherited(arguments); 47 43 } else { … … 68 64 return false; 69 65 }, 66 markDirty: function() { 67 this._isValid = this.propertiesForm.validate() && 68 this.contentList.validate(); 69 this.saveBtn.set('disabled',!this._isValid); 70 this.saveAndCloseBtn.set('disabled',!this._isValid); 71 this.discardBtn.set('label','Discard & Close'); 72 this.inherited(arguments); 73 }, 74 markClean: function() { 75 this._isValid = true; 76 this.saveBtn.set('disabled',true); 77 this.saveAndCloseBtn.set('disabled',true); 78 this.discardBtn.set('label','Close'); 79 this.inherited(arguments); 80 }, 70 81 _ignore: function(evt) { 71 82 if ( evt ) { event.stop( evt ); } -
Dev/trunk/src/client/qed-client/pages/response.js
r490 r492 40 40 this.submitButton.set('disabled',false); 41 41 this.continueButton.set('disabled',false); 42 this.cancelButton.set('disabled',false); 42 var canDelete = (this.response && 43 this.response._surveyRun.respondentCanDeleteOwnResponse); 44 this.cancelButton.set('disabled',canDelete||false); 43 45 this.surveyWidget.set('disabled', false); 44 46 }, -
Dev/trunk/src/client/qed-client/pages/survey.js
r491 r492 23 23 this._setupQuestionBrowser(); 24 24 this._setupListView(); 25 this.questionList.on('change',lang.hitch(this,'_handleQuestionsChange')); 25 26 this._load(); 26 27 }, … … 58 59 _refresh: function() { 59 60 this.titleNode.innerHTML = this.object.title || "(set title in properties)"; 60 this.properties Dialog.set('value',{survey:this.object});61 this.propertiesForm.set('value',{survey:this.object}); 61 62 this.questionList.set('value', 62 63 this.object.questions); 63 64 }, 64 _save: function() {65 this.object.questions = this.questionList.get('value');66 return this.inherited(arguments);67 },68 65 _includeQuestion: function(question) { 69 66 this.questionList.appendItem(question); 67 }, 68 _handleQuestionsChange: function() { 69 this.object.questions = this.questionList.get('value'); 70 this.markDirty(); 71 this._refresh(); 70 72 }, 71 73 _onShowProperties: function(evt) { … … 76 78 _onPropertiesOk: function(evt) { 77 79 this.propertiesDialog.hide(); 78 lang.mixin(this.object, this.properties Dialog.get('value').survey);80 lang.mixin(this.object, this.propertiesForm.get('value').survey); 79 81 this.markDirty(); 80 82 this._refresh(); … … 84 86 _onPropertiesCancel: function(evt) { 85 87 this.propertiesDialog.hide(); 86 this.properties Dialog.set('value',{survey:this.object});88 this.propertiesForm.set('value',{survey:this.object}); 87 89 if ( evt ) { event.stop(evt); } 88 90 return false; … … 109 111 preview: true 110 112 }); 113 }, 114 markDirty: function() { 115 this.saveBtn.set('disabled',false); 116 this.saveAndCloseBtn.set('disabled',false); 117 this.discardBtn.set('label','Discard & Close'); 118 this.inherited(arguments); 119 }, 120 markClean: function() { 121 this.saveBtn.set('disabled',true); 122 this.saveAndCloseBtn.set('disabled',true); 123 this.discardBtn.set('label','Close'); 124 this.inherited(arguments); 111 125 } 112 126 }); -
Dev/trunk/src/client/qed-client/pages/surveyRun.js
r490 r492 74 74 }, 75 75 _onPropChange: function(e) { 76 if ( this.surveyRunWidget.validate() ) { 77 lang.mixin(this.object,this.surveyRunWidget.get('value')); 76 if ( this._updateObject() ) { 78 77 this._refreshURL(); 79 78 } … … 90 89 }, 91 90 _save: function() { 92 if ( this.surveyRunWidget.validate() ) { 93 lang.mixin(this.object,this.surveyRunWidget.get('value')); 91 if ( this._updateObject() ) { 94 92 return this.inherited(arguments); 95 93 } else { 96 94 return new Deferred.reject(); 97 95 } 96 }, 97 _updateObject: function() { 98 var valid = this.surveyRunWidget.validate(); 99 if ( valid ) { 100 lang.mixin(this.object,this.surveyRunWidget.get('value')); 101 } 102 return valid; 98 103 }, 99 104 _onSave: function(evt) { … … 115 120 if ( evt ) { event.stop(evt); } 116 121 return false; 122 }, 123 markDirty: function() { 124 this.saveBtn.set('disabled',false); 125 this.saveAndCloseBtn.set('disabled',false); 126 this.discardBtn.set('label','Discard & Close'); 127 this.inherited(arguments); 128 }, 129 markClean: function() { 130 this.saveBtn.set('disabled',true); 131 this.saveAndCloseBtn.set('disabled',true); 132 this.discardBtn.set('label','Close'); 133 this.inherited(arguments); 117 134 } 118 135 }); -
Dev/trunk/src/client/qed-client/pages/templates/question.html
r490 r492 18 18 <button data-dojo-type="dijit/form/Button" 19 19 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'" 20 data-dojo-attach-point="saveBtn" 20 21 data-dojo-attach-event="onClick:_onSave"> 21 22 Save</button> 22 23 <button data-dojo-type="dijit/form/Button" 23 24 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'" 25 data-dojo-attach-point="saveAndCloseBtn" 24 26 data-dojo-attach-event="onClick:_onSaveAndClose"> 25 27 Save & Close</button> 26 28 <button data-dojo-type="dijit/form/Button" 27 29 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'" 30 data-dojo-attach-point="discardBtn" 28 31 data-dojo-attach-event="onClick:_onDiscard"> 29 32 Discard & Close</button> -
Dev/trunk/src/client/qed-client/pages/templates/survey.html
r491 r492 23 23 <button data-dojo-type="dijit/form/Button" 24 24 data-dojo-attach-event="onClick:_onSave" 25 data-dojo-attach-point="saveBtn" 25 26 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'"> 26 27 Save</button> 27 28 <button data-dojo-type="dijit/form/Button" 28 29 data-dojo-attach-event="onClick:_onSaveAndClose" 30 data-dojo-attach-point="saveAndCloseBtn" 29 31 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'"> 30 32 Save & Close</button> 31 33 <button data-dojo-type="dijit/form/Button" 32 34 data-dojo-attach-event="onClick:_onDiscardAndClose" 35 data-dojo-attach-point="discardBtn" 33 36 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'"> 34 37 Discard & Close</button> … … 41 44 42 45 <div data-dojo-type="dijit/Dialog" 43 title="Survey properties" 44 data-dojo-attach-point="propertiesDialog" 45 data-dojo-attach-event="onSubmit:_onPropertiesOk"> 46 <fieldset class="qedFieldset"> 47 <div data-dojo-type="../model/widgets/SurveyWidget" data-dojo-props="name:'survey'"></div> 48 </fieldset> 49 <button data-dojo-type="dijit/form/Button" 50 type="submit" 51 data-dojo-attach-event="onClick:_onPropertiesOk"> 52 OK</button> 53 <button data-dojo-type="dijit/form/Button" 54 type="button" 55 data-dojo-attach-event="onClick:_onPropertiesCancel"> 56 Cancel</button> 46 data-dojo-props="'title':'Survey properties'" 47 data-dojo-attach-point="propertiesDialog"> 48 <form data-dojo-type="dijit/form/Form" 49 data-dojo-attach-point="propertiesForm" 50 data-dojo-attach-event="onSubmit:_onPropertiesOk"> 51 <fieldset class="qedFieldset"> 52 <div data-dojo-type="../model/widgets/SurveyWidget" data-dojo-props="name:'survey'"></div> 53 </fieldset> 54 <button data-dojo-type="dijit/form/Button" 55 type="submit" 56 data-dojo-attach-event="onClick:_onPropertiesOk"> 57 OK</button> 58 <button data-dojo-type="dijit/form/Button" 59 type="button" 60 data-dojo-attach-event="onClick:_onPropertiesCancel"> 61 Cancel</button> 62 </form> 57 63 </div> 58 64 -
Dev/trunk/src/client/qed-client/pages/templates/surveyRun.html
r490 r492 55 55 class="blue" 56 56 data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconSave'" 57 data-dojo-attach-point="saveBtn" 57 58 data-dojo-attach-event="onClick:_onSave">Save</button> 58 59 <button data-dojo-type="dijit/form/Button" 59 60 class="blue" 60 61 data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconSave'" 62 data-dojo-attach-point="saveAndCloseBtn" 61 63 data-dojo-attach-event="onClick:_onSaveAndClose">Save & Close</button> 62 64 <button data-dojo-type="dijit/form/Button" 63 65 class="blue" 64 66 data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconClose'" 67 data-dojo-attach-point="discardBtn" 65 68 data-dojo-attach-event="onClick:_onDiscard">Discard & Close</button> 66 69 </div> -
Dev/trunk/src/client/qed-client/ui/LoginDialogWrapper.coffee
r487 r492 9 9 "dojo/_base/lang", 10 10 "dojo/on", 11 "dojo/when", 11 12 "dojo/text!./templates/LoginDialogWrapper.html" 12 13 ], (session, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, 13 registry, declare, event, lang, _on, template) ->14 registry, declare, event, lang, _on, _when, template) -> 14 15 declare [_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin], 15 16 templateString: template 17 _fx: null 16 18 startup: () -> 17 19 if @_started then return … … 25 27 value.password 26 28 .then () => 27 @loginDialog.hide() 29 @_fx = _when(@_fx) 30 .then () => 31 @loginDialog.hide() 28 32 , () => 29 33 alert "Login failed!" … … 31 35 false 32 36 onUserChange: (user) -> 33 if user 34 @loginDialog.hide() 35 else 36 @loginDialog.show() 37 @_fx = _when(@_fx) 38 .then () => 39 if user 40 @loginDialog.hide() 41 else 42 @loginDialog.show() 37 43 null -
Dev/trunk/src/client/qed-client/ui/templates/LoginDialogWrapper.html
r468 r492 25 25 <div data-dojo-type="dijit/form/Button" 26 26 type="submit" 27 data-dojo-attach-event="on Login">Login</div>27 data-dojo-attach-event="onClick:onLogin">Login</div> 28 28 </form> 29 29 </div> -
Dev/trunk/src/client/qed-client/widgets/_ComplexValueMixin.coffee
r472 r492 2 2 "dijit/_Container", 3 3 "dijit/form/_FormMixin", 4 "dijit/registry", 4 5 "dojo/_base/array", 5 6 "dojo/_base/declare", 6 "dojo/_base/event" 7 ], (_Container, _FormMixin, array, declare, event) -> 7 "dojo/_base/event", 8 "dojo/on" 9 ], (_Container, _FormMixin, registry, array, declare, event, _on) -> 8 10 declare [_Container,_FormMixin], 9 11 name: "" … … 20 22 It is recommended to use <form> as the root 21 23 element in your template for", @declaredClass 24 @own ( _on @domNode, 'submit', (evt) => @_handleSubmit evt ) 22 25 23 26 _setDisabledAttr: (value) -> … … 35 38 children[0].focus() if children.length > 0 36 39 37 onSubmit: (e) => 38 # since this widget is used to create more complex 39 # widgets within other forms, the onSubmit must either be 40 # ignored or propagated, but not handled here. 41 event.stop e if e 40 _handleSubmit: (evt) -> 41 node = @domNode 42 until not node or ( widget and 43 typeof widget._onSubmit is "function" ) 44 node = node.parentNode 45 widget = registry.byNode node if node 46 widget._onSubmit(evt) if widget 47 # we always stop the event, since this is a widget after all 48 event.stop evt if evt 42 49 false 43 44 _onSubmit: (e) =>45 # since this widget is used to create more complex46 # widgets within other forms, the onSubmit must either be47 # ignored or propagated, but not handled here.48 event.stop e if e49 false -
Dev/trunk/src/server/app.js
r490 r492 8 8 , CouchDB = require('./util/couch').CouchDB 9 9 , _ = require("underscore") 10 , tv4 = require("tv4")10 , validator = require("./util/validator") 11 11 , HTTPResult = require("./util/http-result") 12 12 , etags = require("./util/etags") … … 151 151 return new HTTPResult(500,{error: error.reason}); 152 152 } 153 function handleUnknownError(error) {153 function handleUnknownError(error) { 154 154 return new HTTPResult(500, {error: "Unknown error", innerError: error}); 155 155 } … … 159 159 function handleRowDocs(result) { 160 160 return _.map(result.rows, function(item) { return item.doc; }); 161 } 162 function handleRowFirstDoc(result) { 163 if ( result.rows.length > 0 ) { 164 return result.rows[0].doc; 165 } else { 166 return new HTTPResult(404,{error:"No document found."}); 167 } 168 } 169 function handleRowFirstValue(result) { 170 if ( result.rows.length > 0 ) { 171 return result.rows[0].value; 172 } else { 173 return new HTTPResult(404,{error:"No document found."}); 174 } 175 } 176 function handleRowDictOfDocs(result) { 177 return _.reduce(result.rows, function(dict,item) { 178 dict[item.key] = item.doc; 179 return dict; 180 }, {}); 181 } 182 function handleRowDictOfValues(result) { 183 return _.reduce(result.rows, function(dict,item) { 184 dict[item.key] = item.value; 185 return dict; 186 }, {}); 161 187 } 162 188 … … 199 225 function putDocument(id,rev,type,doc) { 200 226 var priv = stripAndReturnPrivates(doc); 201 if ( doc.type === type && tv4.validateResult(doc, schema)) {227 if ( doc.type === type && validator(doc, schema).valid ) { 202 228 var opts = rev ? {headers:{'If-Match':'"'+rev+'"'}} : {}; 203 229 return HTTPResult.fromResponsePromise(couch.put(id,doc,opts).response, … … 236 262 function postDocument(type,doc) { 237 263 var priv = stripAndReturnPrivates(doc); 238 if ( doc.type === type && tv4.validateResult(doc, schema)) {264 if ( doc.type === type && validator(doc, schema).valid ) { 239 265 return HTTPResult.fromResponsePromise(couch.post(doc).response, 240 266 handleUnknownError) … … 321 347 .handle({ 322 348 200: handleRowDocs, 349 default: handleUnknownResponse 350 }); 351 } 352 function getQuestionsAndCodes() { 353 var url = '_design/questions/_view/by_code'; 354 var query = {include_docs:true}; 355 return HTTPResult.fromResponsePromise(couch.get(url,{query:query}).response, 356 handleUnknownError) 357 .handle({ 358 200: handleRowDictOfDocs, 323 359 default: handleUnknownResponse 324 360 }); … … 760 796 return new HTTPResult(403,{error: "Secrets are not the same."}); 761 797 } else { 762 return deleteDocument(id,rev,doc); 798 return getDocument(doc.surveyRunId,[],'SurveyRun') 799 .handle({ 800 200: function(surveyRun) { 801 if ( surveyRun.respondentCanDeleteOwnResponse === true ) { 802 return deleteDocument(id,rev,doc); 803 } else { 804 return new HTTPResult(403,{error:"Not allowed to delete response."}); 805 } 806 } 807 }); 763 808 } 764 809 } -
Dev/trunk/src/server/config/check-couchdb.js
r487 r492 1 1 var Q = require('q') 2 2 , _ = require('underscore') 3 , tv4 = require('tv4')3 , validator = require('../util/validator') 4 4 , CouchDB = require('../util/couch').CouchDB 5 5 ; … … 10 10 var server = new CouchDB(couchServerURL,dbName); 11 11 var designRe = /^_design\//; 12 13 var codes = {}; 14 function codeUnique(code) { 15 if ( code in codes ) { 16 return false; 17 } else { 18 codes[code] = true; 19 return true; 20 } 21 } 22 12 23 return server.get('/_all_docs') 13 24 .then(function(allDocs){ … … 20 31 return server.get(doc.id) 21 32 .then(function(doc){ 22 var valid = tv4.validateResult(doc,schema); 33 var valid = validator(doc,schema); 34 if ( doc.type === "Question" && !codeUnique(doc.code) ) { 35 valid.valid = false; 36 valid.error = "Question code "+doc.code+" is not unique."; 37 } 23 38 result[doc._id] = valid; 24 39 return result; -
Dev/trunk/src/server/config/couchdb-design-docs.js
r487 r492 125 125 }, 126 126 127 "qed/_design/surveyRuns": { 128 __configAction: "replace", 129 _id: "_design/surveys", 130 language: "javascript", 131 views: { 132 by_dates: { 133 map: function(doc){ 134 if ( doc.type !== 'SurveyRun' ) { return; } 135 var startDate = doc.startDate || ""; 136 var endDate = doc.endDate || {}; 137 emit([startDate,endDate,doc.liveName||null],doc); 138 } 139 } 140 } 141 }, 142 127 143 "qed/_design/responses": { 128 144 __configAction: "replace", -
Dev/trunk/src/server/config/couchdb-schema.json
r487 r492 36 36 "_rev": { "type": "string" }, 37 37 "categories": { "type": "array", "items": { "type": "string" } }, 38 "code": { "type": "string" },38 "code": { "type": "string", "minLength": 1 }, 39 39 "content": { "type": "array", "items": { "$ref": "#/definitions/content/any" } }, 40 40 "description": { "type": "string" }, … … 52 52 "_id": { "type": "string" }, 53 53 "_rev": { "type": "string" }, 54 "description": { "type": "string" }, 54 55 "publicationDate": { "type": "string", "format": "datetime" }, 55 56 "questions": { "type": "array", "items": { "$ref": "#/definitions/docs/Question" } }, … … 67 68 "description": { "type": "string" }, 68 69 "endDate": { "type": "string", "format": "datetime" }, 70 "liveName": { "type": "string" }, 69 71 "mode": { "type": "string", "enum": [ "open", "closed" ] }, 70 "secret": { "type": "string", "minLength": 8 }, 72 "respondentCanDeleteOwnResponse": { "type": "boolean" }, 73 "secret": { "type": "string", "minLength": 1 }, 71 74 "startDate": { "type": "string", "format": "datetime" }, 72 75 "survey": { "$ref": "#/definitions/docs/Survey" }, … … 83 86 "_rev": { "type": "string" }, 84 87 "answers": { "type": "object" }, 88 "email": { "type": "string", "format": "email" }, 85 89 "publicationDate": { "type": "string", "format": "datetime" }, 86 "secret": { "type": "string", "minLength": 8},90 "secret": { "type": "string", "minLength": 1 }, 87 91 "surveyRunId": { "type": "string" } 88 92 }, -
Dev/trunk/src/server/config/upgrade-couchdb.js
r487 r492 1 1 var Q = require('q') 2 2 , _ = require('underscore') 3 , tv4 = require('tv4')4 3 , CouchDB = require('../util/couch').CouchDB 5 4 ;
Note: See TracChangeset
for help on using the changeset viewer.