Ignore:
Timestamp:
03/13/14 01:19:07 (11 years ago)
Author:
hendrikvanantwerpen
Message:

Small fixes fir urls and validation.

File:
1 edited

Legend:

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

    r503 r512  
    55    "../model/widgets/TabbedQuestionBrowser",
    66    "./_ObjectPage",
     7    "dojo/Deferred",
    78    "dojo/_base/array",
    89    "dojo/_base/declare",
     
    1213    "require",
    1314    "dojo/text!./templates/survey.html"
    14 ], function(Router, surveys, QuestionListView, TabbedQuestionBrowser, _ObjectPage, array, declare, event, lang, when, require, template) {
     15], function(Router, surveys, QuestionListView, TabbedQuestionBrowser, _ObjectPage, Deferred, array, declare, event, lang, when, require, template) {
    1516    return declare([_ObjectPage],{
    1617        contextRequire: require,
     
    7778        },
    7879        _handleQuestionsChange: function() {
    79             this.object.questions = this.questionList.get('value');
     80            this._updateObject();
    8081            this.markDirty();
    8182            this._refresh();
    8283        },
    8384        _handlePropertiesChange: function() {
    84             lang.mixin(this.object, this.propertiesForm.get('value').survey);
     85            this._updateObject();
    8586            this.markDirty();
    8687            this._refresh();
    8788            this.layout();
     89        },
     90        _updateObject: function() {
     91            this._isValid = this.propertiesForm.validate();
     92            lang.mixin(this.object, this.propertiesForm.get('value').survey);
     93            this.object.questions = this.questionList.get('value');
     94            return this._isValid;
    8895        },
    8996        _onSave: function(evt) {
     
    109116            });
    110117        },
     118        _save: function() {
     119            if ( this._updateObject ) {
     120                return this.inherited(arguments);
     121            } else {
     122                return new Deferred().reject({error:"Please correct invalid values."});
     123            }
     124        },
    111125        markDirty: function() {
    112             this.saveBtn.set('disabled',false);
    113             this.saveAndCloseBtn.set('disabled',false);
     126            this.saveBtn.set('disabled',!this._isValid);
     127            this.saveAndCloseBtn.set('disabled',!this._isValid);
    114128            this.discardBtn.set('label','Discard & Close');
    115129            this.inherited(arguments);
Note: See TracChangeset for help on using the changeset viewer.