source: Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js @ 292

Last change on this file since 292 was 292, checked in by hendrikvanantwerpen, 13 years ago

[Client] Added surveys list and survey details skeleton pages.
[Client] Changed method of passing parameters to pages. This still feels clumsy, because we're working against Dojo a bit with this.
[Server] Integrated REST resources for collections and objects, since they shared more than they differed.

File size: 1.6 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/store/JsonRest','dojo/data/ObjectStore','rft/content','rft/ui/_Page'],
2    function(declare,lang,JsonRest,ObjectStore,content,_Page){
3        return declare('rft.pages.surveys',[_Page],{
4            selectedObject: null,
5            postCreate: function() {
6                this._store = new JsonRest({
7                    target:"../server/api.php/data/Survey/",
8                    idProperty: 'uid'
9                });
10            },
11            onVisit: function() {
12                this.grid.setStore(ObjectStore({objectStore: this._store}));
13               
14                this.grid.on('rowclick',lang.hitch(this,function(evt){
15                    this.selectedObject = evt.grid.getItem(evt.rowIndex);
16                    this.btnEdit.set('disabled',!!this.selectedObject);
17                }));
18
19                this.grid.on('rowdblclick',lang.hitch(this,function(evt){
20                    var obj = evt.grid.getItem(evt.rowIndex);
21                    content.goTo('/survey',{uid:obj.uid});
22                }));
23               
24                this.btnNew.on('click',lang.hitch(this,function(){
25                    this._store.add({},function(obj) {
26                        content.goTo('/survey',{uid:this.selectedObject.uid});
27                    });
28                }));
29
30                this.btnEdit.on('click',lang.hitch(this,function(){
31                    if ( this.selectedObject ) {
32                        content.goTo('/survey',{uid:this.selectedObject.uid});
33                    }
34                   
35                }));
36            }
37        });
38    });
39
Note: See TracBrowser for help on using the repository browser.