Ignore:
Timestamp:
08/15/12 18:30:58 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Added survey viewer page.

Added view.html page to view surveys. Widgets from the questions are
displayed, no answers are saved yet.

The content module is split for index.html and view.html, so viewers
cannot navigate to other pages. Widgets to pre-load are now seperated
in stddeps.js module and shared between run.js & view.js.

Location:
Dev/branches/rest-dojo-ui
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui

    • Property svn:ignore
      •  

        old new  
        11nbproject
         2.project
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.js

    r392 r399  
    9999            },
    100100            _onShowPreview: function() {
    101                 content.goTo('surveyAdvanced', {uid: store.getIdentity(this.survey)});
     101                content.goTo('previewSurvey', {uid: store.getIdentity(this.survey)});
    102102            }
    103103        });
  • Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.html

    r398 r399  
    1 <div data-dojo-type="rft.pages.survey" class="blue">
     1<div data-dojo-type="rft.pages.viewSurvey" class="blue">
    22    <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'center'" style="height: 500px;">
    33
     
    55            <h2>
    66                <span class="rftIcon rftIconSurvey"></span>
    7                 <span class="headerText" data-rft-attach-point="titleNode">Survey Editor</span>
     7                <span class="headerText" data-rft-attach-point="titleNode">Survey</span>
    88            </h2>
    99        </div>
    1010       
    11         <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'center'">
    12             <div data-rft-attach-point="questionBrowser"></div>
     11        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" data-rft-attach-point="questionsPane">
    1312        </div>
    1413       
    15         <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'right'" style="width: 300px">
    16             <div data-rft-attach-point="surveyListViewNode" class="rftSurveyListView">
    17             </div>
    18 
    19             <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'">
    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>
    36             </div>
    37         </div>
    38     </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"/><br/>
    49             <label for="description">Description</label>
    50             <input data-dojo-type="dijit.form.Textarea" name="description"/><br/>
    51         </form>
    52            
    53         <div>
     14        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'bottom'">
    5415            <button data-dojo-type="dijit.form.Button"
    5516                    type="submit"
    56                     data-rft-attach-event="onClick:_onPropertiesOk">
    57                 OK</button>
     17                    data-rft-attach-event="onClick:_onSubmit">
     18                Submit</button>
    5819            <button data-dojo-type="dijit.form.Button"
    5920                    type="button"
    60                     data-rft-attach-event="onClick:_onPropertiesCancel">
     21                    data-rft-attach-event="onClick:_onCancel">
    6122                Cancel</button>
    6223        </div>
     24
    6325    </div>
    64 
    6526</div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js

    r398 r399  
    55    'dojo/_base/event',
    66    'dojo/_base/lang',
    7     '../content',
    87    '../store',
    98    '../ui/_Page',
    10     '../ui/lists/QuestionListView',
    11     '../ui/TabbedQuestionBrowser'
     9    '../ui/content/ContentWidgetFactory'
    1210    ],
    13     function(array,declare,Deferred,event,lang,content,store,_Page,
    14              QuestionListView,TabbedQuestionBrowser){
    15         return declare('rft.pages.survey',[_Page],{
     11    function(array,declare,Deferred,event,lang,store,_Page,ContentWidgetFactory){
     12        return declare('rft.pages.viewSurvey',[_Page],{
    1613            survey: null,
    17             questionList: null,
    18             _dataMap: null,
    1914            constructor: function(){
    2015                this._dataMap = {};
     
    2217            onVisit: function() {
    2318                if ( this.pageArgs.uid ) {
    24                     this._setupQuestionBrowser();
    25                     this._setupListView();
    2619                    Deferred.when(store.get(this.pageArgs.uid))
    2720                    .then(lang.hitch(this,function(obj){
     21                        var f = new ContentWidgetFactory();
    2822                        this.survey = obj;
    2923                        store.query(null,{keys:this.survey.questions,include_docs:true})
    30                         .forEach(lang.hitch(this.questionList,'appendItem'));
    31                         this.refresh();
     24                        .forEach(function(question){
     25                            array.forEach(question.content,function(item){
     26                                var w = f.createViewWidget(item);
     27                                if ( w !== null ) {
     28                                    w.placeAt(this.questionsPane.containerNode,'last');
     29                                    w.startup();
     30                                }
     31                            },this);
     32                        },this);
    3233                    }));
    3334                } else {
     
    3536                }
    3637            },
    37             _setupQuestionBrowser: function() {
    38                 this.questionBrowser = new TabbedQuestionBrowser({
    39                     region: 'center',
    40                     'class': 'blue',
    41                     selectedActions: {
    42                         "Include": {
    43                             callback: lang.hitch(this,this._includeQuestion),
    44                             icon: "Accept",
    45                             description: "Include in survey"
    46                         }
    47                     },
    48                     itemActions: {
    49                         "Info": {
    50                             callback: function(item){ item.description && alert(item.description); },
    51                             icon: "Inspect",
    52                             description: "Show item description"
    53                         }
    54                     }
    55                 },this.questionBrowser);
    56                 this.questionBrowser.startup();
    57             },
    58             _includeQuestion: function(question) {
    59                 this.questionList.insertItem(question);
    60             },
    61             _setupListView: function() {
    62                 this.questionList = new QuestionListView({
    63                     region: 'center'
    64                 },this.surveyListViewNode);
    65                 this.questionList.startup();
    66             },
    67             refresh: function() {
    68                 this.titleNode.innerHTML = this.survey.title || "(set title in properties)";
    69                 this.propertiesForm.set('value',this.survey);
    70             },
    71             _onShowProperties: function(evt) {
    72                 this.propertiesDialog.show();
    73             },
    74             _onPropertiesOk: function(evt) {
    75                 this.propertiesDialog.hide();
    76                 lang.mixin(this.survey, this.propertiesForm.get('value'));
    77                 this.refresh();
     38            _onSubmit: function(evt) {
    7839                event.stop(evt);
    7940                return false;
    8041            },
    81             _onPropertiesCancel: function(evt) {
    82                 this.propertiesDialog.hide();
    83                 this.propertiesForm.set('value',this.survey);
     42            _onCancel: function(evt) {
    8443                event.stop(evt);
    8544                return false;
    86             },
    87             _onSave: function(evt) {
    88                 this.survey.questions = array.map(this.questionList.getItems(),function(item){
    89                     return store.getIdentity(item);
    90                 });
    91                 store.put(this.survey)
    92                 .then(function() {
    93                     content.goTo('surveys');
    94                 });
    95                 event.stop(evt);
    96                 return false;
    97             },
    98             _onDiscard: function(evt) {
    99             },
    100             _onShowPreview: function() {
    101                 content.goTo('surveyAdvanced', {uid: store.getIdentity(this.survey)});
    10245            }
    10346        });
Note: See TracChangeset for help on using the changeset viewer.