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

Last change on this file since 397 was 358, checked in by tjcschipper, 13 years ago

Omgevingsbewustzijnde schalingsfunctie

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