Ignore:
Timestamp:
03/12/14 15:16:54 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Factored out general object mapping and iteration.
  • Split widgets for multiplechoice and singlechoice.
  • Restored readOnly/disabled setting for QuestionEditorPreviewItem? on innerWidget (since view innerWidget is not a form anymore, we cannot just set it on that, we iterate over all form children now).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/widgets/Selector.js

    r495 r510  
    11define([
     2    "../lib/object",
    23    "./LineWithActionsWidget",
    34    "dijit/_Container",
     
    1617    "dojo/query",
    1718    "dojo/text!./templates/Selector.html"
    18 ], function(LineWithActionsWidget, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, registry, baseArray, declare, event, lang, Source, domClass, domConstruct, fx, query, templateString) {
     19], function(objectFuns, LineWithActionsWidget, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, registry, baseArray, declare, event, lang, Source, domClass, domConstruct, fx, query, templateString) {
    1920
    2021    function get(selector, item) {
     
    6263        },
    6364        _createTitleLine: function() {
    64             var actions = {};
    65             var action = null;
    6665            var userActions =
    6766                    lang.isFunction(this.selectedActions) ?
    6867                    this.selectedActions() :
    6968                    this.selectedActions;
    70             if ( userActions ) {
    71                 for (var actionName in userActions) {
    72                     if ( userActions.hasOwnProperty(actionName) ) {
    73                         action = userActions[actionName];
    74                         actions[actionName] = {
    75                             callback: action.callback &&
    76                                       lang.hitch(this,this._onSelectedAction,
    77                                                  action.callback),
    78                             properties: {
    79                                 blockButton: true,
    80                                 label: action.title || actionName,
    81                                 icon: action.icon,
    82                                 tooltip: action.description
    83                             }
    84 
    85                         };
    86                     }
    87                 }
    88             }
    89 
     69
     70            var actions = objectFuns.map(userActions||{},function(action,actionName){
     71                return {
     72                    callback: action.callback &&
     73                              lang.hitch(this,this._onSelectedAction,
     74                                         action.callback),
     75                    properties: {
     76                        blockButton: true,
     77                        label: action.title || actionName,
     78                        icon: action.icon,
     79                        tooltip: action.description
     80                    }
     81
     82                };
     83            }, this);
    9084            this._titleLine = new LineWithActionsWidget({
    9185                title: this.title,
     
    205199        },
    206200        _createLineNode: function(item) {
    207             var actions = {};
    208201            var userActions =
    209202                    lang.isFunction(this.itemActions) ?
    210203                    this.itemActions(item) :
    211204                    this.itemActions;
    212             if (userActions) {
    213                 for (var actionName in userActions) {
    214                     if ( userActions.hasOwnProperty(actionName) ) {
    215                         var action = userActions[actionName];
    216                         actions[actionName] = {
    217                             callback: action.callback &&
    218                                       lang.partial(action.callback,item,this),
    219                             properties: {
    220                                 blockButton: false,
    221                                 showLabel: false,
    222                                 icon: action.icon + " black",
    223                                 tooltip: action.description
    224                             }
    225                         };
    226                     }
    227                 }
    228             }
     205            var actions = objectFuns.map(userActions||{},function(action,actionName){
     206                return {
     207                    callback: action.callback &&
     208                              lang.partial(action.callback,item,this),
     209                    properties: {
     210                        blockButton: false,
     211                        showLabel: false,
     212                        icon: action.icon + " black",
     213                        tooltip: action.description
     214                    }
     215                };
     216            }, this);
    229217            var w = new LineWithActionsWidget({
    230218                title: get(this.itemTitle,item),
Note: See TracChangeset for help on using the changeset viewer.