Last change
on this file was
490,
checked in by hendrikvanantwerpen, 11 years ago
|
- Mark content as dirty to prevent moving away from unsaved data.
- Better change propagation from lists and our own widgets.
- Generate notifications for errors and show correct message.
- Moved all path/url generation to the class stores, not everywhere we
use it.
- Give user always a choice between Save and Save & Close.
- Better refresh behaviour on form changes and saves.
- Don't generate duplicate code error when existing object is the one
you're storing.
|
File size:
1.7 KB
|
Rev | Line | |
---|
[443] | 1 | define([ |
---|
| 2 | 'dojo/_base/declare', |
---|
| 3 | 'dijit/registry' |
---|
| 4 | ],function(declare,registry){ |
---|
| 5 | |
---|
| 6 | var Content = declare(null,{ |
---|
| 7 | _started: false, |
---|
| 8 | _container: null, |
---|
| 9 | _previousContent: null, |
---|
[490] | 10 | _dirty: false, |
---|
[443] | 11 | startup: function() { |
---|
| 12 | if ( this._started ) { return; } |
---|
| 13 | |
---|
| 14 | this._container = registry.byId('content'); |
---|
| 15 | if ( !this._container || !this._container.addChild ) { |
---|
| 16 | throw new Error("Cannot find container widget with id 'content'."); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | this._toaster = registry.byId('toaster'); |
---|
| 20 | if ( !this._toaster || !this._toaster.setContent ) { |
---|
| 21 | throw new Error("Cannot find toaster widget with id 'toaster'."); |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | this._started = true; |
---|
| 25 | }, |
---|
| 26 | set: function(widget) { |
---|
| 27 | if ( !this._started ) { |
---|
| 28 | throw new Error('Call startup() before setting content.'); |
---|
| 29 | } |
---|
| 30 | if ( this._previousContent ) { |
---|
| 31 | this._previousContent.destroyRecursive(); |
---|
| 32 | this._previousContent = null; |
---|
| 33 | } |
---|
| 34 | widget.region = 'center'; |
---|
[490] | 35 | this._previousContent = widget; |
---|
[443] | 36 | this._container.addChild(widget); |
---|
| 37 | }, |
---|
| 38 | notify: function(text,type) { |
---|
| 39 | if ( !this._started ) { |
---|
| 40 | throw new Error('Call startup() before setting content.'); |
---|
| 41 | } |
---|
| 42 | this._toaster.setContent(text,type || 'message'); |
---|
[490] | 43 | }, |
---|
| 44 | markDirty: function() { |
---|
| 45 | this._dirty = true; |
---|
| 46 | }, |
---|
| 47 | markClean:function() { |
---|
| 48 | this._dirty = false; |
---|
| 49 | }, |
---|
| 50 | isDirty: function() { |
---|
| 51 | return this._dirty; |
---|
[443] | 52 | } |
---|
| 53 | }); |
---|
| 54 | |
---|
| 55 | return new Content(); |
---|
| 56 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.