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

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

[Server] Refactored model classes with some meta-programming. Specific classes only define their fields and inherit from class RdfObject?. Changes to handle the new model objects correctly.
[Client] Added rft/store module for uniform resource access. Removed dependencies on 'uid' field name. Added support for references without loading full object nor exposing uri.
[Client] Added reset() to QuestionWidget?.
[RDFAPI] Fixed PHP warning.

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            postCreate: function() {
6                this._store = store.getStore('Survey');
7            },
8            onVisit: function() {
9                this.grid.setStore(ObjectStore({objectStore: this._store}));
10               
11                this.grid.on('rowclick',lang.hitch(this,function(evt){
12                    this.selectedObject = evt.grid.getItem(evt.rowIndex);
13                    this.btnEdit.set('disabled',!this.selectedObject);
14                }));
15
16                this.grid.on('rowdblclick',lang.hitch(this,function(evt){
17                    var obj = evt.grid.getItem(evt.rowIndex);
18                    content.goTo('/survey',{uid:obj.getUid()});
19                }));
20                               
21                this.btnNew.on('click',lang.hitch(this,function(){
22                    Deferred.when( this._store.add({'creator':auth.getUser()}) )
23                    .then(function(obj) {
24                        content.goTo('/survey',{uid:obj.getUid()});
25                    });
26                }));
27
28                this.btnEdit.on('click',lang.hitch(this,function(){
29                    if ( this.selectedObject ) {
30                        content.goTo('/survey',{uid:this.selectedObject.getUid()});
31                    }
32                   
33                }));
34            }
35        });
36    });
37
Note: See TracBrowser for help on using the repository browser.