Ignore:
Timestamp:
03/08/14 22:51:23 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • 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.
Location:
Dev/trunk/src/client/qed-client/model/classes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/model/classes/_Class.js

    r487 r490  
    2727        },
    2828        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'));
    3032        },
    3133        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'));
    3336        },
    3437        remove: function(objOrId,rev) {
     
    4043                rev = this.getRev(objOrId);
    4144            }
    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'));
    4347        },
    4448        getRev: function(obj) {
    4549            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));
    4658        }
    4759    });
  • Dev/trunk/src/client/qed-client/model/classes/_View.js

    r487 r490  
    11define([
    22    "../../store/JsonRest",
     3    "dojo/Deferred",
    34    "dojo/_base/declare",
     5    "dojo/_base/json",
    46    "dojo/_base/lang",
    57    "dojo/store/util/QueryResults"
    6 ], function(JsonRest, declare, lang, queryResults) {
     8], function(JsonRest, Deferred, declare, json, lang, queryResults) {
    79
    810    var _View = declare([],{
     
    1820            });
    1921        },
     22        _deserializeError: function(err) {
     23            return new Deferred().reject(json.fromJson(err.responseText));
     24        },
    2025        _doDeserialize: function(obj) {
    2126            obj = lang.clone(obj);
     
    3035        getId: function(obj) {
    3136            return obj._id;
     37        },
     38        getCollectionPath: function() {
     39            return '/'+this._collection;
    3240        }
    3341    });
  • Dev/trunk/src/client/qed-client/model/classes/responses.js

    r487 r490  
    4343                handleAs: 'json',
    4444                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'));
    4847        },
    4948        postWithSecret: function(response,secret) {
     
    5554                contentType: 'application/json',
    5655                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'));
    6058        },
    6159        putWithSecret: function(response,secret) {
     
    6765                contentType: 'application/json',
    6866                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'));
    7269        },
    7370        removeWithSecret: function(response,secret) {
     
    8582                contentType: 'application/json',
    8683                rawBody: body
    87             });
     84            }).otherwise(lang.hitch(this,'_deserializeError'));
    8885        }
    8986    });
  • Dev/trunk/src/client/qed-client/model/classes/surveys.js

    r487 r490  
    2626                obj.publicationDate = stamp.toISOString(obj.publicationDate);
    2727            }
     28        },
     29        getPreviewPath: function(idOrObj) {
     30            return '/previewSurvey/'+(typeof idOrObj === "string"?
     31                                      idOrObj :
     32                                      this.getId(idOrObj));
    2833        }
    2934    });
Note: See TracChangeset for help on using the changeset viewer.