You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/12/05 20:48:32 UTC

fauxton commit: updated refs/heads/master to c2e8dbd

Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master fbff1116f -> c2e8dbd02


Recognize manual URL changes on doc editor page

This ticket lets users manually change the URL on the doc editor page
and have the page automatically load the new doc.

Closes COUCHDB-2490


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/c2e8dbd0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/c2e8dbd0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/c2e8dbd0

Branch: refs/heads/master
Commit: c2e8dbd0294b4c7de914904c7f75c17dbf54d016
Parents: fbff111
Author: Benjamin Keen <be...@gmail.com>
Authored: Thu Dec 4 09:47:59 2014 -0800
Committer: Benjamin Keen <be...@gmail.com>
Committed: Fri Dec 5 11:48:39 2014 -0800

----------------------------------------------------------------------
 app/addons/documents/routes-doc-editor.js | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/c2e8dbd0/app/addons/documents/routes-doc-editor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/routes-doc-editor.js b/app/addons/documents/routes-doc-editor.js
index a4fa44c..83cca0b 100644
--- a/app/addons/documents/routes-doc-editor.js
+++ b/app/addons/documents/routes-doc-editor.js
@@ -30,15 +30,11 @@ function(app, FauxtonAPI, Documents, DocEditor, Databases) {
     selectedHeader: "Databases",
 
     initialize: function(route, masterLayout, options) {
-      var databaseName = options[0];
-      this.docID = options[1]||'new';
+      this.databaseName = options[0];
+      this.docID = options[1] || 'new';
 
-      this.database = this.database || new Databases.Model({id: databaseName});
-      this.doc = new Documents.Doc({
-        _id: this.docID
-      }, {
-        database: this.database
-      });
+      this.database = this.database || new Databases.Model({ id: this.databaseName });
+      this.doc = new Documents.Doc({ _id: this.docID }, { database: this.database });
     },
 
     routes: {
@@ -59,6 +55,17 @@ function(app, FauxtonAPI, Documents, DocEditor, Databases) {
     },
 
     code_editor: function (database, doc) {
+
+      // if either the database or document just changed, we need to get the latest doc/db info
+      if (this.databaseName !== database) {
+        this.databaseName = database;
+        this.database = new Databases.Model({ id: this.databaseName });
+      }
+      if (this.docID !== doc) {
+        this.docID = doc;
+        this.doc = new Documents.Doc({ _id: this.docID }, { database: this.database });
+      }
+
       this.docView = this.setView("#dashboard-content", new DocEditor.CodeEditor({
         model: this.doc,
         database: this.database