You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2013/12/16 21:03:37 UTC

[17/50] git commit: updated refs/heads/1744-single-config-file to 1c344a9

Fauxton: Fix search button


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

Branch: refs/heads/1744-single-config-file
Commit: 844ddfa3c4ae1695327de17f9816b28d19fdceb7
Parents: 9c942b5
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Dec 4 10:33:57 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Dec 4 16:31:26 2013 +0200

----------------------------------------------------------------------
 src/fauxton/Gruntfile.js                      |  5 +++--
 src/fauxton/app/modules/databases/views.js    | 20 +++++++++++++++-----
 src/fauxton/app/modules/fauxton/components.js | 12 +++++++++++-
 3 files changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/844ddfa3/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 42e5e17..6a8a73a 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -142,12 +142,13 @@ module.exports = function(grunt) {
 
     // The jshint option for scripturl is set to lax, because the anchor
     // override inside main.js needs to test for them so as to not accidentally
-    // route.
+    // route. Settings expr true so we can do `migtBeNullObject && mightBeNullObject.coolFunction()`
     jshint: {
       all: ['app/**/*.js', 'Gruntfile.js', "test/core/*.js"],
       options: {
         scripturl: true,
-        evil: true
+        evil: true,
+        expr: true
       }
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/844ddfa3/src/fauxton/app/modules/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/views.js b/src/fauxton/app/modules/databases/views.js
index 0f67d36..9a197a9 100644
--- a/src/fauxton/app/modules/databases/views.js
+++ b/src/fauxton/app/modules/databases/views.js
@@ -38,7 +38,8 @@ function(app, Components, FauxtonAPI) {
     template: "templates/databases/list",
     events: {
       "click button.all": "selectAll",
-      "submit form.database-search": "switchDatabase"
+      "submit form.database-search": "switchDatabase",
+      "click label.fonticon-search": "switchDatabase"
     },
 
     initialize: function(options) {
@@ -52,10 +53,15 @@ function(app, Components, FauxtonAPI) {
       };
     },
 
-    switchDatabase: function(event) {
-      event.preventDefault();
+    switchDatabase: function(event, selectedName) {
+      event && event.preventDefault();
+
       var dbname = this.$el.find("input.search-query").val();
 
+      if (selectedName) {
+        dbname = selectedName;
+      }
+
       if (dbname) {
         // TODO: switch to using a model, or Databases.databaseUrl()
         // Neither of which are in scope right now
@@ -77,7 +83,6 @@ function(app, Components, FauxtonAPI) {
         collection: this.collection
       }));
 
-
       _.each(this.paginated(), function(database) {
         this.insertView("table.databases tbody", new Views.Item({
           model: database
@@ -99,9 +104,14 @@ function(app, Components, FauxtonAPI) {
     },
 
     afterRender: function() {
+      var that = this;
       this.dbSearchTypeahead = new Components.DbSearchTypeahead({
         dbLimit: this.dbLimit,
-        el: "input.search-query"
+        el: "input.search-query",
+        onUpdate: function (item) {
+          console.log('boom', item);
+          that.switchDatabase(null, item);
+        }
       });
 
       this.dbSearchTypeahead.render();

http://git-wip-us.apache.org/repos/asf/couchdb/blob/844ddfa3/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 0443573..bcc9226 100644
--- a/src/fauxton/app/modules/fauxton/components.js
+++ b/src/fauxton/app/modules/fauxton/components.js
@@ -116,8 +116,17 @@ function(app, FauxtonAPI, ace) {
     },
 
     afterRender: function () {
+      var onUpdate = this.onUpdate;
+
       this.$el.typeahead({
-        source: this.source
+        source: this.source,
+        updater: function (item) {
+          if (onUpdate) {
+            onUpdate(item);
+          }
+
+          return item;
+        }
       });
     }
 
@@ -127,6 +136,7 @@ function(app, FauxtonAPI, ace) {
   Components.DbSearchTypeahead = Components.Typeahead.extend({
     initialize: function (options) {
       this.dbLimit = options.dbLimit || 30;
+      this.onUpdate = options.onUpdate;
       _.bindAll(this);
     },
     source: function(query, process) {