Ignore:
Timestamp:
07/29/12 00:03:52 (13 years ago)
Author:
hendrikvanantwerpen
Message:
  • Cleanup of the differen ListViews?, List & OrderedList?. Based QuestionListView? on these base classes as well. Removed duplicate code.
  • Destroy busy indicator of TabbedQuestionBrowser? (because it's placed outside of the widgets DOM tree, this is not done automatically).
  • Use dojo/date/stamp module for uniform and parsable date formatting.
  • Added docs/ directory for database format documentation etc.
File:
1 edited

Legend:

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

    r374 r384  
    22    'dojo/_base/declare',
    33    'dojo/_base/lang',
     4    'dojo/dnd/Source',
     5    'dijit/_Container',
     6    'dijit/_TemplatedMixin',
    47    'dijit/_WidgetBase',
    5     'dijit/_TemplatedMixin',
    68    'dijit/_WidgetsInTemplateMixin',
    7     'dijit/_Container',
    8     'rft/ui/LineWithActionsWidget',
     9    'dijit/registry',
    910    'dojo/text!./templates/List.html'
    1011    ],function(
    1112        declare,
    1213        lang,
     14        Source,
     15        _Container,
     16        _TemplatedMixin,
    1317        _WidgetBase,
    14         _TemplatedMixin,
    1518        _WidgetsInTemplateMixin,
    16         _Container,
    17         LineWithActionsWidget,
     19        registry,
    1820        templateString
    1921        ){
     
    2224            baseClass: 'rftList',
    2325            removeCallback: null,
    24             creator: null,
    25 
    26             constructor: function() {
    27                 lang.mixin(this, arguments);
    28             },
     26            type: 'text',
     27            source: null,
    2928
    3029            postCreate: function() {
     
    3534                }
    3635
    37                 this.source = new dojo.dnd.Source(this.sourceNode, {
    38                     isSource: false,
    39                     accept: ["LineListViewItem"],
     36                this.source = new Source(this.sourceNode, {
     37                    accept: [this.type],
    4038                    horizontal: false,
    41                     withHandles: false,
    42                     selfCopy: false,
    43                     selfAccept: true,
    44                     delay: 0,
    4539                    singular: true,
    46                     creator: lang.hitch(this, this.creatorMethod)
    47                 })
     40                    creator: lang.hitch(this, this._createNode)
     41                });
    4842            },
    4943
    50             removeItem: function(item, widget) {
    51                 widget.destroy();
    52                 if(this.removeCallback)
    53                     this.removeCallback(item);
     44            _createNode: function(item, hint) {
     45                var node = hint === "avatar" ?
     46                        this._createAvatarNode(item) : this._createListNode(item);
     47                return {
     48                    node: node,
     49                    data: item,
     50                    type: this.type
     51                };
     52            },
     53            _createListNode: function(item) {},
     54            _createAvatarNode: function(item) {},
     55
     56            appendItem: function(item) {
     57                this.source.insertNodes(false,[item]);
    5458            },
    5559
    56             insertItem: function(item) {
    57                 this.source.insertNodes(false, [item]);
     60            getItems: function() {
     61                return this.source.getAllNodes()
     62                .map(function(node){
     63                    return this.source.getItem(node.id).data;
     64                },this);
     65            },
     66
     67            deleteItems: function() {
     68                this.source.getAllNodes()
     69                .forEach(function(node){
     70                    registry.byNode(node).destroy();
     71                });
     72                this.source.sync();
     73            },
     74
     75            removeItem: function(item){
     76                this.source.getAllNodes()
     77                .filter(lang.hitch(this,function(node){
     78                    return this.source.getItem(node.id).data === item;
     79                }))
     80                .forEach(lang.hitch(this,function(node){
     81                    registry.byNode(node).destroy();
     82                    this.removeCallback && this.removeCallback(item);
     83                }));
     84                this.source.sync();
    5885            }
    5986
Note: See TracChangeset for help on using the changeset viewer.