Ignore:
Timestamp:
12/04/12 16:29:49 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Support data validation and increase dendency separation.

Added json-schema validation before documents are saved. Acts both as
a safe-guard and as a reference of the data model.

Added directory for server related material. For now it contains scripts
to configure CouchDB and check validity of documents against the schema.

Started separating out parts that depend on the data model from parts
that do not.

Location:
Dev/branches/rest-dojo-ui/client/rft/pages
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/pages/question.html

    r407 r415  
    33        <h2>
    44            <span class="rftIcon rftIconSurvey"></span>
    5             <span class="headerText">Question 123 [Editing]</span>
     5            <span class="headerText"><span data-dojo-attach-point="titleNode">Question title</span> [Editing]</span>
    66        </h2>
    77    </div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/question.js

    r410 r415  
    2121            if ( this._started ) { return; }
    2222            this.inherited(arguments);
    23             if (this.questionId) {
     23            if ( !this.questionId ) {
     24                throw new Error("Error: no reference to object set!");
     25            }
     26            this._setupEditor();
     27            if (this.questionId === "new") {
     28                this.question = { type: 'Question' };
     29                this._refresh();
     30            } else {
    2431                Deferred.when(store.get(this.questionId))
    2532                .then(lang.hitch(this, function(obj) {
     
    2734                    this._refresh();
    2835                }));
    29             } else {
    30                 throw new Error("Error: no reference to object set!");
    3136            }
    32             this._setupEditor();
    3337        },
    3438        onLeave: function() {
     
    3640        },
    3741        _refresh: function () {
     42            this.titleNode.innerHTML = this.question.title || "";
    3843            this._toolkit.set('value',this.question);
    3944            this._preview.appendItems(this.question.content || []);
     
    4651                Router.go('/questions');
    4752            },function(err){
    48                 Content.notify(err.reason,'error');
     53                Content.notify(err,'error');
    4954            });
    5055            evt && event.stop( evt );
  • Dev/branches/rest-dojo-ui/client/rft/pages/questions.js

    r414 r415  
    4040        },
    4141        onNewQuestion: function() {
    42             Deferred.when(store.add({type:'Question'}))
    43             .then(lang.hitch(this,function(question){
    44                 this.onEditQuestion(question);
    45             }));
     42            Router.go("/question/new");
    4643        },
    4744        onDeleteQuestion: function(question) {
     
    5047                Content.notify("Question deleted.");
    5148            },function(err){
    52                 Content.notify(err.reason,'error');
     49                Content.notify(err,'error');
    5350            });
    5451        },
     
    6259                Content.notify("Question published.");
    6360            },function(err){
    64                 Content.notify(err.reason,'error');
     61                Content.notify(err,'error');
    6562            });
    6663        }
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.html

    r407 r415  
    4040         data-dojo-attach-event="onSubmit:_onPropertiesOk">
    4141
    42         <form data-dojo-type="dijit/form/Form"
    43               data-dojo-attach-point="propertiesForm">
    44             <label for="title">Title</label>
    45             <input data-dojo-type="dijit/form/TextBox" name="title"/><br/>
    46             <label for="description">Description</label>
    47             <input data-dojo-type="dijit/form/Textarea" name="description"/><br/>
    48         </form>
     42        <div data-dojo-type="rft/ui/model/SurveyForm"
     43              data-dojo-attach-point="propertiesForm"></div>
    4944           
    5045        <div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.html

    r414 r415  
    3636    </div>
    3737
     38    <div data-dojo-type="dijit/Dialog"
     39         title="SurveyRun properties"
     40         data-dojo-attach-point="surveyRunDialog">
     41        <form data-dojo-type="rft/ui/model/SurveyRunForm" data-dojo-attach-point="surveyRunForm">
     42            <button data-dojo-type="dijit/form/Button">OK</button>
     43            <button data-dojo-type="dijit/form/Button">Cancel</button>
     44        </form>
     45    </div>
     46
    3847</div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js

    r414 r415  
    2323                Router.go('/survey/'+store.getIdentity(survey));
    2424            },function(err){
    25                 Content.notify(err.reason,'error');
     25                Content.notify(err,'error');
    2626            });
    2727        },
     
    3333                self.refreshPublished();
    3434            },function(err){
    35                 Content.notify(err.reason,'error');
     35                Content.notify(err,'error');
    3636            });
    3737        },
     
    4242                self.refreshDrafts();
    4343            },function(err){
    44                 Content.notify(err.reason,'error');
     44                Content.notify(err,'error');
    4545            });
    4646        },
     
    5252        },
    5353        _onRunSurvey:function(survey){
    54 
     54            this.surveyRunDialog.show();
    5555        },
    5656        refresh: function() {
  • Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js

    r410 r415  
    77    '../store',
    88    '../app/Page',
    9     '../ui/content/ContentWidgetFactory',
     9    '../ui/model/QuestionWidgetFactory',
    1010    'dojo/text!./viewSurvey.html'
    11 ],function(array,declare,Deferred,event,lang,store,Page,ContentWidgetFactory,template){
     11],function(array,declare,Deferred,event,lang,store,Page,QuestionWidgetFactory,template){
    1212    return declare([Page],{
    1313        templateString: template,
     
    3535                    this.titleNode.innerHTML = survey.title +
    3636                            (this.options.preview?' [preview]':'');
    37                     var f = new ContentWidgetFactory();
     37                    var f = new QuestionWidgetFactory();
    3838                    this.survey = survey;
    3939                    store.query(null,{keys:this.survey.questions,include_docs:true})
Note: See TracChangeset for help on using the changeset viewer.