Ignore:
Timestamp:
12/16/12 20:07:35 (12 years ago)
Author:
hendrikvanantwerpen
Message:

We can store answers for surveys now!

Introduces SurveyRun?, which can be edited. Workflow not quite clear yet. A
running survey can be accessed to leave a response. When the response
has an ID, it is loaded (used for closed surveys and continuations). A
researcher cannot create responses yet. He should also be able to add
comments to responses (that he creates).

Introduced caching of store requests.

Factored out path matching and formatting.

Put object creation in separate classes, to localize model/storage
dependency. Not consistent at the moment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/qed/pages/surveys.js

    r418 r420  
    99    '../app/Page',
    1010    '../app/Router',
     11    '../model/classes/Survey',
     12    '../model/classes/SurveyRun',
    1113    '../widgets/LineWithActionsWidget',
    1214    'dojo/text!./templates/surveys.html'
    13 ],function(array,declare,lang,when,Rx,store,Content,Page,Router,LineWithActionsWidget,template){
     15],function(array,declare,lang,when,Rx,store,Content,Page,Router,Survey,SurveyRun,LineWithActionsWidget,template){
    1416    return declare([Page],{
    1517        templateString: template,
     
    4547        },
    4648        _onPreviewSurvey:function(survey){
    47             Router.go('/viewSurvey/'+store.getIdentity(survey),{preview:true});
     49            Router.go('/previewSurvey/'+store.getIdentity(survey));
    4850        },
    4951        _onRunSurvey:function(survey){
    50             this.surveyRun = {
    51                 type: 'SurveyRun',
    52                 surveyId: store.getIdentity(survey),
    53                 publicationDate: store.timestamp()
    54             };
    55             this.surveyRunDialog.set('value',this.surveyRun);
    56             this.surveyRunDialog.show();
    57         },
    58         _onSurveyRunOk: function() {
    59             var surveyRun = lang.mixin(lang.clone(this.surveyRun),this.surveyRunDialog.get('value'));
     52            var surveyRun = SurveyRun.create();
     53            SurveyRun.Survey.set(surveyRun,survey);
    6054            store.put(surveyRun)
    61             .then(lang.hitch(this,function(){
    62                 this.surveyRunDialog.hide();
    63                 this.refreshRuns();
     55            .then(lang.hitch(this,function(surveyRun){
     56                this._onRunDetails(surveyRun);
    6457            }),function(err){
    6558                Content.notify(err);
    6659            });
    6760        },
    68         _onSurveyRunCancel: function() {
    69             this.surveyRunDialog.hide();
     61        _onRunDetails: function(surveyRun) {
     62            Router.go('/surveyRun/'+store.getIdentity(surveyRun));
    7063        },
    7164        refresh: function() {
     
    8174                array.forEach(surveys,function(survey){
    8275                    var w = new LineWithActionsWidget({
    83                         title: survey.title || '(unnamed)',
     76                        title: Survey.DisplayTitle.get(survey) || '(unnamed)',
    8477                        actions: [{
    8578                            callback: lang.hitch(this,'_onPublishSurvey',survey),
     
    123116                array.forEach(surveys,function(survey){
    124117                    var w = new LineWithActionsWidget({
    125                         title: survey.title,
     118                        title: Survey.DisplayTitle.get(survey),
    126119                        actions:[{
    127120                            callback: lang.hitch(this,'_onPreviewSurvey',survey),
     
    151144                array.forEach(surveyRuns,function(surveyRun){
    152145                    var w = new LineWithActionsWidget({
    153                         title: surveyRun.title+" (from "+surveyRun.startDate+" to "+surveyRun.endDate+")",
     146                        title: SurveyRun.DisplayTitle.get(surveyRun),
    154147                        actions:[{
    155                             callback: lang.hitch(this,'_onCloseRun',surveyRun),
     148                            callback: lang.hitch(this,'_onRunDetails',surveyRun),
    156149                            properties: {
    157                                 label: 'Close',
    158                                 tooltip: 'Close survey',
    159                                 icon: 'Close'
     150                                label: 'Details',
     151                                tooltip: 'Show details for this run',
     152                                icon: 'Details'
    160153                            }
    161154                        }]
Note: See TracChangeset for help on using the changeset viewer.