You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/09/19 14:51:53 UTC
[1/4] git commit: updated refs/heads/master to d719b78
Updated Branches:
refs/heads/master bdc14beff -> d719b781f
Fauxton: Add typeahead support to jump to doc
Simple type ahead support to check for start of id. It also checks if
document exists if not return back to _all_docs list
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/fbbaaffa
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/fbbaaffa
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/fbbaaffa
Branch: refs/heads/master
Commit: fbbaaffaac347368aff7bc480071fc6ef7399d59
Parents: bdc14be
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Sep 18 17:34:33 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Sep 18 17:34:33 2013 +0200
----------------------------------------------------------------------
src/fauxton/app/api.js | 14 +++++---
src/fauxton/app/modules/documents/resources.js | 4 ---
src/fauxton/app/modules/documents/routes.js | 5 ++-
src/fauxton/app/modules/documents/views.js | 27 +++++++++++++--
src/fauxton/app/modules/fauxton/components.js | 35 ++++++++++++++++++++
.../app/templates/documents/jumpdoc.html | 2 +-
src/fauxton/assets/less/fauxton.less | 14 ++++++++
7 files changed, 88 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 5cf59a2..6f47bd8 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -335,10 +335,13 @@ function(app, Fauxton) {
reason: resp
};
- FauxtonAPI.addNotification({
- msg: 'An Error occurred ' + resp.responseText,
- type: 'error'
- });
+ if (resp) {
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred' + resp.responseText,
+ type: 'error'
+ });
+ }
+
masterLayout.renderView(selector);
});
@@ -352,8 +355,9 @@ function(app, Fauxton) {
});
});
}.bind(this), function (resp) {
+ if (!resp) { return; }
FauxtonAPI.addNotification({
- msg: 'An Error occurred ' + resp.responseText,
+ msg: 'An Error occurred' + resp.responseText,
type: 'error'
});
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index 70be81c..395d171 100644
--- a/src/fauxton/app/modules/documents/resources.js
+++ b/src/fauxton/app/modules/documents/resources.js
@@ -22,10 +22,6 @@ function(app, FauxtonAPI) {
Documents.Doc = Backbone.Model.extend({
idAttribute: "_id",
- defaults: {
- views: {}
- },
-
url: function(context) {
if (context === "app") {
return this.getDatabase().url("app") + "/" + this.safeID();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/app/modules/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
index 0edf18d..7a75740 100644
--- a/src/fauxton/app/modules/documents/routes.js
+++ b/src/fauxton/app/modules/documents/routes.js
@@ -205,7 +205,10 @@ function(app, FauxtonAPI, Documents, Databases) {
if (this.viewEditor) { this.viewEditor.remove(); }
- this.toolsView = this.setView("#dashboard-upper-menu", new Documents.Views.JumpToDoc({database: this.data.database}));
+ this.toolsView = this.setView("#dashboard-upper-menu", new Documents.Views.JumpToDoc({
+ database: this.data.database,
+ collection: this.data.database.allDocs
+ }));
this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
collection: this.data.database.allDocs
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index 576e14e..3296a0d 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -646,7 +646,24 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
},
establish: function() {
- return [this.model.fetch()];
+ var promise = this.model.fetch(),
+ databaseId = this.database.id,
+ deferred = $.Deferred();
+
+ promise.then(function () {
+ deferred.resolve()
+ }, function (xhr, reason, msg) {
+ if (xhr.status === 404) {
+ FauxtonAPI.addNotification({
+ msg: 'The document does not exist',
+ type: 'error'
+ });
+ FauxtonAPI.navigate('/database/' + databaseId + '/_all_docs?limit=20');
+ }
+ deferred.reject();
+ });
+
+ return deferred;
},
saveDoc: function(event) {
@@ -1345,13 +1362,19 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
events: {
"submit #jump-to-doc": "jumpToDoc",
- "click #jump-to-doc-label": "jumpToDoc"
},
jumpToDoc: function (event) {
event.preventDefault();
+
var docId = this.$('#jump-to-doc-id').val();
+
FauxtonAPI.navigate('/database/' + this.database.id +'/' + docId, {trigger: true});
+ },
+
+ afterRender: function () {
+ this.typeAhead = new Components.DocSearchTypeahead({el: '#jump-to-doc-id', database: this.database});
+ this.typeAhead.render();
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/app/modules/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/components.js b/src/fauxton/app/modules/fauxton/components.js
index 10e08dc..09dcc51 100644
--- a/src/fauxton/app/modules/fauxton/components.js
+++ b/src/fauxton/app/modules/fauxton/components.js
@@ -105,6 +105,7 @@ function(app, FauxtonAPI) {
});
+
Components.DbSearchTypeahead = Components.Typeahead.extend({
initialize: function (options) {
this.dbLimit = options.dbLimit || 30;
@@ -133,6 +134,40 @@ function(app, FauxtonAPI) {
}
});
+ Components.DocSearchTypeahead = Components.Typeahead.extend({
+ initialize: function (options) {
+ this.docLimit = options.docLimit || 30;
+ this.database = options.database;
+ _.bindAll(this);
+ },
+ source: function(query, process) {
+ var url = [
+ app.host,
+ "/",
+ this.database.id,
+ "/_all_docs?startkey=%22",
+ query,
+ "%22&endkey=%22",
+ query,
+ "\u9999%22&limit=",
+ this.docLimit
+ ].join('');
+
+ if (this.ajaxReq) { this.ajaxReq.abort(); }
+
+ this.ajaxReq = $.ajax({
+ url: url,
+ dataType: 'json',
+ success: function(data) {
+ var ids = _.map(data.rows, function (row) {
+ return row.id;
+ });
+ process(ids);
+ }
+ });
+ }
+ });
+
return Components;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/app/templates/documents/jumpdoc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/jumpdoc.html b/src/fauxton/app/templates/documents/jumpdoc.html
index 546134b..2e83c52 100644
--- a/src/fauxton/app/templates/documents/jumpdoc.html
+++ b/src/fauxton/app/templates/documents/jumpdoc.html
@@ -15,6 +15,6 @@ the License.
<form id="jump-to-doc" class="form-inline">
<label id="jump-to-doc-label" class="fonticon-search">
- <input type="text" id="jump-to-doc-id" class="input-large" placeholder="Document ID"></input>
+ <input type="text" id="jump-to-doc-id" class="i1nput-large" placeholder="Document ID"></input>
</label>
</form>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/fbbaaffa/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index e5f5142..82e0a14 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -914,3 +914,17 @@ div.spinner {
}
}
}
+
+#jump-to-doc {
+ width: 88%;
+ max-width: 600px;
+
+ #jump-to-doc-label {
+ width: 100%;
+ }
+
+ #jump-to-doc-id {
+ width: 100%;
+ margin-top: -4px;
+ }
+}
[4/4] git commit: updated refs/heads/master to d719b78
Posted by ga...@apache.org.
Added clear:true to the notification for when a document doesn't exist so that it overwrites the generic error messaging
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d719b781
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d719b781
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d719b781
Branch: refs/heads/master
Commit: d719b781fba6f2f9cb90d55b2dd741c859124455
Parents: e9bddf9
Author: suelockwood <de...@gmail.com>
Authored: Wed Sep 18 16:13:06 2013 -0400
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Sep 19 14:50:52 2013 +0200
----------------------------------------------------------------------
src/fauxton/app/api.js | 2 +-
src/fauxton/app/modules/documents/views.js | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d719b781/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 192678e..9c2b523 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -358,7 +358,7 @@ function(app, Fauxton) {
}.bind(this), function (resp) {
if (!resp) { return; }
FauxtonAPI.addNotification({
- msg: 'An Error occurred' + resp.responseText,
+ msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
type: 'error'
});
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/d719b781/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index d66c6da..09ef2b5 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -656,7 +656,8 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
if (xhr.status === 404) {
FauxtonAPI.addNotification({
msg: 'The document does not exist',
- type: 'error'
+ type: 'error',
+ clear: true
});
FauxtonAPI.navigate('/database/' + databaseId + '/_all_docs?limit=20');
}
[2/4] git commit: updated refs/heads/master to d719b78
Posted by ga...@apache.org.
Missed a semicolon on the deferred
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/95b8bb3b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/95b8bb3b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/95b8bb3b
Branch: refs/heads/master
Commit: 95b8bb3bef356dc350d1d7faac06c70deca295b8
Parents: fbbaaff
Author: suelockwood <de...@gmail.com>
Authored: Wed Sep 18 16:01:29 2013 -0400
Committer: suelockwood <de...@gmail.com>
Committed: Wed Sep 18 16:01:29 2013 -0400
----------------------------------------------------------------------
src/fauxton/app/modules/documents/views.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/95b8bb3b/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
index 3296a0d..d66c6da 100644
--- a/src/fauxton/app/modules/documents/views.js
+++ b/src/fauxton/app/modules/documents/views.js
@@ -651,7 +651,7 @@ function(app, FauxtonAPI, Components, Documents, pouchdb, Codemirror, JSHint, re
deferred = $.Deferred();
promise.then(function () {
- deferred.resolve()
+ deferred.resolve();
}, function (xhr, reason, msg) {
if (xhr.status === 404) {
FauxtonAPI.addNotification({
[3/4] git commit: updated refs/heads/master to d719b78
Posted by ga...@apache.org.
Our error handling was showing an object in the messaging. I fixed it so it shows the "reason" part of the object.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e9bddf96
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e9bddf96
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e9bddf96
Branch: refs/heads/master
Commit: e9bddf967c9a92a56e3e99d3fa2be40705f0c428
Parents: 95b8bb3
Author: suelockwood <de...@gmail.com>
Authored: Wed Sep 18 16:06:09 2013 -0400
Committer: suelockwood <de...@gmail.com>
Committed: Wed Sep 18 16:06:09 2013 -0400
----------------------------------------------------------------------
src/fauxton/app/api.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e9bddf96/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 6f47bd8..192678e 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -336,8 +336,9 @@ function(app, Fauxton) {
};
if (resp) {
+ var errorText = JSON.parse(resp.responseText).reason;
FauxtonAPI.addNotification({
- msg: 'An Error occurred' + resp.responseText,
+ msg: 'An Error occurred: ' + errorText,
type: 'error'
});
}