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