Ignore:
Timestamp:
03/09/14 14:23:42 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Enable/disable buttons on content change.
  • One place to do date formatting, because it was going wrong again.
  • Serialize questions in survey properly.
  • _ComplexValueMixin consumes submit events, but does trigger outer forms if present.
  • Trigger dialog show/hide for login only after previous effect is finished.
  • Check that documents are actually valid, not just that validator returned a result.
  • Validate email and timestamp formats.
  • Prepared for live runs.
Location:
Dev/trunk/src/client/qed-client/pages
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/pages/_ObjectPage.js

    r491 r492  
    1111        classStore: null,
    1212        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();
    1421        },
    1522        _load: function() {
  • Dev/trunk/src/client/qed-client/pages/question.js

    r490 r492  
    2929        },
    3030        _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'));
    3432            this.markDirty();
     33            this._refresh();
    3534        },
    3635        _handleContentChange: function() {
    37             if ( this.contentList.validate() ) {
    38                 this.object.content = this.contentList.get('value');
    39             }
     36            this.object.content = this.contentList.get('value');
    4037            this.markDirty();
     38            this._refresh();
    4139        },
    4240        _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 ) {
    4642                return this.inherited(arguments);
    4743            } else {
     
    6864            return false;
    6965        },
     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        },
    7081        _ignore: function(evt) {
    7182            if ( evt ) { event.stop( evt ); }
  • Dev/trunk/src/client/qed-client/pages/response.js

    r490 r492  
    4040            this.submitButton.set('disabled',false);
    4141            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);
    4345            this.surveyWidget.set('disabled', false);
    4446        },
  • Dev/trunk/src/client/qed-client/pages/survey.js

    r491 r492  
    2323            this._setupQuestionBrowser();
    2424            this._setupListView();
     25            this.questionList.on('change',lang.hitch(this,'_handleQuestionsChange'));
    2526            this._load();
    2627        },
     
    5859        _refresh: function() {
    5960            this.titleNode.innerHTML = this.object.title || "(set title in properties)";
    60             this.propertiesDialog.set('value',{survey:this.object});
     61            this.propertiesForm.set('value',{survey:this.object});
    6162            this.questionList.set('value',
    6263                                  this.object.questions);
    6364        },
    64         _save: function() {
    65             this.object.questions = this.questionList.get('value');
    66             return this.inherited(arguments);
    67         },
    6865        _includeQuestion: function(question) {
    6966            this.questionList.appendItem(question);
     67        },
     68        _handleQuestionsChange: function() {
     69            this.object.questions = this.questionList.get('value');
     70            this.markDirty();
     71            this._refresh();
    7072        },
    7173        _onShowProperties: function(evt) {
     
    7678        _onPropertiesOk: function(evt) {
    7779            this.propertiesDialog.hide();
    78             lang.mixin(this.object, this.propertiesDialog.get('value').survey);
     80            lang.mixin(this.object, this.propertiesForm.get('value').survey);
    7981            this.markDirty();
    8082            this._refresh();
     
    8486        _onPropertiesCancel: function(evt) {
    8587            this.propertiesDialog.hide();
    86             this.propertiesDialog.set('value',{survey:this.object});
     88            this.propertiesForm.set('value',{survey:this.object});
    8789            if ( evt ) { event.stop(evt); }
    8890            return false;
     
    109111                preview: true
    110112            });
     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);
    111125        }
    112126    });
  • Dev/trunk/src/client/qed-client/pages/surveyRun.js

    r490 r492  
    7474        },
    7575        _onPropChange: function(e) {
    76             if ( this.surveyRunWidget.validate() ) {
    77                 lang.mixin(this.object,this.surveyRunWidget.get('value'));
     76            if ( this._updateObject() ) {
    7877                this._refreshURL();
    7978            }
     
    9089        },
    9190        _save: function() {
    92             if ( this.surveyRunWidget.validate() ) {
    93                 lang.mixin(this.object,this.surveyRunWidget.get('value'));
     91            if ( this._updateObject() ) {
    9492                return this.inherited(arguments);
    9593            } else {
    9694                return new Deferred.reject();
    9795            }
     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;
    98103        },
    99104        _onSave: function(evt) {
     
    115120            if ( evt ) { event.stop(evt); }
    116121            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);
    117134        }
    118135    });
  • Dev/trunk/src/client/qed-client/pages/templates/question.html

    r490 r492  
    1818                <button data-dojo-type="dijit/form/Button"
    1919                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'"
     20                        data-dojo-attach-point="saveBtn"
    2021                        data-dojo-attach-event="onClick:_onSave">
    2122                  Save</button>
    2223                <button data-dojo-type="dijit/form/Button"
    2324                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'"
     25                        data-dojo-attach-point="saveAndCloseBtn"
    2426                        data-dojo-attach-event="onClick:_onSaveAndClose">
    2527                  Save &amp; Close</button>
    2628                <button data-dojo-type="dijit/form/Button"
    2729                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'"
     30                        data-dojo-attach-point="discardBtn"
    2831                        data-dojo-attach-event="onClick:_onDiscard">
    2932                  Discard &amp; Close</button>
  • Dev/trunk/src/client/qed-client/pages/templates/survey.html

    r491 r492  
    2323            <button data-dojo-type="dijit/form/Button"
    2424                    data-dojo-attach-event="onClick:_onSave"
     25                    data-dojo-attach-point="saveBtn"
    2526                    data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">
    2627                Save</button>
    2728            <button data-dojo-type="dijit/form/Button"
    2829                    data-dojo-attach-event="onClick:_onSaveAndClose"
     30                    data-dojo-attach-point="saveAndCloseBtn"
    2931                    data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">
    3032                Save &amp; Close</button>
    3133            <button data-dojo-type="dijit/form/Button"
    3234                    data-dojo-attach-event="onClick:_onDiscardAndClose"
     35                    data-dojo-attach-point="discardBtn"
    3336                    data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">
    3437                Discard &amp; Close</button>
     
    4144
    4245    <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>
    5763    </div>
    5864
  • Dev/trunk/src/client/qed-client/pages/templates/surveyRun.html

    r490 r492  
    5555                class="blue"
    5656                data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconSave'"
     57                data-dojo-attach-point="saveBtn"
    5758                data-dojo-attach-event="onClick:_onSave">Save</button>
    5859        <button data-dojo-type="dijit/form/Button"
    5960                class="blue"
    6061                data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconSave'"
     62                data-dojo-attach-point="saveAndCloseBtn"
    6163                data-dojo-attach-event="onClick:_onSaveAndClose">Save &amp; Close</button>
    6264        <button data-dojo-type="dijit/form/Button"
    6365                class="blue"
    6466                data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconClose'"
     67                data-dojo-attach-point="discardBtn"
    6568                data-dojo-attach-event="onClick:_onDiscard">Discard &amp; Close</button>
    6669    </div>
Note: See TracChangeset for help on using the changeset viewer.