couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [2/2] fauxton commit: updated refs/heads/master to 6ed784b
Date Tue, 11 Nov 2014 10:14:17 GMT
Fix back-button after you saved a new document

When you were creating a new document and then clicking save
the back button would bring you to the editor for new documents.
To get back to the Documentslist you were coming from, you had
to hit the "back"-button twice.

Additionally renamed lastPage to lastPages as it contains
multiple pages.


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

Branch: refs/heads/master
Commit: 6ed784b68be349b58050659a5e854253754ec763
Parents: 1139612
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Fri Nov 7 17:49:41 2014 +0100
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Fri Nov 7 18:00:12 2014 +0100

----------------------------------------------------------------------
 app/addons/documents/views-doceditor.js |  6 ++++--
 app/core/router.js                      | 10 +++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6ed784b6/app/addons/documents/views-doceditor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views-doceditor.js b/app/addons/documents/views-doceditor.js
index cbcfff1..aa27b66 100644
--- a/app/addons/documents/views-doceditor.js
+++ b/app/addons/documents/views-doceditor.js
@@ -221,9 +221,11 @@ function (app, FauxtonAPI, Components, Documents, Databases, resizeColumns,
pret
     },
 
     goback: function () {
-      var lastPageLength = FauxtonAPI.router.lastPage.length;
+      var lastPages = FauxtonAPI.router.lastPages;
 
-      if (lastPageLength < 2) {
+      // we copy/pasted the url into the browser or came from
+      // creating a document with "/new" in the end of the path
+      if (lastPages.length < 2 || /\/new$/.test(lastPages[0])) {
         FauxtonAPI.navigate(this.database.url('index') + '?limit=100');
       } else {
         window.history.back();

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/6ed784b6/app/core/router.js
----------------------------------------------------------------------
diff --git a/app/core/router.js b/app/core/router.js
index 49190cb..1982f88 100644
--- a/app/core/router.js
+++ b/app/core/router.js
@@ -98,12 +98,12 @@ function(FauxtonAPI, Auth, Backbone) {
       $(FauxtonAPI.el).html(FauxtonAPI.masterLayout.el);
       FauxtonAPI.masterLayout.render();
 
-      this.lastPage = [];
+      this.lastPages = [];
       //keep last pages visited in Fauxton
-      Backbone.history.on('route', function () { 
-        this.lastPage.push(Backbone.history.fragment);
-        if (this.lastPage.length > 2) {
-          this.lastPage.shift();
+      Backbone.history.on('route', function () {
+        this.lastPages.push(Backbone.history.fragment);
+        if (this.lastPages.length > 2) {
+          this.lastPages.shift();
         }
       }, this);
     },


Mime
View raw message