source: Dev/trunk/src/client/qed-client/model/classes/surveys.js @ 536

Last change on this file since 536 was 492, checked in by hendrikvanantwerpen, 11 years ago
  • Enable/disable buttons on content change.
  • One place to do date formatting, because it was going wrong again.
  • Serialize questions in survey properly.
  • _ComplexValueMixin consumes submit events, but does trigger outer forms if present.
  • Trigger dialog show/hide for login only after previous effect is finished.
  • Check that documents are actually valid, not just that validator returned a result.
  • Validate email and timestamp formats.
  • Prepared for live runs.
File size: 1.3 KB
Line 
1define([
2    "./_Class",
3    "./questions",
4    "dojo/_base/array",
5    "dojo/_base/declare",
6    "dojo/_base/lang"
7], function(_Class, questions, array, declare, lang) {
8
9    var Surveys = declare([_Class],{
10        _collection: 'surveys',
11        _type: 'Survey',
12        create: function() {
13            var obj = {
14                type: this._type,
15                questions: [],
16                title: ""
17            };
18            return obj;
19        },
20        _deserialize: function(obj) {
21            obj.questions = array.map(obj.questions,
22                                      lang.hitch(questions,'_doDeserialize'));
23            if (obj.publicationDate) {
24                obj.publicationDate = this._parseDate(obj.publicationDate);
25            }
26        },
27        _serialize: function(obj) {
28            obj.questions = array.map(obj.questions,
29                                      lang.hitch(questions,'_doSerialize'));
30            if (obj.publicationDate) {
31                obj.publicationDate = this._formatDate(obj.publicationDate);
32            }
33        },
34        getPreviewPath: function(idOrObj) {
35            return '/previewSurvey/'+(typeof idOrObj === "string"?
36                                      idOrObj :
37                                      this.getId(idOrObj));
38        }
39    });
40
41    return new Surveys();
42
43});
Note: See TracBrowser for help on using the repository browser.