Ignore:
Timestamp:
09/03/12 18:14:37 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Lots of small fixes.

Make it possible to read survey answers (when a question code is
provided), it is now displayed in place of the survey. More to come.

Some whitespace fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/ui/ObjectBox.js

    r405 r406  
    77    'rft/ui/LineWithActionsWidget',
    88    '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                 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"
    25                             }
     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            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"
    2625                        }
    2726                    }
    28                 }).placeAt(this.line1Node);
    29                 this.line2 = new LineWithActionsWidget({
    30                 }).placeAt(this.line1Node);
    31                 var line3Actions = this._createLine3Actions();
    32                 this.line3 = new LineWithActionsWidget({
    33                     actions: line3Actions
    34                 }).placeAt(this.line1Node);
    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){
    45                             this.value && callback(this.value);
    46                         }, this.actions[action]),
    47                         properties: {
    48                             blockButton: true,
    49                             label: action,
    50                             icon: action.charAt(0).toUpperCase()+action.slice(1)
    51                         }
    52                     };
    5327                }
    54                 return line3Actions;
    55             },
    56             _showInfoBox: function() {
    57                 alert(this.value.description);
    58             },
    59             _setValueAttr: function(value) {
    60                 this.value = value;
    61                 this._refresh();
    62             },
    63             _getValueAttr: function(value) {
    64                 this.value = value;
    65             },
    66             _refresh: function() {
    67                 if ( this.value !== null ) {
    68                     this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || '');
    69                     this.line1.set('title', this.value.title || '');
    70                     this.line2.set('title', this.value.subTitle || '');
    71                     this.line3.set('title', this.value.lowerTitle || '');
    72                 }
     28            }).placeAt(this.line1Node);
     29            this.line2 = new LineWithActionsWidget({
     30            }).placeAt(this.line1Node);
     31            var line3Actions = this._createLine3Actions();
     32            this.line3 = new LineWithActionsWidget({
     33                actions: line3Actions
     34            }).placeAt(this.line1Node);
     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){
     45                        this.value && callback(this.value);
     46                    }, this.actions[action]),
     47                    properties: {
     48                        blockButton: true,
     49                        label: action,
     50                        icon: action.charAt(0).toUpperCase()+action.slice(1)
     51                    }
     52                };
    7353            }
    74         });
     54            return line3Actions;
     55        },
     56        _showInfoBox: function() {
     57            alert(this.value.description);
     58        },
     59        _setValueAttr: function(value) {
     60            this.value = value;
     61            this._refresh();
     62        },
     63        _getValueAttr: function(value) {
     64            this.value = value;
     65        },
     66        _refresh: function() {
     67            if ( this.value !== null ) {
     68                this.iconNode.className = "rftIcon typeIcon rftIcon"+(this.value.type || '');
     69                this.line1.set('title', this.value.title || '');
     70                this.line2.set('title', this.value.subTitle || '');
     71                this.line3.set('title', this.value.lowerTitle || '');
     72            }
     73        }
     74    });
    7575});
Note: See TracChangeset for help on using the changeset viewer.