source: Dev/trunk/src/client/qed-client/model/classes/SurveyRun.js @ 457

Last change on this file since 457 was 457, checked in by hendrikvanantwerpen, 12 years ago

Improve SurveyRun? form and drop Fieldsets as widgets.

  • Improved console message on Page change fail.
  • Renamed some widgets, dropped having Fieldset widgets.
  • Put constraint that survey run start date cannot be before end date.
  • Link to survey from survey summary,
File size: 1.7 KB
Line 
1define(['dojo/_base/lang','dojo/date/locale','dojo/date/stamp'],function(lang,locale,stamp){
2    var SurveyRun = {
3        create: function(){
4            return { type:'SurveyRun' };
5        },
6        StartDate: {
7            get: function(sr) {
8                var d;
9                if ( sr.startDate ) {
10                    d = lang.isString(sr.startDate) ? stamp.fromISOString(sr.startDate) : sr.startDate;
11                }
12                return d;
13            },
14            set: function(sr,d) {
15                if ( d ) {
16                    sr.startDate = lang.isString(d) ? stamp.toISOString(d) : d;
17                }
18            }
19        },
20        EndDate: {
21            get: function(sr) {
22                var d;
23                if ( sr.endDate ) {
24                    d = lang.isString(sr.endDate) ? stamp.fromISOString(sr.endDate) : sr.endDate;
25                }
26                return d;
27            },
28            set: function(sr,d) {
29                if ( d ) {
30                    sr.endDate = lang.isString(d) ? stamp.toISOString(d) : d;
31                }
32            }
33        },
34        DisplayTitle: {
35            get: function(sr) {
36                var t = "Run of '"+sr.survey.title+"'";
37                if ( sr.startDate ) {
38                    t += " from "+locale.format(SurveyRun.StartDate.get(sr));
39                }
40                if ( sr.endDate ) {
41                    t += " until "+locale.format(SurveyRun.EndDate.get(sr));
42                }
43                return t;
44            }
45        },
46        Survey: {
47            get: function(sr) {
48                return sr.survey || null;
49            },
50            set: function(sr,s) {
51                sr.survey = s;
52                return sr;
53            }
54        }
55    };
56    return SurveyRun;
57});
Note: See TracBrowser for help on using the repository browser.