Changeset 359 for Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
- Timestamp:
- 07/12/12 17:07:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
r353 r359 2 2 function(declare,lang,store,content,_Page,ObjectBox){ 3 3 return declare('rft.pages.sessions',[_Page],{ 4 selectedObject: null, 4 templateActions: null, 5 sessionActions: null, 5 6 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 }; 6 30 this._refresh(); 7 31 }, … … 9 33 this.containerTemplates.set('content',''); 10 34 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); 13 37 }, 14 _refreshByType: function(type,container ) {38 _refreshByType: function(type,container,actions) { 15 39 store.query("_design/default/_view/by_type",{key:type}) 16 40 .forEach(lang.hitch(this,function(obj){ 17 41 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"); 31 44 widget.startup(); 32 widget. placeAt(container, "last");45 widget.set('value',obj); 33 46 })); 34 47 }, 35 48 onAddSessionTemplate: function(){ 36 49 store.put({ 37 type: 'SessionTemplate', 38 title: 'TeamUp Basic Template' 50 type: 'SessionTemplate' 39 51 }) 40 .then(lang.hitch(this,function( ){41 this._refresh();52 .then(lang.hitch(this,function(obj){ 53 content.goTo('session',{uid:store.getIdentity(obj)}); 42 54 })); 43 55 }, 44 56 _publishSession: function(sessionTemplate) { 45 57 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"; 52 64 store.add(session) 53 65 .then(lang.hitch(this,function(){ 54 66 this._refresh(); 67 this.tabContainer.selectChild(this.sessionsTab); 55 68 })); 56 69 }
Note: See TracChangeset
for help on using the changeset viewer.