Changeset 407 for Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
- Timestamp:
- 09/05/12 14:41:13 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui
- Property svn:ignore
-
old new 1 1 nbproject 2 2 .project 3 release
-
- Property svn:ignore
-
Dev/branches/rest-dojo-ui/client
- Property svn:externals
-
old new 1 dojotoolkit http://svn.dojotoolkit.org/src/tags/release-1.8.0 1 dojo http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojo 2 dijit http://svn.dojotoolkit.org/src/tags/release-1.8.0/dijit 3 dojox http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojox 4 util http://svn.dojotoolkit.org/src/tags/release-1.8.0/util
-
- Property svn:externals
-
Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
r384 r407 3 3 'dojo/_base/lang', 4 4 'dojo/date/stamp', 5 'rft/store', 6 'rft/content', 7 'rft/ui/_Page', 8 'rft/ui/ObjectBox'], 9 function(declare,lang,dateStamp,store,content,_Page,ObjectBox){ 10 return declare('rft.pages.sessions',[_Page],{ 11 templateActions: null, 12 sessionActions: null, 13 onVisit: function() { 14 this.templateActions = { 15 "Edit": function(obj){ 16 content.goTo('session',{uid:store.getIdentity(obj)}); 17 }, 18 "Delete": lang.hitch(this,function(obj){ 19 store.remove(store.getIdentity(obj),store.getRevision(obj)) 20 .then(lang.hitch(this,function(){ 21 this._refresh(); 22 })); 23 }), 24 "Publish": lang.hitch(this,this._publishSession) 25 }; 26 this.sessionActions = { 27 "Facilitate": function(obj){ 28 content.goTo('run',{uid:store.getIdentity(obj)}); 29 }, 30 "Delete": lang.hitch(this,function(obj){ 31 store.remove(store.getIdentity(obj),store.getRevision(obj)) 32 .then(lang.hitch(this,function(){ 33 this._refresh(); 34 })); 35 }) 36 }; 5 '../store', 6 '../app/Controller', 7 '../app/Page', 8 '../ui/ObjectBox', 9 'dojo/text!./sessions.html' 10 ],function(declare,lang,dateStamp,store,Controller,Page,ObjectBox,template){ 11 return declare([Page],{ 12 templateString: template, 13 templateActions: null, 14 sessionActions: null, 15 startup: function() { 16 if ( this._started ) { return; } 17 this.inherited(arguments); 18 this.templateActions = { 19 "Edit": function(obj){ 20 Controller.go('/session/'+store.getIdentity(obj)); 21 }, 22 "Delete": lang.hitch(this,function(obj){ 23 store.remove(store.getIdentity(obj),store.getRevision(obj)) 24 .then(lang.hitch(this,function(){ 25 this._refresh(); 26 })); 27 }), 28 "Publish": lang.hitch(this,this._publishSession) 29 }; 30 this.sessionActions = { 31 "Facilitate": function(obj){ 32 Controller.go('run',{uid:store.getIdentity(obj)}); 33 }, 34 "Delete": lang.hitch(this,function(obj){ 35 store.remove(store.getIdentity(obj),store.getRevision(obj)) 36 .then(lang.hitch(this,function(){ 37 this._refresh(); 38 })); 39 }) 40 }; 41 this._refresh(); 42 }, 43 _refresh: function() { 44 this.containerTemplates.set('content',''); 45 this.containerSessions.set('content',''); 46 this._refreshByType('SessionTemplate',this.containerTemplates.domNode,this.templateActions); 47 this._refreshByType('SessionInstance',this.containerSessions.domNode,this.sessionActions); 48 }, 49 _refreshByType: function(type,container,actions) { 50 store.query("_design/default/_view/by_type",{key:type}) 51 .forEach(lang.hitch(this,function(obj){ 52 var widget = new ObjectBox({ 53 actions: actions 54 }).placeAt(container, "last"); 55 widget.startup(); 56 widget.set('value',obj); 57 })); 58 }, 59 onAddSessionTemplate: function(){ 60 store.put({ 61 type: 'SessionTemplate' 62 }) 63 .then(lang.hitch(this,function(obj){ 64 Controller.go('/session/'+store.getIdentity(obj)); 65 })); 66 }, 67 _publishSession: function(sessionTemplate) { 68 var session = lang.clone(sessionTemplate); 69 delete session[store.idProperty]; 70 delete session[store.revProperty]; 71 session.type = "SessionInstance"; 72 session.publishedDate = dateStamp.toISOString(new Date(),{zulu: true}); 73 session.creator = "Igor Mayer"; 74 store.add(session) 75 .then(lang.hitch(this,function(){ 37 76 this._refresh(); 38 }, 39 _refresh: function() { 40 this.containerTemplates.set('content',''); 41 this.containerSessions.set('content',''); 42 this._refreshByType('SessionTemplate',this.containerTemplates.domNode,this.templateActions); 43 this._refreshByType('SessionInstance',this.containerSessions.domNode,this.sessionActions); 44 }, 45 _refreshByType: function(type,container,actions) { 46 store.query("_design/default/_view/by_type",{key:type}) 47 .forEach(lang.hitch(this,function(obj){ 48 var widget = new ObjectBox({ 49 actions: actions 50 }).placeAt(container, "last"); 51 widget.startup(); 52 widget.set('value',obj); 53 })); 54 }, 55 onAddSessionTemplate: function(){ 56 store.put({ 57 type: 'SessionTemplate' 58 }) 59 .then(lang.hitch(this,function(obj){ 60 content.goTo('session',{uid:store.getIdentity(obj)}); 61 })); 62 }, 63 _publishSession: function(sessionTemplate) { 64 var session = lang.clone(sessionTemplate); 65 delete session[store.idProperty]; 66 delete session[store.revProperty]; 67 session.type = "SessionInstance"; 68 session.publishedDate = dateStamp.toISOString(new Date(),{zulu: true}); 69 session.creator = "Igor Mayer"; 70 store.add(session) 71 .then(lang.hitch(this,function(){ 72 this._refresh(); 73 this.tabContainer.selectChild(this.sessionsTab); 74 })); 75 } 76 }); 77 this.tabContainer.selectChild(this.sessionsTab); 78 })); 79 } 77 80 }); 78 81 });
Note: See TracChangeset
for help on using the changeset viewer.