Changeset 493 for Dev


Ignore:
Timestamp:
03/09/14 19:25:40 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • _ComplexValueMixin propagates priorityChange to children.
  • Deserialize updated docs after save too.
  • Validate to false if definitions are missing.
Location:
Dev/trunk/src
Files:
1 added
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/model/classes/_Class.js

    r492 r493  
    3434        save: function(obj) {
    3535            return this._store.put(this._doSerialize(obj))
    36             .otherwise(lang.hitch(this,'_deserializeError'));
     36            .then(lang.hitch(this,'_doDeserialize'),
     37                  lang.hitch(this,'_deserializeError'));
    3738        },
    3839        remove: function(objOrId,rev) {
  • Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorToolkit.js

    r487 r493  
    3030            { type: "Header" },
    3131            { type: "Text" },
    32             { type: "Image" },
    33             { type: "ExternalMedia" },
    3432            { type: "Divider" }
    3533        ],
     
    4442            "Header": "Header",
    4543            "Text": "Text",
    46             "Image": "Image",
    47             "ExternalMedia": "External media",
    4844            "Divider": "Divider",
    4945            "StringInput": "Text line",
     
    5652            "Header": "Header",
    5753            "Text": "TextBox",
    58             "Image": "Image",
    59             "ExternalMedia": "External",
    6054            "Divider": "Divider",
    6155            "StringInput": "Text",
  • Dev/trunk/src/client/qed-client/model/widgets/SurveyRunWidget.js

    r492 r493  
    1717            if ( !value.startDate ) { delete value.startDate; }
    1818            if ( !value.endDate ) { delete value.endDate; }
    19             value.respondentCanDeleteOwnResponse = value.respondentCanDeleteOwnResponse[0] === true;
     19            value.respondentCanDeleteOwnResponse =
     20                value.respondentCanDeleteOwnResponse.length > 0;
    2021            return value;
     22        },
     23        _setValueAttr: function(value) {
     24            value.respondentCanDeleteOwnResponse =
     25                value.respondentCanDeleteOwnResponse ? ["on"] : [];
     26            this.inherited(arguments);
    2127        }
    2228    });
  • Dev/trunk/src/client/qed-client/model/widgets/SurveySummary.js

    r490 r493  
    1919            this.titleNode.innerHTML = survey.title || "";
    2020            domAttr.set(this.titleNode, "href", survey && surveys.getObjectPath(survey));
    21             this.descriptionNode.innerHTML = survey.description;
     21            this.descriptionNode.innerHTML = survey.description || "";
    2222            this.questionsNode.innerHTML = survey.questions.length;
    2323        }
  • Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputConfigWidget.js

    r490 r493  
    5252        _getValueAttr: function() {
    5353            var value = this.inherited(arguments);
    54             value.allowMultiple = value.allowMultiple && value.allowMultiple.length > 0;
     54            value.allowMultiple = value.allowMultiple.length > 0;
    5555            value.type = this.type;
    5656            return value;
    57         },
    58         _setValueAttr: function(value) {
    59             value.allowMultiple = value.allowMultiple === true ? ["on"] : [];
    60             this.inherited(arguments);
    6157        },
    6258        onAddItem: function(evt) {
  • Dev/trunk/src/client/qed-client/model/widgets/questions/NumberInputConfigWidget.js

    r443 r493  
    1010            var value = this.inherited(arguments);
    1111            value.type = this.type;
     12            if ( !value.min ) { delete value.min; }
     13            if ( !value.max ) { delete value.max; }
     14            if ( !value.places ) { delete value.places; }
    1215            return value;
    1316        }
  • Dev/trunk/src/client/qed-client/model/widgets/questions/TextInputConfigWidget.js

    r443 r493  
    1010            var value = this.inherited(arguments);
    1111            value.type = this.type;
     12            if ( !value.maxLength ) { delete value.maxLength; }
    1213            return value;
    1314        }
  • Dev/trunk/src/client/qed-client/model/widgets/questions/templates/MultipleChoiceInputConfigRowWidget.html

    r461 r493  
    11<form>
    2   <div data-dojo-type="dijit/form/ValidationTextBox" name="text" required="required" data-dojo-attach-point="textBox"></div><div data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:onDestroy">X</div>
     2  <div data-dojo-type="dijit/form/ValidationTextBox"
     3       name="text" required="required"
     4       data-dojo-attach-point="textBox"></div>
     5  <div data-dojo-type="dijit/form/Button"
     6       data-dojo-attach-event="onClick:onDestroy">X</div>
    37</form>
  • Dev/trunk/src/client/qed-client/model/widgets/questions/templates/MultipleChoiceInputConfigWidget.html

    r461 r493  
    66  <div data-dojo-attach-point="itemsNode">
    77  </div>
    8   <div data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:onAddItem">Add item</div>
     8  <div data-dojo-type="dijit/form/Button"
     9       data-dojo-attach-event="onClick:onAddItem">Add item</div>
    910</form>
  • Dev/trunk/src/client/qed-client/model/widgets/templates/SurveyRunWidget.html

    r492 r493  
    2525        <input type="text" name="respondentCanDeleteOwnResponse"
    2626               class="qedField"
    27                data-dojo-type="dijit/form/CheckBox"
    28                data-dojo-props="'value':true" />
     27               data-dojo-type="dijit/form/CheckBox" />
    2928    </div>
    3029
  • Dev/trunk/src/client/qed-client/pages/question.js

    r492 r493  
    2525        _refresh: function() {
    2626            this.titleNode.innerHTML = this.object.title || "";
    27             this.propertiesForm.set('value',this.object);
    28             this.contentList.set('value',this.object.content);
     27            this.propertiesForm.set('value',this.object,null);
     28            this.contentList.set('value',this.object.content,null);
    2929        },
    3030        _handlePropertiesChange: function() {
    31             lang.mixin(this.object,this.propertiesForm.get('value'));
     31            this._updateObject();
    3232            this.markDirty();
    3333            this._refresh();
    3434        },
    3535        _handleContentChange: function() {
    36             this.object.content = this.contentList.get('value');
     36            this._updateObject();
    3737            this.markDirty();
    3838            this._refresh();
    3939        },
     40        _updateObject: function() {
     41            var pValid = this.propertiesForm.validate();
     42            if ( pValid ) {
     43                lang.mixin(this.object,this.propertiesForm.get('value'));
     44            }
     45            var cValid = this.contentList.validate();
     46            if ( cValid ) {
     47                this.object.content = this.contentList.get('value');
     48            }
     49            this._isValid = pValid && cValid;
     50            return this._isValid;
     51        },
    4052        _save: function() {
    41             if ( this._isValid ) {
     53            if ( this._updateObject() ) {
    4254                return this.inherited(arguments);
    4355            } else {
     
    6577        },
    6678        markDirty: function() {
    67             this._isValid = this.propertiesForm.validate() &&
    68                             this.contentList.validate();
    6979            this.saveBtn.set('disabled',!this._isValid);
    7080            this.saveAndCloseBtn.set('disabled',!this._isValid);
     
    7383        },
    7484        markClean: function() {
    75             this._isValid = true;
    7685            this.saveBtn.set('disabled',true);
    7786            this.saveAndCloseBtn.set('disabled',true);
  • Dev/trunk/src/client/qed-client/pages/survey.js

    r492 r493  
    5959        _refresh: function() {
    6060            this.titleNode.innerHTML = this.object.title || "(set title in properties)";
    61             this.propertiesForm.set('value',{survey:this.object});
    62             this.questionList.set('value',
    63                                   this.object.questions);
     61            this.propertiesForm.set('value',{survey:this.object},null);
     62            this.questionList.set('value',this.object.questions,null);
    6463        },
    6564        _includeQuestion: function(question) {
  • Dev/trunk/src/client/qed-client/pages/surveyRun.js

    r492 r493  
    2222        templateString: template,
    2323        classStore: surveyRuns,
     24        _isValid: false,
    2425        startup: function() {
    2526            if ( this._started ) { return; }
     
    3031        _refresh: function() {
    3132            this.titleNode.innerHTML = this.object.title || "";
    32             this.surveySummaryWidget.set('value',this.object.survey);
    33             this.surveyRunWidget.set('value',this.object);
     33            this.surveySummaryWidget.set('value',this.object.survey,null);
     34            this.surveyRunWidget.set('value',this.object,null);
    3435            this._refreshURL();
    3536            this._loadResponses();
     
    9697        },
    9798        _updateObject: function() {
    98             var valid = this.surveyRunWidget.validate();
    99             if ( valid ) {
     99            this._isValid = this.surveyRunWidget.validate();
     100            if ( this._isValid ) {
    100101                lang.mixin(this.object,this.surveyRunWidget.get('value'));
    101102            }
    102             return valid;
     103            return this._isValid;
    103104        },
    104105        _onSave: function(evt) {
     
    122123        },
    123124        markDirty: function() {
    124             this.saveBtn.set('disabled',false);
    125             this.saveAndCloseBtn.set('disabled',false);
     125            this.saveBtn.set('disabled',!this._isValid);
     126            this.saveAndCloseBtn.set('disabled',!this._isValid);
    126127            this.discardBtn.set('label','Discard & Close');
    127128            this.inherited(arguments);
  • Dev/trunk/src/client/qed-client/widgets

    • Property svn:ignore
      •  

        old new  
        11
        2 ### begin grunt-svn-ignore managed ignores
        3 ### edits will be overwritten when grunt svn-ignore is run
        4 _ComplexValueMixin.js
        5 ### end grunt-svn-ignore managed ignores
  • Dev/trunk/src/server/config/couchdb-schema.json

    r492 r493  
    9999        "type": "object",
    100100        "oneOf": [
     101          { "$ref": "#/definitions/content/Header" },
    101102          { "$ref": "#/definitions/content/Text" },
     103          { "$ref": "#/definitions/content/Divider" },
    102104          { "$ref": "#/definitions/content/StringInput" },
    103           { "$ref": "#/definitions/content/ScaleInput" }
     105          { "$ref": "#/definitions/content/TextInput" },
     106          { "$ref": "#/definitions/content/NumberInput" },
     107          { "$ref": "#/definitions/content/ScaleInput" },
     108          { "$ref": "#/definitions/content/MultipleChoiceInput" }
    104109        ]
    105110      },
     111      "Header": {
     112        "type": "object",
     113        "properties": {
     114          "type": { "type": "string", "pattern": "Header" },
     115          "text": { "type": "string" }
     116        },
     117        "required": ["type","text"],
     118        "additionalProperties": false
     119      },
    106120      "Text": {
    107121        "type": "object",
     
    113127        "additionalProperties": false
    114128      },
     129      "Divider": {
     130        "type": "object",
     131        "properties": {
     132          "type": { "type": "string", "pattern": "Divider" }
     133        },
     134        "additionalProperties": false
     135      },
    115136      "StringInput": {
    116137        "type": "object",
    117138        "properties": {
    118139          "type": { "type": "string", "pattern": "StringInput" },
     140          "text": { "type": "string" }
     141        },
     142        "required":["type","text"],
     143        "additionalProperties": false
     144      },
     145      "TextInput": {
     146        "type": "object",
     147        "properties": {
     148          "type": { "type": "string", "pattern": "TextInput" },
     149          "maxLength": { "type": "integer" },
     150          "text": { "type": "string" }
     151        },
     152        "required":["type","text"],
     153        "additionalProperties": false
     154      },
     155      "NumberInput": {
     156        "type": "object",
     157        "properties": {
     158          "type": { "type": "string", "pattern": "NumberInput" },
     159          "min": { "type": "integer" },
     160          "max": { "type": "integer" },
     161          "places": { "type": "integer" },
    119162          "text": { "type": "string" }
    120163        },
     
    144187        "required":["type","min","max","items"],
    145188        "additionalProperties": false
     189      },
     190      "MultipleChoiceInput": {
     191        "type": "object",
     192        "properties": {
     193          "type": { "type": "string", "pattern": "MultipleChoiceInput" },
     194          "allowMultiple": { "type": "boolean" },
     195          "items": { "type": "array", "items": {
     196              "type": "object",
     197              "properties": {
     198                  "text": { "type": "string" }
     199              },
     200              "required": ["text"],
     201              "additionalProperties": false
     202          } }
     203        },
     204        "required":["type","items"],
     205        "additionalProperties": false
    146206      }
    147207    }
  • Dev/trunk/src/server/util/validator.js

    r492 r493  
    2222});
    2323
    24 module.exports = tv4.validateResult.bind(tv4);
     24module.exports = function() {
     25    var result = tv4.validateResult.apply(tv4,arguments);
     26    if ( result.missing.length > 0 ) {
     27        result.valid = false;
     28    }
     29    return result;
     30};
Note: See TracChangeset for help on using the changeset viewer.