source: Dev/branches/rest-dojo-ui/client/rft/pages/question.js @ 372

Last change on this file since 372 was 372, checked in by jkraaijeveld, 13 years ago

Started work on loading questions into the question editor if the already exist.

File size: 2.4 KB
Line 
1define(['dojo/_base/declare',
2    'dojo/_base/lang',
3    'dojo/_base/Deferred',
4    'rft/ui/LineWithActionsWidget',
5    'rft/store',
6    'rft/ui/_Page',
7    'rft/api',
8    'rft/content',
9    'dijit/registry',
10    'dojo/on',
11    'dojo/behavior',
12    'dojo/query',
13    'rft/ui/QuestionEditorPreview',
14    'rft/ui/QuestionEditorToolkit',
15    'dijit/form/FilteringSelect'],
16    function(declare, lang, Deferred, LineWithActionsWidget, store, _Page, api, content, registry, on, behavior, query){
17        return declare('rft.pages.question', [_Page], {
18            question: null,
19            _toolkit: null,
20            _preview: null,
21           
22            onVisit: function() {
23                if (this.pageArgs.uid) {
24                    Deferred.when(store.get(this.pageArgs.uid))
25                    .then(lang.hitch(this, function(obj) {
26                        this.question = obj;
27                        this._refresh();
28                    }));
29                } else {
30                    throw new Error("Error: no reference to object set!");
31                }
32                this._setupEditor();
33                this._setupButtons();
34            },
35            onLeave: function() {
36                this.inherited(arguments);
37            },
38            _refresh: function () {
39                this._toolkit.propertiesForm.set('value', this.question);
40            },
41            _setupButtons: function() {
42                var behaviorMap = {
43                    "#btnSave": {
44                        onclick: lang.hitch(this, function(){
45                            this._saveSurvey();
46                        })
47                    },
48                    "#btnDiscard": {
49                        onclick: lang.hitch(this, function(){
50                            this._restartEditor();
51                        })
52                    }
53                }
54                behavior.add(behaviorMap);
55                behavior.apply();
56            },
57            _setupEditor: function() {
58//                this.toolkit = new rft.ui.QuestionEditorToolkit( { question: this.question } );
59                this._toolkit = new rft.ui.QuestionEditorToolkit();
60                this._toolkit.placeAt("QuestionEditorToolkit");
61
62                this._preview = new rft.ui.QuestionEditorPreview();
63                this._preview.placeAt("QuestionEditorPreview");
64            }
65        });
66});
67
Note: See TracBrowser for help on using the repository browser.