Ignore:
Timestamp:
07/23/12 13:07:24 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Seperated question browser in TabbedQuestionBrowser? widget.
Made configuring Selector actions more flexible (both for top actions and item actions).
Fixed lowercase/uppercase problem in SurveyListView?.
Fixed whitespace and toolyip in LineWithActionsWidget?.
Added question browser to questions page. Removed the old dialog that was there and redirect to questionEditor page.

File:
1 edited

Legend:

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

    r369 r370  
    1 define(['dojo/_base/declare',
     1define([
     2    'dojo/_base/declare',
     3    'dojo/_base/Deferred',
     4    'dojo/_base/event',
    25    'dojo/_base/lang',
    3     'dojo/_base/event',
    4     'dojo/_base/Deferred',
    5     'dojo/on',
    6     'rft/ui/Selector',
    7     'rft/ui/SurveyListView',
    8     'dijit/layout/ContentPane',
     6    'rft/content',
    97    'rft/store',
    108    'rft/ui/_Page',
    11     'rft/content',
    12     'dojo/store/Cache',
    13     'dojo/store/Memory' ],
    14     function(declare,lang,event,Deferred,on,Selector,SurveyListView,ContentPane,store,_Page,content,Cache,Memory){
     9    'rft/ui/SurveyListView',
     10    'rft/ui/TabbedQuestionBrowser'
     11    ],
     12    function(declare,Deferred,event,lang,content,store,_Page,SurveyListView,TabbedQuestionBrowser){
    1513        return declare('rft.pages.survey',[_Page],{
    1614            object: null,
     
    2725                        return Deferred.when( obj.creator && store.dereference(obj.creator) );
    2826                    }));
    29                     this._setupButtons();
    3027                    this._setupQuestionBrowser();
    3128                    this._setupListView();
     
    4946                content.goTo('surveyAdvanced', {uid: this.object._id});
    5047            },
    51             _setupButtons: function() {
    52                 this.btnSave.on("click", lang.hitch(this, this.onSave));
    53                 this.btnPreview.on("click", lang.hitch(this, this._goToPreview));
    54             },
    5548            _setupQuestionBrowser: function() {
    56                 this.tabList.watch("selectedChildWidget",lang.hitch(this,function(name,oldTab,newTab){
    57                     this._fillCategoryTab(newTab.__category);
    58                 }));
    59                 store.query('_design/default/_view/questions', {reduce:true,group:true,group_level:1})
    60                 .forPairs(lang.hitch(this,function(value,key){
    61                     this._createCategoryTab(key[0],value);
    62                 }));
    63             },
    64             _createCategoryTab: function(category,count) {
    65                 if (this._dataMap[category] === undefined) {
    66                     var categoryTab = new ContentPane({
    67                         __category: category,
    68                         title: category+" ("+count+")"
    69                     });
    70                     categoryTab.startup();
    71                     this._dataMap[category] = {
    72                         _widget: categoryTab
    73                     };
    74                     this.tabList.addChild(categoryTab);
    75                 }
    76             },
    77             _fillCategoryTab: function(category) {
    78                 var categoryMap = this._dataMap[category];
    79                 if (!categoryMap._filled) {
    80                     categoryMap._filled = true;
    81                     store.query('_design/default/_view/questions', {reduce:true,group:true,group_level:2,startkey:[category],endkey:[category,{}]})
    82                     .forPairs(lang.hitch(this,function(value,key){
    83                         this._createTopicSelector(key[1],category,value);
    84                     }));
    85                 }
    86             },
    87             _createTopicSelector: function(topic,category,count){
    88                 var categoryMap = this._dataMap[category];
    89                 if (categoryMap[topic] === undefined) {
    90                     var w = new Selector({
    91                         __category: category,
    92                         __topic: topic,
    93                         title: topic+" ("+count+")"
    94                     }).placeAt(categoryMap._widget.containerNode);
    95                     w.startup();
    96                     categoryMap[topic] = {
    97                         _widget: w
    98                     };
    99                     this._fillTopicSelector(topic,category);
    100                     w.on('include',lang.hitch(this,this.includeQuestion));
    101                 }
    102             },
    103             _fillTopicSelector: function(topic,category) {
    104                 var categoryMap = this._dataMap[category];
    105                 var topicMap = categoryMap[topic];
    106                 if (!topicMap._filled) {
    107                     store.query('_design/default/_view/questions', {reduce:false,include_docs:true,key:[category,topic]})
    108                     .forEach(lang.hitch(this,function(value){
    109                         topicMap._widget.addItem(value);
    110                     }));
    111                 }
     49                this.questionBrowser = new TabbedQuestionBrowser({
     50                    region: 'center',
     51                    'class': 'blue',
     52                    selectedActions: {
     53                        "Include": {
     54                            callback: lang.hitch(this,this.includeQuestion),
     55                            icon: "Accept",
     56                            description: "Include in survey"
     57                        }
     58                    },
     59                    itemActions: {
     60                        "Info": {
     61                            callback: function(item){ item.description && alert(item.description); },
     62                            icon: "Inspect",
     63                            description: "Show item description"
     64                        }
     65                    }
     66                },this.questionBrowser);
     67                this.questionBrowser.startup();
    11268            },
    11369            /* ListView code */
Note: See TracChangeset for help on using the changeset viewer.