Ignore:
Timestamp:
07/26/12 21:57:20 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Changed SurveyListView? to more general OrderedDndList?.
Survey page has rudimentary properties dialog and saves included questions.
Fixed bug in store for null question.

Location:
Dev/branches/rest-dojo-ui/client/rft/pages
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.html

    r370 r379  
    55            <h2>
    66                <span class="rftIcon rftIconSurvey"></span>
    7                 <span class="headerText" data-dojo-attach-point="header">Survey A [editing]</span>
     7                <span class="headerText" data-rft-attach-point="titleNode">Survey Editor</span>
    88            </h2>
    99        </div>
     
    1818
    1919            <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'">
    20                 <button data-rft-attach-point="btnProperties" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onProperties" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconProperties'">Properties</button>
    21                 <button data-rft-attach-point="btnSave" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onSave" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">Save Changes</button>
    22                 <button data-rft-attach-point="btnDiscard" data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">Discard changes</button>
    23                 <button data-rft-attach-point="btnPreview" data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconPreview'">Preview</button>
     20                <button data-dojo-type="dijit.form.Button"
     21                        data-rft-attach-event="onClick:_onShowProperties"
     22                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconProperties'">
     23                    Properties</button>
     24                <button data-dojo-type="dijit.form.Button"
     25                        data-rft-attach-event="onClick:_onSave"
     26                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">
     27                    Save Changes</button>
     28                <button data-dojo-type="dijit.form.Button"
     29                        data-rft-attach-event="onClick:_onDiscard"
     30                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">
     31                    Discard changes</button>
     32                <button data-dojo-type="dijit.form.Button"
     33                        data-rft-attach-event="onClick:_onShowPreview"
     34                        data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconPreview'">
     35                    Preview</button>
    2436            </div>
    2537        </div>
    2638    </div>
     39
     40    <div data-dojo-type="dijit.Dialog"
     41         title="Survey properties"
     42         data-rft-attach-point="propertiesDialog"
     43         data-rft-attach-event="onSubmit:_onPropertiesOk">
     44
     45        <form data-dojo-type="dijit.form.Form"
     46              data-rft-attach-point="propertiesForm">
     47            <label for="title">Title</label>
     48            <input data-dojo-type="dijit.form.TextBox" name="title"/>
     49        </form>
     50           
     51        <div>
     52            <button data-dojo-type="dijit.form.Button"
     53                    type="submit"
     54                    data-rft-attach-event="onClick:_onPropertiesOk">
     55                OK</button>
     56            <button data-dojo-type="dijit.form.Button"
     57                    type="button"
     58                    data-rft-attach-event="onClick:_onPropertiesCancel">
     59                Cancel</button>
     60        </div>
     61    </div>
     62
    2763</div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.js

    r370 r379  
    11define([
     2    'dojo/_base/array',
    23    'dojo/_base/declare',
    34    'dojo/_base/Deferred',
     
    78    'rft/store',
    89    'rft/ui/_Page',
    9     'rft/ui/SurveyListView',
     10    'rft/ui/OrderedDndList',
    1011    'rft/ui/TabbedQuestionBrowser'
    1112    ],
    12     function(declare,Deferred,event,lang,content,store,_Page,SurveyListView,TabbedQuestionBrowser){
     13    function(array,declare,Deferred,event,lang,content,store,_Page,
     14             OrderedDndList,TabbedQuestionBrowser){
    1315        return declare('rft.pages.survey',[_Page],{
    14             object: null,
    15             listView: null,
     16            survey: null,
     17            questionList: null,
    1618            _dataMap: null,
    1719            constructor: function(){
     
    2022            onVisit: function() {
    2123                if ( this.pageArgs.uid ) {
     24                    this._setupQuestionBrowser();
     25                    this._setupListView();
    2226                    Deferred.when(store.get(this.pageArgs.uid))
    2327                    .then(lang.hitch(this,function(obj){
    24                         this.object = obj;
    25                         return Deferred.when( obj.creator && store.dereference(obj.creator) );
     28                        this.survey = obj;
     29                        this.refresh();
    2630                    }));
    27                     this._setupQuestionBrowser();
    28                     this._setupListView();
    2931                } else {
    3032                    throw "No valid uid or survey passed!";
    3133                }
    32             },
    33             onProperties: function(evt) {
    34 
    35             },
    36             onSave: function(evt) {
    37 //                lang.mixin(this.object, this.propertiesForm.get('value'));
    38                 store.put(this.object)
    39                 .then(function() {
    40                     content.goTo('surveys');
    41                 });
    42                 event.stop(evt);
    43                 return false;
    44             },
    45             _goToPreview: function() {
    46                 content.goTo('surveyAdvanced', {uid: this.object._id});
    4734            },
    4835            _setupQuestionBrowser: function() {
     
    5239                    selectedActions: {
    5340                        "Include": {
    54                             callback: lang.hitch(this,this.includeQuestion),
     41                            callback: lang.hitch(this,this._includeQuestion),
    5542                            icon: "Accept",
    5643                            description: "Include in survey"
     
    6754                this.questionBrowser.startup();
    6855            },
    69             /* ListView code */
    70             includeQuestion: function(question) {
    71                 var item = this.listView.insertItem(question);
     56            _includeQuestion: function(question) {
     57                this.questionList.insertItem(question);
    7258            },
    7359            _setupListView: function() {
    74                 this.listView = new SurveyListView({
    75                     controller: this
     60                this.questionList = new OrderedDndList({
     61                    type: 'question',
     62                    region: 'center'
    7663                }).placeAt(this.surveyListViewNode);
    77                 this.listView.startup();
     64                this.questionList.startup();
     65            },
     66            refresh: function() {
     67                this.titleNode.innerHTML = this.survey.title || "(set title in properties)";
     68                this.propertiesForm.set('value',this.survey);
     69                store.query(null,{keys:this.survey.questions,include_docs:true})
     70                .forEach(lang.hitch(this.questionList,'appendItem'));
     71            },
     72            _onShowProperties: function(evt) {
     73                this.propertiesDialog.show();
     74            },
     75            _onPropertiesOk: function(evt) {
     76                this.propertiesDialog.hide();
     77                lang.mixin(this.survey, this.propertiesForm.get('value'));
     78                this.refresh();
     79                event.stop(evt);
     80                return false;
     81            },
     82            _onPropertiesCancel: function(evt) {
     83                this.propertiesDialog.hide();
     84                this.propertiesForm.set('value',this.survey);
     85                event.stop(evt);
     86                return false;
     87            },
     88            _onSave: function(evt) {
     89                this.survey.questions = array.map(this.questionList.getItems(),function(item){
     90                    return store.getIdentity(item);
     91                });
     92                store.put(this.survey)
     93                .then(function() {
     94                    content.goTo('surveys');
     95                });
     96                event.stop(evt);
     97                return false;
     98            },
     99            _onDiscard: function(evt) {
     100            },
     101            _onShowPreview: function() {
     102                content.goTo('surveyAdvanced', {uid: store.getIdentity(this.survey)});
    78103            }
    79104        });
Note: See TracChangeset for help on using the changeset viewer.