Last change
on this file since 442 was
441,
checked in by hendrikvanantwerpen, 12 years ago
|
Big cleanup of the question content.
- Replaced old list implementations with a new one that behaves like a form widget.
- All question content is now in separate widgets, not in the factory itself.
- Added form and widget validation for question editing.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[406] | 1 | define([ |
---|
[410] | 2 | 'dojo/date/stamp', |
---|
[417] | 3 | 'dojo/store/Cache', |
---|
| 4 | 'dojo/store/Memory', |
---|
[415] | 5 | 'dojox/json/schema', |
---|
[417] | 6 | './model/schema', |
---|
[410] | 7 | './store/CouchStore' |
---|
[417] | 8 | ],function(stamp,Cache,Memory,jsonSchema,schema,CouchStore){ |
---|
[303] | 9 | |
---|
[417] | 10 | var couchStore = new CouchStore({ |
---|
[441] | 11 | target: 'data/couch/' /*, |
---|
[415] | 12 | validate: function(object) { |
---|
| 13 | var result = jsonSchema.validate(object,schema); |
---|
| 14 | if ( result.valid ) { |
---|
| 15 | return true; |
---|
| 16 | } else { |
---|
| 17 | console.log("Found error ",result," for invalid object ",object); |
---|
| 18 | return false; |
---|
| 19 | } |
---|
[441] | 20 | }*/ |
---|
[415] | 21 | }); |
---|
[420] | 22 | var memoryStore = new Memory({ |
---|
| 23 | idProperty: couchStore.idProperty |
---|
| 24 | }); |
---|
| 25 | var cacheStore = new Cache(couchStore,memoryStore,{ |
---|
| 26 | isLoaded: function(object) { |
---|
| 27 | // Unfortunately we cannot determine of the full documents were |
---|
| 28 | // loaded or not. Therefore never cache query results. |
---|
| 29 | return false; |
---|
| 30 | } |
---|
| 31 | }); |
---|
[417] | 32 | |
---|
| 33 | var store = cacheStore; |
---|
[410] | 34 | store.formatDate = function(date){ |
---|
| 35 | return stamp.toISOString(date,{zulu:true}); |
---|
| 36 | }; |
---|
| 37 | store.parseDate = function(dateString){ |
---|
| 38 | return stamp.fromISOString(dateString); |
---|
| 39 | }; |
---|
| 40 | store.timestamp = function() { |
---|
| 41 | return this.formatDate(new Date()); |
---|
| 42 | }; |
---|
| 43 | return store; |
---|
[343] | 44 | |
---|
[406] | 45 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.