Changeset 490 for Dev/trunk/src/client/qed-client/pages/survey.js
- Timestamp:
- 03/08/14 22:51:23 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/pages/survey.js
r487 r490 1 1 define([ 2 "../app/Page",3 2 "../app/Router", 4 3 "../model/classes/surveys", 5 4 "../model/widgets/QuestionListView", 6 5 "../model/widgets/TabbedQuestionBrowser", 6 "./_ObjectPage", 7 7 "dojo/_base/array", 8 8 "dojo/_base/declare", … … 12 12 "require", 13 13 "dojo/text!./templates/survey.html" 14 ], function( Page, Router, surveys, QuestionListView, TabbedQuestionBrowser, array, declare, event, lang, when, require, template) {15 return declare([ Page],{14 ], function(Router, surveys, QuestionListView, TabbedQuestionBrowser, _ObjectPage, array, declare, event, lang, when, require, template) { 15 return declare([_ObjectPage],{ 16 16 contextRequire: require, 17 17 templateString: template, 18 survey: null,18 classStore: surveys, 19 19 questionList: null, 20 20 startup: function() { 21 21 if ( this._started ) { return; } 22 22 this.inherited(arguments); 23 if ( this.surveyId ) { 24 this._setupQuestionBrowser(); 25 this._setupListView(); 26 this._loadSurvey(); 27 } else { 28 throw "No valid uid or survey passed!"; 29 } 23 this._setupQuestionBrowser(); 24 this._setupListView(); 25 this._load(); 30 26 }, 31 27 _setupQuestionBrowser: function() { … … 60 56 this.questionList.startup(); 61 57 }, 62 _loadSurvey: function() { 63 if ( this.surveyId === "new" ) { 64 this.survey = surveys.create(); 65 this.refresh(); 66 } else { 67 when(surveys.load(this.surveyId)) 68 .then(lang.hitch(this,function(survey){ 69 this.survey = survey; 70 this.questionList.set('value', 71 this.survey.questions); 72 this.refresh(); 73 })); 74 } 58 _refresh: function() { 59 this.titleNode.innerHTML = this.object.title || "(set title in properties)"; 60 this.propertiesDialog.set('value',this.object); 61 this.questionList.set('value', 62 this.object.questions); 63 }, 64 _save: function() { 65 this.object.questions = this.questionList.get('value'); 66 return this.inherited(arguments); 75 67 }, 76 68 _includeQuestion: function(question) { 77 69 this.questionList.appendItem(question); 78 70 }, 79 refresh: function() {80 this.titleNode.innerHTML = this.survey.title || "(set title in properties)";81 this.propertiesDialog.set('value',this.survey);82 },83 71 _onShowProperties: function(evt) { 84 72 this.propertiesDialog.show(); 73 if ( evt ) { event.stop(evt); } 74 return false; 85 75 }, 86 76 _onPropertiesOk: function(evt) { 87 77 this.propertiesDialog.hide(); 88 lang.mixin(this.survey, this.propertiesDialog.get('value')); 89 this.refresh(); 90 event.stop(evt); 78 lang.mixin(this.object, this.propertiesDialog.get('value')); 79 this.markDirty(); 80 this._refresh(); 81 if ( evt ) { event.stop(evt); } 91 82 return false; 92 83 }, 93 84 _onPropertiesCancel: function(evt) { 94 85 this.propertiesDialog.hide(); 95 this.propertiesDialog. reset('value',this.survey);96 event.stop(evt);86 this.propertiesDialog.set('value',this.object); 87 if ( evt ) { event.stop(evt); } 97 88 return false; 98 89 }, 99 90 _onSave: function(evt) { 100 this.survey.questions = this.questionList.get('value'); 101 surveys.save(this.survey) 91 this._save(); 92 if ( evt ) { event.stop(evt); } 93 return false; 94 }, 95 _onSaveAndClose: function(evt) { 96 this._save() 102 97 .then(function() { 103 Router.go( '/surveys');98 Router.go(surveys.getCollectionPath()); 104 99 }); 105 100 event.stop(evt); 106 101 return false; 107 102 }, 108 _onDiscard: function(evt) { 109 Router.go('/surveys'); 103 _onDiscardAndClose: function(evt) { 104 this.markClean(); 105 Router.go(surveys.getCollectionPath()); 110 106 }, 111 107 _onShowPreview: function() { 112 Router.go( '/previewSurvey/'+this.survey._id,{108 Router.go(surveys.getPreviewPath(this.object),{ 113 109 preview: true 114 110 });
Note: See TracChangeset
for help on using the changeset viewer.