Changeset 490 for Dev/trunk/src/client/qed-client/model
- Timestamp:
- 03/08/14 22:51:23 (11 years ago)
- Location:
- Dev/trunk/src/client/qed-client/model
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/model/classes/_Class.js
r487 r490 27 27 }, 28 28 load: function(id) { 29 return this._store.get(id).then(lang.hitch(this,'_doDeserialize')); 29 return this._store.get(id) 30 .then(lang.hitch(this,'_doDeserialize'), 31 lang.hitch(this,'_deserializeError')); 30 32 }, 31 33 save: function(obj) { 32 return this._store.put(this._doSerialize(obj)); 34 return this._store.put(this._doSerialize(obj)) 35 .otherwise(lang.hitch(this,'_deserializeError')); 33 36 }, 34 37 remove: function(objOrId,rev) { … … 40 43 rev = this.getRev(objOrId); 41 44 } 42 return this._store.remove(id,{headers:{'If-Match':'"'+rev+'"'}}); 45 return this._store.remove(id,{headers:{'If-Match':'"'+rev+'"'}}) 46 .otherwise(lang.hitch(this,'_deserializeError')); 43 47 }, 44 48 getRev: function(obj) { 45 49 return obj._rev; 50 }, 51 getName: function() { 52 return this._type; 53 }, 54 getObjectPath: function(idOrObj) { 55 return '/'+this._collection+'/'+(typeof idOrObj === "string" ? 56 idOrObj : 57 this.getId(idOrObj)); 46 58 } 47 59 }); -
Dev/trunk/src/client/qed-client/model/classes/_View.js
r487 r490 1 1 define([ 2 2 "../../store/JsonRest", 3 "dojo/Deferred", 3 4 "dojo/_base/declare", 5 "dojo/_base/json", 4 6 "dojo/_base/lang", 5 7 "dojo/store/util/QueryResults" 6 ], function(JsonRest, declare, lang, queryResults) {8 ], function(JsonRest, Deferred, declare, json, lang, queryResults) { 7 9 8 10 var _View = declare([],{ … … 18 20 }); 19 21 }, 22 _deserializeError: function(err) { 23 return new Deferred().reject(json.fromJson(err.responseText)); 24 }, 20 25 _doDeserialize: function(obj) { 21 26 obj = lang.clone(obj); … … 30 35 getId: function(obj) { 31 36 return obj._id; 37 }, 38 getCollectionPath: function() { 39 return '/'+this._collection; 32 40 } 33 41 }); -
Dev/trunk/src/client/qed-client/model/classes/responses.js
r487 r490 43 43 handleAs: 'json', 44 44 contentType: false 45 }).then(lang.hitch(this,'_doDeserialize'),function(err){ 46 return new Deferred().reject(json.fromJson(err.responseText)); 47 }); 45 }).then(lang.hitch(this,'_doDeserialize'), 46 lang.hitch(this,'_deserializeError')); 48 47 }, 49 48 postWithSecret: function(response,secret) { … … 55 54 contentType: 'application/json', 56 55 rawBody: body 57 }).then(lang.hitch(this,'_doDeserialize'),function(err){ 58 return new Deferred().reject(json.fromJson(err.responseText)); 59 }); 56 }).then(lang.hitch(this,'_doDeserialize'), 57 lang.hitch(this,'_deserializeError')); 60 58 }, 61 59 putWithSecret: function(response,secret) { … … 67 65 contentType: 'application/json', 68 66 rawBody: body 69 }).then(lang.hitch(this,'_doDeserialize'),function(err){ 70 return new Deferred().reject(json.fromJson(err.responseText)); 71 }); 67 }).then(lang.hitch(this,'_doDeserialize'), 68 lang.hitch(this,'_deserializeError')); 72 69 }, 73 70 removeWithSecret: function(response,secret) { … … 85 82 contentType: 'application/json', 86 83 rawBody: body 87 }) ;84 }).otherwise(lang.hitch(this,'_deserializeError')); 88 85 } 89 86 }); -
Dev/trunk/src/client/qed-client/model/classes/surveys.js
r487 r490 26 26 obj.publicationDate = stamp.toISOString(obj.publicationDate); 27 27 } 28 }, 29 getPreviewPath: function(idOrObj) { 30 return '/previewSurvey/'+(typeof idOrObj === "string"? 31 idOrObj : 32 this.getId(idOrObj)); 28 33 } 29 34 }); -
Dev/trunk/src/client/qed-client/model/widgets/AccountListView.js
r443 r490 23 23 actions: { 24 24 "Remove" : { 25 callback: lang.hitch(this, 'removeItem', item ),25 callback: lang.hitch(this, 'removeItem', item, true), 26 26 properties: { 27 27 blockButton: false, -
Dev/trunk/src/client/qed-client/model/widgets/CategoryListView.js
r443 r490 25 25 actions: { 26 26 "Remove" : { 27 callback: lang.hitch(this, 'removeItem', id ),27 callback: lang.hitch(this, 'removeItem', id, true), 28 28 properties: { 29 29 blockButton: false, -
Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorPreview.js
r443 r490 24 24 }); 25 25 this.own(previewItem.on('destroy', 26 lang.hitch(this,'removeItem',id )));26 lang.hitch(this,'removeItem',id,true))); 27 27 previewItem.startup(); 28 28 return previewItem; -
Dev/trunk/src/client/qed-client/model/widgets/QuestionListView.js
r443 r490 23 23 actions: { 24 24 "Remove" : { 25 callback: lang.hitch(this, 'removeItem', id ),25 callback: lang.hitch(this, 'removeItem', id, true), 26 26 properties: { 27 27 blockButton: false, -
Dev/trunk/src/client/qed-client/model/widgets/SurveySummary.js
r487 r490 1 1 define([ 2 "../classes/surveys", 2 3 "dijit/_TemplatedMixin", 3 4 "dijit/_WidgetBase", … … 5 6 "dojo/dom-attr", 6 7 "dojo/text!./templates/SurveySummary.html" 7 ], function( _TemplatedMixin, _WidgetBase, declare, domAttr, template) {8 ], function(surveys, _TemplatedMixin, _WidgetBase, declare, domAttr, template) { 8 9 return declare([_WidgetBase,_TemplatedMixin],{ 9 10 templateString: template, … … 17 18 _setValueAttr: function(survey) { 18 19 this.titleNode.innerHTML = survey.title || ""; 19 domAttr.set(this.titleNode, "href", survey ._id && ("#!/survey/"+survey._id));20 domAttr.set(this.titleNode, "href", survey && surveys.getObjectPath(survey)); 20 21 this.descriptionNode.innerHTML = survey.description; 21 22 this.questionsNode.innerHTML = survey.questions.length; -
Dev/trunk/src/client/qed-client/model/widgets/TabbedQuestionBrowser.js
r487 r490 24 24 this.inherited(arguments); 25 25 this._dataMap = {}; 26 },27 postCreate: function() {28 this.inherited(arguments);29 this._query = '_design/questions/_view/'+this.include;30 26 }, 31 27 startup: function() { -
Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputConfigWidget.js
r443 r490 37 37 value: item, 38 38 onDestroy: lang.hitch(this,function(evt){ 39 this.itemsWidget.removeItem(id );40 event.stop(evt);39 this.itemsWidget.removeItem(id,true); 40 if ( evt ) { event.stop(evt); } 41 41 return false; 42 42 }) … … 61 61 }, 62 62 onAddItem: function(evt) { 63 this.itemsWidget.appendItem({} );64 event.stop(evt);63 this.itemsWidget.appendItem({},true); 64 if ( evt ) { event.stop(evt); } 65 65 return false; 66 66 } -
Dev/trunk/src/client/qed-client/model/widgets/questions/ScaleInputConfigWidget.js
r443 r490 61 61 id: id, 62 62 onDestroy: lang.hitch(this,function(evt){ 63 this.itemsWidget.removeItem(id );64 event.stop(evt);63 this.itemsWidget.removeItem(id,true); 64 if ( evt ) { event.stop(evt); } 65 65 return false; 66 66 }) … … 75 75 }, 76 76 onAddNewItem: function(e) { 77 this.itemsWidget.appendItem({} );78 event.stop(e);77 this.itemsWidget.appendItem({},true); 78 if ( e ) { event.stop(e); } 79 79 return false; 80 80 },
Note: See TracChangeset
for help on using the changeset viewer.