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/pages/sessions.js

    r353 r359  
    22    function(declare,lang,store,content,_Page,ObjectBox){
    33        return declare('rft.pages.sessions',[_Page],{
    4             selectedObject: null,
     4            templateActions: null,
     5            sessionActions: null,
    56            onVisit: function() {
     7                this.templateActions = {
     8                    "Edit": function(obj){
     9                        content.goTo('session',{uid:store.getIdentity(obj)});
     10                    },
     11                    "Delete": lang.hitch(this,function(obj){
     12                        store.remove(store.getIdentity(obj),store.getRevision(obj))
     13                        .then(lang.hitch(this,function(){
     14                            this._refresh();
     15                        }));
     16                    }),
     17                    "Publish": lang.hitch(this,this._publishSession)
     18                };
     19                this.sessionActions = {
     20                    "Facilitate": function(obj){
     21                        content.goTo('run',{uid:store.getIdentity(obj)});
     22                    },
     23                    "Delete": lang.hitch(this,function(obj){
     24                        store.remove(store.getIdentity(obj),store.getRevision(obj))
     25                        .then(lang.hitch(this,function(){
     26                            this._refresh();
     27                        }));
     28                    })
     29                };
    630                this._refresh();
    731            },
     
    933                this.containerTemplates.set('content','');
    1034                this.containerSessions.set('content','');
    11                 this._refreshByType('SessionTemplate',this.containerTemplates.domNode);
    12                 this._refreshByType('SessionInstance',this.containerSessions.domNode);
     35                this._refreshByType('SessionTemplate',this.containerTemplates.domNode,this.templateActions);
     36                this._refreshByType('SessionInstance',this.containerSessions.domNode,this.sessionActions);
    1337            },
    14             _refreshByType: function(type,container) {
     38            _refreshByType: function(type,container,actions) {
    1539                store.query("_design/default/_view/by_type",{key:type})
    1640                .forEach(lang.hitch(this,function(obj){
    1741                    var widget = new ObjectBox({
    18                         title: obj.title || "Untitled",
    19                         actions: {
    20                             "Edit": function(){alert('Custom edit code');},
    21                             "Delete": lang.hitch(this,function(){
    22                                 store.remove(store.getIdentity(obj),store.getRevision(obj))
    23                                 .then(lang.hitch(this,function(){
    24                                     this._refresh();
    25                                 }));
    26                             }),
    27                             "Custom function": function(){alert('newCommand');},
    28                             "Publish": lang.hitch(this,this._publishSession,obj)
    29                         }
    30                     });
     42                        actions: actions
     43                    }).placeAt(container, "last");
    3144                    widget.startup();
    32                     widget.placeAt(container, "last");
     45                    widget.set('value',obj);
    3346                }));
    3447            },
    3548            onAddSessionTemplate: function(){
    3649                store.put({
    37                     type: 'SessionTemplate',
    38                     title: 'TeamUp Basic Template'
     50                    type: 'SessionTemplate'
    3951                })
    40                 .then(lang.hitch(this,function(){
    41                     this._refresh();
     52                .then(lang.hitch(this,function(obj){
     53                    content.goTo('session',{uid:store.getIdentity(obj)});
    4254                }));
    4355            },
    4456            _publishSession: function(sessionTemplate) {
    4557                var publishDate = new Date();
    46                 var session = {
    47                     type: "SessionInstance",
    48                     title: sessionTemplate.title,
    49                     date: publishDate.getDate()+"-"+publishDate.getMonth()+"-"+publishDate.getFullYear(),
    50                     creator: "Igor Mayer"
    51                 };
     58                var session = lang.clone(sessionTemplate);
     59                delete session[store.idProperty];
     60                delete session[store.revProperty];
     61                session.type = "SessionInstance";
     62                session.date = publishDate.getDate()+"-"+publishDate.getMonth()+"-"+publishDate.getFullYear();
     63                session.creator = "Igor Mayer";
    5264                store.add(session)
    5365                .then(lang.hitch(this,function(){
    5466                    this._refresh();
     67                    this.tabContainer.selectChild(this.sessionsTab);
    5568                }));
    5669            }
Note: See TracChangeset for help on using the changeset viewer.