Ignore:
Timestamp:
07/12/12 17:07:35 (13 years ago)
Author:
hendrikvanantwerpen
Message:

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:
1 edited

Legend:

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

    r350 r359  
    1111            baseClass: "rftObjectBox",
    1212            templateString: template,
    13            
    14             constructor: function() {
    15                 this.title = "";
    16                 this.subTitle = "";
    17                 this.lowerTitle = "";
    18                 this.objectType = "SessionTemplate";
    19                 this.actions = {}
    20                
    21             },
    22             postCreate: function() {
     13            value: null,
     14            actions: null,
     15            startup: function() {
    2316                this.line1 = new LineWithActionsWidget({
    24                     title: this.title || "Untitled",
    2517                    modifiers: 'green',
    2618                    actions: {
    2719                        "inspectIcon": {
    28                             callback: lang.hitch(this, "_inspectObject"),
     20                            callback: lang.hitch(this, this._showInfoBox),
    2921                            properties: {
    3022                                blockButton: false,
     
    3628                }).placeAt(this.line1Node);
    3729                this.line2 = new LineWithActionsWidget({
    38                     title: this.subTitle || "",
    39                     modifiers: 'green',
    40                     actions: {}
     30                    modifiers: 'green'
    4131                }).placeAt(this.line1Node);
    4232                var line3Actions = this._createLine3Actions();
    4333                this.line3 = new LineWithActionsWidget({
    44                     title: this.lowerTitle || "",
    4534                    modifiers: 'green',
    4635                    actions: line3Actions
     
    5241            },
    5342            _createLine3Actions: function() {
    54                 var ac = {};
    55                 if (this.actions["edit"]) {
    56                     ac["edit"] = {
    57                         callback: lang.hitch(this, "_editObject", this.actions["edit"]),
    58                         properties: {
    59                             blockButton: true,
    60                             label: "Edit/View",
    61                             modifiers: "trans",
    62                             icon: "Edit"
    63                         }
    64                     };
    65                     delete this.actions["edit"];
    66                 }
    67                 if (this.actions["delete"]) {
    68                     ac["delete"] = {
    69                         callback: lang.hitch(this, "_deleteObject", this.actions["delete"]),
    70                         properties: {
    71                             blockButton: true,
    72                             label: "Delete",
    73                             modifiers: "trans",
    74                             icon: "Delete"
    75                         }
    76                     };
    77                     delete this.actions["delete"];
    78                 }
    79                 for (action in this.actions) {
    80                     ac[action] = {
    81                         callback: lang.hitch(this, this.actions[action]),
     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]),
    8249                        properties: {
    8350                            blockButton: true,
     
    8653                            icon: action.charAt(0).toUpperCase()+action.slice(1)
    8754                        }
    88                     }
     55                    };
    8956                }
    90                 return ac;
     57                return line3Actions;
    9158            },
    92            
    93             _setObjectReference: function(identifier) {
    94             // TODO: Set this ObjectBox to refer to a certain database object
    95         },
    96         _getObjectInfo: function() {
    97             // TODO: Query the database and retrieve a JSON array of object properties
    98         },
    99         _inspectObject: function() {
    100             // TODO: Get object information (or retrieve from cache), then display in popup
    101         },
    102         _editObject: function(customFunction) {
    103             // TODO: Pass an edit call to the page script, along with reference to the object contained in this ObjectBox
    104             alert("Default edit code");
    105             customFunction();
    106         },
    107         _deleteObject: function(customFunction) {
    108             // TODO: Pass a delete call to the page script, along with reference to the object contained in this ObjectBox
    109             customFunction();
    110         },
    111            
    112            
    113         _setTitleAttr: function(value) {
    114             this.title = value;
    115             if (this.line1 && this.line1.set) {
    116                 this.line1.set('title', this.title);
     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                }
    11776            }
    118         },
    119         _setSubTitleAttr: function(value) {
    120             this.subTitle = value;
    121             if (this.line2 && this.line2.set) {
    122                 this.line2.set('title', this.subTitle);
    123             }
    124         },
    125         _setLowerTitleAttr: function(value) {
    126             this.lowerTitle = value;
    127             if (this.line3 && this.line3.set) {
    128                 this.line3.set('title', this.lowerTitle);
    129             }
    130         },
    131         _setObjectTypeAttr: function(value) {
    132             this.objectType = value;
    133             this.iconNode.className = "rftIcon typeIcon rftIcon"+this.objectType;
    134         },
    135 
    136         /* This is an experiment to embed the creation function in the ObjectBox class itself. This method cannot be static, but can be called externally as such:
    137          * rft.ui.ObjectBox().CreateNew(args, ref, loc);
    138          * TODO: Check with Hendrik if I should do this or not!
    139          * */
    140          CreateNew: function(arguments, reference, location) {
    141             var newBox = new rft.ui.ObjectBox(arguments);
    142             newBox.startup();
    143             newBox.placeAt(reference, location);
    144         }
     77        });
    14578    });
    146 });
Note: See TracChangeset for help on using the changeset viewer.