Ignore:
Timestamp:
03/08/14 22:51:23 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Mark content as dirty to prevent moving away from unsaved data.
  • Better change propagation from lists and our own widgets.
  • Generate notifications for errors and show correct message.
  • Moved all path/url generation to the class stores, not everywhere we use it.
  • Give user always a choice between Save and Save & Close.
  • Better refresh behaviour on form changes and saves.
  • Don't generate duplicate code error when existing object is the one you're storing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/widgets/ListWidget.js

    r443 r490  
    88    "dojo/dnd/Source",
    99    "dojo/dnd/common",
    10     "dojo/dom-construct"
    11 ], function(_Container, _WidgetBase, registry, array, declare, lang, Source, dnd, domConstruct) {
     10    "dojo/dom-construct",
     11    "dojo/on"
     12], function(_Container, _WidgetBase, registry, array, declare, lang, Source, dnd, domConstruct, on) {
    1213    return declare([_WidgetBase,_Container],{
    1314        name: "",
     
    4950            });
    5051            this.source = new this.container(this.domNode,sourceParams);
     52            this.source.on('Drop',lang.hitch(this,'_handleChange'));
    5153        },
    5254        creator: function(item, hint) {
     
    6668                }
    6769            }
     70            on(nodeOrWidget,'change',lang.hitch(this,'_handleChange'));
    6871            var node = nodeOrWidget.domNode ? nodeOrWidget.domNode : nodeOrWidget;
    6972            if ( hint !== "avatar" && node.id !== id ) {
     
    7982        createListElement: null, /* function(id,item){},*/
    8083        _getValueAttr: function() {
    81             return array.map(this.source.getAllNodes(),function(node){
     84            this.value = array.map(this.source.getAllNodes(),function(node){
    8285                var widget = registry.byNode(node);
    8386                if ( widget && "value" in widget ) {
     
    8790                }
    8891            },this);
     92            return this.value;
    8993        },
    9094        _setValueAttr: function(value) {
     
    110114            }
    111115        },
    112         appendItems: function(items) {
     116        appendItems: function(items,forceEvent) {
    113117            this.source.insertNodes(false,items);
     118            if ( forceEvent ) { this._handleChange(); }
    114119        },
    115         appendItem: function(item) {
     120        appendItem: function(item,forceEvent) {
    116121            this.source.insertNodes(false,[item]);
     122            if ( forceEvent ) { this._handleChange(); }
    117123        },
    118         removeItem: function(key) {
     124        removeItem: function(key,forceEvent) {
    119125            array.forEach(array.filter(this.source.getAllNodes(), function(node){
    120126                return node.id === key;
    121127            }), lang.hitch(this, "_destroyNodeOrWidget"));
    122128            this.source.delItem(key);
     129            if ( forceEvent ) { this._handleChange(); }
    123130        },
    124131        getChildren: function() {
     
    127134            }),function(widget){ return widget !== null; });
    128135        },
    129         clear: function() {
     136        clear: function(forceEvent) {
    130137            array.forEach(this.source.getAllNodes(),
    131138                          lang.hitch(this, "_destroyNodeOrWidget"));
    132139            this.source.clearItems();
     140            if ( forceEvent ) { this._handleChange(); }
    133141        },
    134142        _destroyNodeOrWidget: function(node) {
     
    149157            this.source.destroy();
    150158            this.inherited(arguments);
    151         }
     159        },
     160        _handleChange: function() {
     161            this.value = this._getValueAttr();
     162            this.onChange(this.value);
     163        },
     164        onChange: function(value) {}
    152165    });
    153166});
Note: See TracChangeset for help on using the changeset viewer.