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
Files:
12 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    });
  • Dev/trunk/src/client/qed-client/model/widgets/AccountListView.js

    r443 r490  
    2323                actions: {
    2424                    "Remove" : {
    25                         callback: lang.hitch(this, 'removeItem', item),
     25                        callback: lang.hitch(this, 'removeItem', item, true),
    2626                        properties: {
    2727                            blockButton: false,
  • Dev/trunk/src/client/qed-client/model/widgets/CategoryListView.js

    r443 r490  
    2525                actions: {
    2626                    "Remove" : {
    27                         callback: lang.hitch(this, 'removeItem', id),
     27                        callback: lang.hitch(this, 'removeItem', id, true),
    2828                        properties: {
    2929                            blockButton: false,
  • Dev/trunk/src/client/qed-client/model/widgets/QuestionEditorPreview.js

    r443 r490  
    2424            });
    2525            this.own(previewItem.on('destroy',
    26                                     lang.hitch(this,'removeItem',id)));
     26                                    lang.hitch(this,'removeItem',id,true)));
    2727            previewItem.startup();
    2828            return previewItem;
  • Dev/trunk/src/client/qed-client/model/widgets/QuestionListView.js

    r443 r490  
    2323                actions: {
    2424                    "Remove" : {
    25                         callback: lang.hitch(this, 'removeItem', id),
     25                        callback: lang.hitch(this, 'removeItem', id, true),
    2626                        properties: {
    2727                            blockButton: false,
  • Dev/trunk/src/client/qed-client/model/widgets/SurveySummary.js

    r487 r490  
    11define([
     2    "../classes/surveys",
    23    "dijit/_TemplatedMixin",
    34    "dijit/_WidgetBase",
     
    56    "dojo/dom-attr",
    67    "dojo/text!./templates/SurveySummary.html"
    7 ], function(_TemplatedMixin, _WidgetBase, declare, domAttr, template) {
     8], function(surveys, _TemplatedMixin, _WidgetBase, declare, domAttr, template) {
    89    return declare([_WidgetBase,_TemplatedMixin],{
    910        templateString: template,
     
    1718        _setValueAttr: function(survey) {
    1819            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));
    2021            this.descriptionNode.innerHTML = survey.description;
    2122            this.questionsNode.innerHTML = survey.questions.length;
  • Dev/trunk/src/client/qed-client/model/widgets/TabbedQuestionBrowser.js

    r487 r490  
    2424            this.inherited(arguments);
    2525            this._dataMap = {};
    26         },
    27         postCreate: function() {
    28             this.inherited(arguments);
    29             this._query = '_design/questions/_view/'+this.include;
    3026        },
    3127        startup: function() {
  • Dev/trunk/src/client/qed-client/model/widgets/questions/MultipleChoiceInputConfigWidget.js

    r443 r490  
    3737                value: item,
    3838                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); }
    4141                    return false;
    4242                })
     
    6161        },
    6262        onAddItem: function(evt) {
    63             this.itemsWidget.appendItem({});
    64             event.stop(evt);
     63            this.itemsWidget.appendItem({},true);
     64            if ( evt ) { event.stop(evt); }
    6565            return false;
    6666        }
  • Dev/trunk/src/client/qed-client/model/widgets/questions/ScaleInputConfigWidget.js

    r443 r490  
    6161                id: id,
    6262                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); }
    6565                    return false;
    6666                })
     
    7575        },
    7676        onAddNewItem: function(e) {
    77             this.itemsWidget.appendItem({});
    78             event.stop(e);
     77            this.itemsWidget.appendItem({},true);
     78            if ( e ) { event.stop(e); }
    7979            return false;
    8080        },
Note: See TracChangeset for help on using the changeset viewer.