couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garrensmith <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Update full page document editor
Date Fri, 19 Dec 2014 10:02:30 GMT
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/204#discussion_r22097301
  
    --- Diff: app/addons/documents/views-doceditor.js ---
    @@ -398,77 +307,88 @@ function (app, FauxtonAPI, Components, Documents, Databases, prettify)
{
                 msg: 'Save failed: ' + responseText,
                 type: 'error',
                 fade: false,
    -            clear: true,
    -            selector: '#doc .errors-container'
    +            clear: true
               });
             });
           } else if(this.model.validationError && this.model.validationError ===
'Cannot change a documents id.') {
    -          FauxtonAPI.addNotification({
    -            msg: 'Cannot save: ' + 'Cannot change a documents _id, try Duplicate doc
instead!',
    -            type: 'error',
    -            selector: '#doc .errors-container',
    -            clear:  true
    -          });
    +        FauxtonAPI.addNotification({
    +          msg: 'Cannot save. Cannot change a documents _id, try Clone Document instead!',
    +          type: 'error',
    +          clear:  true
    +        });
             delete this.model.validationError;
           } else {
             FauxtonAPI.addNotification({
    -          msg: 'Please fix the JSON errors and try again.',
    +          msg: 'Please fix the JSON errors and try saving again.',
               type: 'error',
    -          selector: '#doc .errors-container',
               clear:  true
             });
           }
         },
     
         getDocFromEditor: function () {
    -      var json;
    -
           if (!this.hasValidCode()) {
             return false;
           }
    -
    -      json = JSON.parse(this.editor.getValue());
    -
    +      var json = JSON.parse(this.editor.getValue());
           this.model.clear().set(json, {validate: true});
           if (this.model.validationError) {
             return false;
           }
    -
           return this.model;
         },
     
    -    hasValidCode: function () {
    -      var errors = this.editor.getAnnotations();
    -      return errors.length === 0;
    +    beforeRender: function () {
    +      var that = this;
    +
    +      this.uploadModal = this.setView('#upload-modal', new this.components.uploadModal({
model: this.model }));
    +      this.duplicateModal = this.setView('#duplicate-modal', new this.components.duplicateDocModal({
model: this.model }));
    +      this.confirmDeleteModal = this.setView('#delete-doc-modal', new this.components.confirmModal({
    +        text: 'Are you sure you want to delete this document?',
    +        action: that.deleteDocument
    --- End diff --
    
    if you change this to `_.bind(this.deleteDocument, this)` then we can remove the `_.bindAll(this)`
in the initialise.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message