1 | define(['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 | object: null,
|
---|
19 | preview: null,
|
---|
20 |
|
---|
21 | onVisit: function() {
|
---|
22 | if (this.pageArgs.uid) {
|
---|
23 | Deferred.when(store.get(this.pageArgs.uid))
|
---|
24 | .then(lang.hitch(this, function(obj) {
|
---|
25 | this.object = obj;
|
---|
26 | }));
|
---|
27 | } else {
|
---|
28 | throw new Error("Error: no reference to object set!");
|
---|
29 | }
|
---|
30 |
|
---|
31 | this._setupButtons();
|
---|
32 | this._setupEditor();
|
---|
33 | },
|
---|
34 | onLeave: function() {
|
---|
35 | this.inherited(arguments);
|
---|
36 | },
|
---|
37 | _setupButtons: function() {
|
---|
38 | var behaviorMap = {
|
---|
39 | "#btnSave": {
|
---|
40 | onclick: lang.hitch(this, function(){
|
---|
41 | this._saveSurvey();
|
---|
42 | })
|
---|
43 | },
|
---|
44 | "#btnDiscard": {
|
---|
45 | onclick: lang.hitch(this, function(){
|
---|
46 | this._restartEditor();
|
---|
47 | })
|
---|
48 | }
|
---|
49 | }
|
---|
50 | behavior.add(behaviorMap);
|
---|
51 | behavior.apply();
|
---|
52 | },
|
---|
53 | _setupEditor: function() {
|
---|
54 | this.toolkit = new rft.ui.QuestionEditorToolkit();
|
---|
55 | this.toolkit.placeAt("QuestionEditorToolkit");
|
---|
56 |
|
---|
57 | this.preview = new rft.ui.QuestionEditorPreview();
|
---|
58 | this.preview.placeAt("QuestionEditorPreview");
|
---|
59 | }
|
---|
60 | });
|
---|
61 | });
|
---|
62 |
|
---|