Changeset 359 for Dev/branches/rest-dojo-ui/client/rft/pages/index.js
- Timestamp:
- 07/12/12 17:07:35 (13 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/index.js
r358 r359 1 define(['dojo/_base/declare','dojo/_base/lang','rft/ store','rft/content','rft/ui/_Page','rft/ui/ObjectBox'],2 function(declare,lang, store,content,_Page,ObjectBox){3 return declare('rft.pages. sessions',[_Page],{1 define(['dojo/_base/declare','dojo/_base/lang','rft/content','rft/ui/_Page'], 2 function(declare,lang,content,_Page){ 3 return declare('rft.pages.index',[_Page],{ 4 4 selectedObject: null, 5 5 onVisit: function() { 6 this._refresh(); 7 }, 8 _refresh: function() { 9 this.containerTemplates.set('content',''); 10 this.containerSessions.set('content',''); 11 this._refreshByType('SessionTemplate',this.containerTemplates.domNode); 12 this._refreshByType('SessionInstance',this.containerSessions.domNode); 13 }, 14 _refreshByType: function(type,container) { 15 store.query("_design/default/_view/by_type",{key:type}) 16 .forEach(lang.hitch(this,function(obj){ 17 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 }); 31 widget.startup(); 32 widget.placeAt(container, "last"); 33 })); 34 }, 35 onAddSessionTemplate: function(){ 36 store.put({ 37 type: 'SessionTemplate', 38 title: 'TeamUp Basic Template' 39 }) 40 .then(lang.hitch(this,function(){ 41 this._refresh(); 42 })); 43 }, 44 _publishSession: function(sessionTemplate) { 45 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 }; 52 store.add(session) 53 .then(lang.hitch(this,function(){ 54 this._refresh(); 55 })); 6 this.btnContentCreate.on("click",function(){ content.goTo("sessions"); }); 7 this.btnContentFacilitate.on("click",function(){ content.goTo("run"); }); 8 this.btnSurveys.on("click",function(){ content.goTo("surveys"); }); 9 this.btnQuestions.on("click",function(){ content.goTo("questions"); }); 10 this.btnApplications.on("click",function(){ content.goTo("applications"); }); 11 this.btnDashboards.on("click",function(){ content.goTo("dashboards"); }); 12 this.btnResults.on("click",function(){ content.goTo("results"); }); 56 13 } 57 14 });
Note: See TracChangeset
for help on using the changeset viewer.