source: Dev/branches/rest-dojo-ui/client/rft/ui/ObjectBox.js @ 359

Last change on this file since 359 was 359, checked in by hendrikvanantwerpen, 13 years ago

Application header is link to menu now.
Links in menu page are clickable now.
Added some logic to session page. Simple props can now be edited and saved.
Different actions for session templates and instances in sessions page.
Cleaner code in ObjectBox?. No special cases anymore, scope error fixed.
Fixed scope error in store.js.

File size: 3.2 KB
Line 
1define([
2    'dojo/_base/declare',
3    'dojo/_base/lang',
4    'dijit/_WidgetBase',
5    'dijit/_TemplatedMixin',
6    'dijit/_WidgetsInTemplateMixin',
7    'rft/ui/LineWithActionsWidget',
8    'dojo/text!./templates/ObjectBox.html',
9    ], function(declare, lang, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, LineWithActionsWidget, template){
10        return declare('rft.ui.ObjectBox', [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
11            baseClass: "rftObjectBox",
12            templateString: template,
13            value: null,
14            actions: null,
15            startup: function() {
16                this.line1 = new LineWithActionsWidget({
17                    modifiers: 'green',
18                    actions: {
19                        "inspectIcon": {
20                            callback: lang.hitch(this, this._showInfoBox),
21                            properties: {
22                                blockButton: false,
23                                modifiers: "white",
24                                icon: "Inspect"
25                            }
26                        }
27                    }
28                }).placeAt(this.line1Node);
29                this.line2 = new LineWithActionsWidget({
30                    modifiers: 'green'
31                }).placeAt(this.line1Node);
32                var line3Actions = this._createLine3Actions();
33                this.line3 = new LineWithActionsWidget({
34                    modifiers: 'green',
35                    actions: line3Actions
36                }).placeAt(this.line1Node);
37                this.line1.startup();
38                this.line2.startup();
39                this.line3.startup();
40                this.inherited(arguments);
41            },
42            _createLine3Actions: function() {
43                var line3Actions = {};
44                for (var action in this.actions) {
45                    line3Actions[action] = {
46                        callback: lang.hitch(this, function(callback){
47                            this.value && callback(this.value);
48                        }, this.actions[action]),
49                        properties: {
50                            blockButton: true,
51                            label: action,
52                            modifiers: "trans",
53                            icon: action.charAt(0).toUpperCase()+action.slice(1)
54                        }
55                    };
56                }
57                return line3Actions;
58            },
59            _showInfoBox: function() {
60                alert(this.value.description);
61            },
62            _setValueAttr: function(value) {
63                this.value = value;
64                this._refresh();
65            },
66            _getValueAttr: function(value) {
67                this.value = value;
68            },
69            _refresh: function() {
70                if ( this.value !== null ) {
71                    this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || '');
72                    this.line1.set('title', this.value.title || '');
73                    this.line2.set('title', this.value.subTitle || '');
74                    this.line3.set('title', this.value.lowerTitle || '');
75                }
76            }
77        });
78    });
Note: See TracBrowser for help on using the repository browser.