source: Dev/trunk/src/client/qed-client/widgets/ObjectBox.js @ 513

Last change on this file since 513 was 513, checked in by hendrikvanantwerpen, 11 years ago
  • Another shot at getting change events right for _ComplexValueMixin. Our previous approach made it impossible to detect if a change was cause during startup. Now we work purely with widget 'change' events. Children are connected during postCreate, addChild. If you add children otherwise you need to call connectChildsChanges yourself. Also to make sure events are generated, use _setValueInternal if you really need to set the value attribute yourself.
  • Removed unused widget.
File size: 2.4 KB
Line 
1define([
2    "../lib/object",
3    "./LineWithActionsWidget",
4    "./_ComplexValueWidget",
5    "dijit/_TemplatedMixin",
6    "dijit/_WidgetBase",
7    "dijit/_WidgetsInTemplateMixin",
8    "dojo/_base/declare",
9    "dojo/_base/lang",
10    "dojo/text!./templates/ObjectBox.html"
11], function(objectFuns, LineWithActionsWidget, _ComplexValueWidget, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, declare, lang, template) {
12    return declare([_ComplexValueWidget], {
13        baseClass: "rftObjectBox",
14        templateString: template,
15        actions: null,
16        startup: function() {
17            if ( this._started ){ return; }
18            this.inherited(arguments);
19            this.line1 = new LineWithActionsWidget({
20                actions: {
21                    "inspectIcon": {
22                        callback: lang.hitch(this, this._showInfoBox),
23                        properties: {
24                            blockButton: false,
25                            icon: "Inspect"
26                        }
27                    }
28                }
29            }).placeAt(this.line1Node);
30            this.line2 = new LineWithActionsWidget({
31            }).placeAt(this.line2Node);
32            var line3Actions = this._createLine3Actions();
33            this.line3 = new LineWithActionsWidget({
34                actions: line3Actions
35            }).placeAt(this.line3Node);
36            this.line1.startup();
37            this.line2.startup();
38            this.line3.startup();
39            this.inherited(arguments);
40        },
41        _createLine3Actions: function() {
42            return objectFuns.map(this.actions,function(value,name){
43                return {
44                    callback: lang.hitch(this, function(callback){
45                        if ( this.value ) { callback(this.value); }
46                    }, value),
47                    properties: {
48                        blockButton: true,
49                        label: name,
50                        icon: name.charAt(0).toUpperCase()+name.slice(1)
51                    }
52                };
53            },this);
54        },
55        _showInfoBox: function() {},
56        onChange: function(value) {
57            if ( value ) {
58                this.iconNode.className = "rftIcon typeIcon rftIcon"+(value.type || '');
59                this.line1.set('title', value.title || '');
60                this.line2.set('title', value.subTitle || '');
61                this.line3.set('title', value.lowerTitle || '');
62            }
63        }
64    });
65});
Note: See TracBrowser for help on using the repository browser.