Changeset 416


Ignore:
Timestamp:
12/04/12 17:36:50 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Don't create new documents before editing them, because
our validation will reject them.

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

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/pages/session.js

    r410 r416  
    2222            this.inherited(arguments);
    2323            if ( this.sessionId ) {
     24                this._loadSession();
     25                this._setupAutoComplete();
     26            } else {
     27                throw "No valid uid or session passed!";
     28            }
     29        },
     30        _loadSession: function() {
     31            if ( this.sessionId === "new" ) {
     32                this.session = {
     33                    type: 'SessionTemplate'
     34                };
     35            } else {
    2436                Deferred.when(store.get(this.sessionId))
    2537                .then(lang.hitch(this,function(obj){
     
    2840                    this._refresh();
    2941                }));
    30                 this._setupAutoComplete();
    31             } else {
    32                 throw "No valid uid or session passed!";
    3342            }
    3443        },
  • Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js

    r410 r416  
    5858        },
    5959        onAddSessionTemplate: function(){
    60             store.put({
    61                 type: 'SessionTemplate'
    62             })
    63             .then(lang.hitch(this,function(obj){
    64                 Router.go('/session/'+store.getIdentity(obj));
    65             }));
     60            Router.go('/session/new');
    6661        },
    6762        _publishSession: function(sessionTemplate) {
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.js

    r410 r416  
    2727                this._setupQuestionBrowser();
    2828                this._setupListView();
    29                 this._setupSurvey();
     29                this._loadSurvey();
    3030            } else {
    3131                throw "No valid uid or survey passed!";
     
    6060            this.questionList.startup();
    6161        },
    62         _setupSurvey: function() {
    63             Deferred.when(store.get(this.surveyId))
    64             .then(lang.hitch(this,function(survey){
    65                 this.survey = survey;
    66                 store.query(null,{keys:this.survey.questions || [], include_docs: true})
    67                 .forEach(lang.hitch(this.questionList,'appendItem'));
     62        _loadSurvey: function() {
     63            if ( this.surveyId === "new" ) {
     64                this.survey = {
     65                    type: 'Survey'
     66                };
    6867                this.refresh();
    69             }));
     68            } else {
     69                Deferred.when(store.get(this.surveyId))
     70                .then(lang.hitch(this,function(survey){
     71                    this.survey = survey;
     72                    store.query(null,{keys:this.survey.questions || [], include_docs: true})
     73                    .forEach(lang.hitch(this.questionList,'appendItem'));
     74                    this.refresh();
     75                }));
     76            }
    7077        },
    7178        _includeQuestion: function(question) {
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js

    r415 r416  
    1919        },
    2020        _onNewSurvey: function(){
    21             when( store.add({type:'Survey'}) )
    22             .then(function(survey) {
    23                 Router.go('/survey/'+store.getIdentity(survey));
    24             },function(err){
    25                 Content.notify(err,'error');
    26             });
     21            Router.go('/survey/new');
    2722        },
    2823        _onPublishSurvey:function(survey){
Note: See TracChangeset for help on using the changeset viewer.