source: Dev/trunk/src/client/qed-client/widgets/LineWithActionsWidget.js @ 490

Last change on this file since 490 was 490, checked in by hendrikvanantwerpen, 11 years ago
  • 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 size: 3.5 KB
Line 
1define(['dojo/_base/declare',
2    'dojo/_base/lang',
3    'dojo/on',
4    'dojo/dom',
5    'dojo/_base/event',
6    'dojo/dom-class',
7    'dijit/form/Button',
8    'dijit/_WidgetBase',
9    'dijit/_TemplatedMixin',
10    'dijit/_WidgetsInTemplateMixin',
11    'dojo/text!./templates/LineWithActionsWidget.html'
12],function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){
13    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
14        templateString: templateString,
15        baseClass: 'rftLineWithActions',
16        title: '',
17        selectable: false,
18        userObject: null,
19
20        actions: null,
21        postCreate: function() {
22            dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection!
23            on(this.domNode,'click',lang.hitch(this,'_onClick'));
24        },
25        startup: function() {
26            if ( this._started ){ return; }
27            this.inherited(arguments);
28            this._setupActions();
29            this.refresh();
30        },
31        _setupActions: function() {
32            if ( this.actions === null ) {
33                return;
34            }
35            for (var action in this.actions) {
36                if ( this.actions.hasOwnProperty(action) ) {
37                    var properties;
38                    if (this.actions[action].properties.blockButton === true) {
39                        properties = lang.mixin({
40                            baseClass: 'rftBlockButton',
41                            label: "Default",
42                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
43                            title: this.actions[action].properties.tooltip,
44                            onClick: lang.hitch(this, function(action, e){
45                                if ( action.callback ) { action.callback(e); }
46                                if ( e ) { event.stop(e); }
47                                return false;
48                            }, this.actions[action])
49                        }, this.actions[action].properties);
50                        new Button(properties).placeAt(this.buttonsNode);
51                    } else {
52                        properties = lang.mixin({
53                            baseClass: 'rftInlineButton',
54                            label: "Default",
55                            showLabel: false,
56                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
57                            title: this.actions[action].properties.tooltip,
58                            onClick: lang.hitch(this, function(action, e){
59                                if ( action.callback ) { action.callback(e); }
60                                if ( e ) { event.stop(e); }
61                                return false;
62                            }, this.actions[action])
63                        }, this.actions[action].properties);
64                        new Button(properties).placeAt(this.buttonsNode);
65                    }
66                }
67            }
68        },
69        refresh: function() {
70            this.titleNode.innerHTML = this.title;
71        },
72        _onClick: function(e){
73            var preventDefault = this.onClick(e) === false;
74            if (preventDefault) {
75                if ( e ) { event.stop(e); }
76            }
77            return !preventDefault;
78        },
79        onClick: function(/*e*/) {
80        },
81        _setTitleAttr: function(value){
82            this.title = value;
83            this.refresh();
84        }
85    });
86});
Note: See TracBrowser for help on using the repository browser.