Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/204#discussion_r22097446
  
    --- Diff: app/addons/documents/views-doceditor.js ---
    @@ -505,35 +426,68 @@ function (app, FauxtonAPI, Components, Documents, 
Databases, prettify) {
                 keyChecked.push('_rev');
               }
     
    -          //check the changedDoc has all the required standard keys
    -          if (_.isEmpty(_.difference(keyChecked, _.keys(changedDoc)))) { 
return; }
    +          // check the changedDoc has all the required standard keys
    +          if (_.isEmpty(_.difference(keyChecked, _.keys(changedDoc)))) {
    +            return;
    +          }
     
               editor.setReadOnly(true);
               setTimeout(function () { editor.setReadOnly(false) ;}, 400);
    +
               // use extend so that _id stays at the top of the object with 
displaying the doc
               changedDoc = _.extend({_id: model.id, _rev: model.get('_rev')}, 
changedDoc);
               editor.setValue(JSON.stringify(changedDoc, null, '  '));
               FauxtonAPI.addNotification({
                 type: 'error',
    -            msg: 'Cannot remove a documents Id or Revision.',
    -            clear:  true
    +            msg: 'Cannot remove a document\'s id or revision.',
    +            clear: true
               });
             });
     
    -        var showHideEditDocString = _.bind(this.showHideEditDocString, 
this);
    -
    -        this.listenTo(editor.editor, 'changeSelection', function (event) {
    -          showHideEditDocString(event);
    -        });
    -        this.listenTo(editor.editor.session, 'changeBackMarker', function 
(event) {
    -          showHideEditDocString(event);
    -        });
    +        // place focus on the editor
    +        editor.editor.focus();
     
           }.bind(this));
    +
    +      // this sucks having to reference #dashboard, but when user clicks 
in the region below the editor I want it
    +      // to focus on the final line. It feels natural that way
    +      $('.scrollable').on('click', function(e) {
    +        var clickedInEditor = $(e.target).closest('#editor-container');
    +        if (clickedInEditor.length === 0) {
    +          editor.editor.focus();
    +          var session = editor.editor.getSession();
    +          var count = session.getLength();
    +          editor.editor.gotoLine(count, session.getLine(count-1).length);
    +        }
    +      });
    +    },
    +
    +    serialize: function () {
    +      return {
    +        doc: this.model,
    +        attachments: this.getAttachments()
    +      };
    +    },
    +
    +    getAttachments: function () {
    +      var attachments = this.model.get('_attachments');
    +      if (!attachments) { return false; }
    +
    +      return _.map(attachments, function (att, key) {
    +        return {
    +          fileName: key,
    +          size: att.length,
    +          contentType: att.content_type,
    +          url: this.model.url() + '/' + app.utils.safeURLName(key)
    +        };
    +      }, this);
         },
     
         cleanup: function () {
    -      if (this.editor) this.editor.remove();
    +      if (this.editor) {
    --- End diff --
    
    This is cool but you can one-line this `this.editor && this.editor.remove()`


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to