Ignore:
Timestamp:
03/06/12 13:07:13 (13 years ago)
Author:
hendrikvanantwerpen
Message:

[Client] Refactored AccordionList? as seperate widget.
[Server] Manually add namespaces to model, to prevent missing namespace errors.

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

Legend:

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

    r288 r305  
    22    <h1>Questions</h1>
    33    <div data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onNewQuestion">New question</div>
    4     <div data-dojo-type="rft.ui.TitleGroup" data-rft-attach-point="accordion">
     4    <div data-rft-attach-point="list">
    55    </div>
    66    <div data-dojo-type="dijit.Dialog" title="Question" data-rft-attach-point="questionDialog">
  • Dev/branches/rest-dojo-ui/client/rft/pages/questions.js

    r303 r305  
    1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event',
    2     'dojo/_base/Deferred','dojo/dom-construct','rft/store','dijit/TitlePane',
    3     'rft/ui/_Page','rft/ui/LineWithActionsWidget'],
    4     function(declare,lang,array,event,Deferred,domConstruct,store,TitlePane,_Page,LineWithActionsWidget) {
     1define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event',
     2    'dojo/_base/Deferred','rft/store','rft/ui/_Page','rft/ui/AccordionList'],
     3    function(declare,lang,event,Deferred,store,_Page,AccordionList) {
    54        return declare('rft.pages.questions',[_Page],{
    65            constructor: function() {
     
    98            },
    109            onVisit: function() {
    11                 this._store = store.getStore('Question');               
    12                 this._refresh(true);
     10                this._store = store.getStore('Question');
     11                this._list = new AccordionList({
     12                    store: this._store,
     13                    actions: {
     14                        'Edit': lang.hitch(this,'_editQuestion')
     15                    },
     16                    categoryProperty: 'category',
     17                    titleProperty: 'title'
     18                },this.list);
     19                this._list.startup();
     20                this._refresh();
    1321            },
    14             _refresh: function(initial) {
    15                 Deferred.when( this._store.query() )
    16                 .then(lang.hitch(this,function(results){
    17                     array.forEach(results,lang.hitch(this,'_addQuestion'));
    18                     initial && this.accordion.selectChild(true);
    19                 }));
    20             },
    21             _addQuestion: function(q) {
    22                 var uid = q.getUid();
    23                 var question = this.questions[uid];
    24                 if ( !question ) {
    25                     var qw = new LineWithActionsWidget({
    26                         title: q.title,
    27                         userObject: q,
    28                         actions: {
    29                             'Edit': lang.hitch(this,'_editQuestion')
    30                         }
    31                     });
    32                     qw.startup();
    33                     question = this.questions[uid] = {
    34                         question: q,
    35                         widget: qw
    36                     }
    37                 } else {
    38                     // update info
    39                     question.question = q;
    40                     question.widget.title = q.title;
    41                     question.widget.userObject = q;
    42                     question.widget.refresh();
    43                 }
    44                 var container = this._getContainerForQuestion(q);
    45                 question.widget.placeAt(container.containerNode);
    46                 this._cleanupEmptyContainers();
    47             },
    48             _getContainerForQuestion: function(q) {
    49                 var category = q.category || 'Unsorted';
    50                 var widgets = this.accordion.getChildren();
    51                 var containerWidget = null;
    52                 var placeNode = this.accordion.domNode;
    53                 var placePos = 'last';
    54                 array.some(widgets,lang.hitch(this,function(widget) {
    55                     if ( widget.title == category ) {
    56                         containerWidget = widget;
    57                         return true;
    58                     } else if ( widget.title > category  ) {
    59                         placeNode = widget.domNode;
    60                         placePos = "before";
    61                         return true;
    62                     }
    63                     return false;
    64                 }));
    65                 if ( !containerWidget ) {
    66                     containerWidget = new TitlePane({
    67                         title:category
    68                     });
    69                     containerWidget.startup();
    70                     domConstruct.place(containerWidget.domNode,placeNode,placePos);
    71                 }
    72                 return containerWidget;
    73             },
    74             _cleanupEmptyContainers: function() {
    75                 var widgets = this.accordion.getChildren();
    76                 array.forEach(widgets,lang.hitch(this,function(widget){
    77                     if ( !widget.getChildren().length ) {
    78                         this.accordion.removeChild(widget).destroy();
    79                     }
    80                 }));
     22            _refresh: function() {
     23                this._list.refresh();
    8124            },
    8225            onNewQuestion: function() {
  • Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js

    r303 r305  
    2828                var value = this.ourForm.get('value');
    2929                lang.mixin(this.value,value);
    30                 return this._question;
     30                return this.value;
    3131            },
    3232            _onTypeChange: function(type) {
Note: See TracChangeset for help on using the changeset viewer.