Last change
on this file since 491 was
491,
checked in by hendrikvanantwerpen, 11 years ago
|
- Include _ObjectPage this time.
- Hash replace doesn't reload page.
- Widget in dialog has name to actually give results.
|
File size:
1.8 KB
|
Line | |
---|
1 | define([ |
---|
2 | "../app/Page", |
---|
3 | "dojo/_base/declare", |
---|
4 | "dojo/_base/event", |
---|
5 | "dojo/_base/lang", |
---|
6 | "require" |
---|
7 | ], function(Page, declare, event, lang, require) { |
---|
8 | return declare([Page],{ |
---|
9 | objectId: null, |
---|
10 | object: null, |
---|
11 | classStore: null, |
---|
12 | constructor: function() { |
---|
13 | if ( !this.classStore ) { throw new Error("Subclasses must specify a classStore."); } |
---|
14 | }, |
---|
15 | _load: function() { |
---|
16 | if ( this.object ) { |
---|
17 | this._refresh(); |
---|
18 | } else if ( this.objectId ) { |
---|
19 | if ( this.objectId === "new" ) { |
---|
20 | this.object = this.classStore.create(); |
---|
21 | this._refresh(); |
---|
22 | } else { |
---|
23 | this.classStore.load(this.objectId) |
---|
24 | .then(lang.hitch(this,'_setObject'), |
---|
25 | lang.hitch(this,function(err){ |
---|
26 | this.die(err.error); |
---|
27 | })); |
---|
28 | } |
---|
29 | } else { |
---|
30 | this.die("No valid uid or object passed!"); |
---|
31 | } |
---|
32 | }, |
---|
33 | _setObject: function(object) { |
---|
34 | this.object = object; |
---|
35 | if ( this.objectId === "new" ) { |
---|
36 | this.go(this.classStore.getObjectPath(this.object),{},true); |
---|
37 | } |
---|
38 | this._refresh(); |
---|
39 | }, |
---|
40 | _refresh: function() {}, |
---|
41 | _save: function() { |
---|
42 | return this.classStore.save(this.object) |
---|
43 | .then(lang.hitch(this,function(object){ |
---|
44 | this.markClean(); |
---|
45 | this._setObject(object); |
---|
46 | this.notify(this.classStore.getName()+" successfully saved."); |
---|
47 | }),lang.hitch(this,function(e){ |
---|
48 | this.notify(e.error,'error'); |
---|
49 | })); |
---|
50 | } |
---|
51 | }); |
---|
52 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.