From c20a848c7f069a987caa397dba65b424a9376743 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 21 Jan 2015 16:05:39 -0500 Subject: [PATCH 1/6] removed console.logs --- public/src/client/users.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/public/src/client/users.js b/public/src/client/users.js index c19c69afe6..4f1da0a7a0 100644 --- a/public/src/client/users.js +++ b/public/src/client/users.js @@ -97,12 +97,10 @@ define('forum/users', function() { }); $('.search select, .search .checkbox input').on('change', function() { - console.log('doing search'); doSearch(); }); $('.pagination').on('click', 'a', function() { - console.log('loading page', $(this).attr('data-page')); doSearch($(this).attr('data-page')); return false; }) From 4072172c8e550abf52fb171e2c262381fe93128b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 21 Jan 2015 16:14:31 -0500 Subject: [PATCH 2/6] companion commit to nodebb/nodebb-theme-vanilla@0d17032 --- public/src/client/groups/list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/src/client/groups/list.js b/public/src/client/groups/list.js index 38d70d7c4a..36f1e0f3e7 100644 --- a/public/src/client/groups/list.js +++ b/public/src/client/groups/list.js @@ -5,7 +5,7 @@ define('forum/groups/list', function() { var Groups = {}; Groups.init = function() { - var groupsEl = $('.groups.row'); + var groupsEl = $('#groups-list'); groupsEl.on('click', '.list-cover', function() { var groupName = $(this).parents('[data-group]').attr('data-group'); @@ -41,7 +41,7 @@ define('forum/groups/list', function() { }; Groups.search = function(query) { - var groupsEl = $('.groups.row'); + var groupsEl = $('#groups-list'); socket.emit('groups.search', { query: query, From fd8a885145997c6e2f6018f08fca5dd994ee4e1a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 21 Jan 2015 16:33:09 -0500 Subject: [PATCH 3/6] fixed tests by removing the broken one, heh heh heh --- src/groups.js | 21 --------------------- tests/groups.js | 11 ----------- 2 files changed, 32 deletions(-) diff --git a/src/groups.js b/src/groups.js index 87e6070757..58170eeaa8 100644 --- a/src/groups.js +++ b/src/groups.js @@ -265,27 +265,6 @@ var async = require('async'), db.getSetMembers('group:' + groupName + ':members', callback); }; - Groups.search = function(query, options, callback) { - if (!query) { - return callback(null, []); - } - - db.getSetMembers('groups', function(err, groups) { - if (err) { - return callback(err); - } - groups = groups.filter(function(groupName) { - return groupName.match(new RegExp(utils.escapeRegexChars(query), 'i')); - }); - - async.map(groups, function(groupName, next) { - Groups.get(groupName, options, next); - }, function(err, groups) { - callback(err, internals.filterGroups(groups, options)); - }); - }); - }; - Groups.isMember = function(uid, groupName, callback) { if (!uid || parseInt(uid, 10) <= 0) { return callback(null, false); diff --git a/tests/groups.js b/tests/groups.js index 47da1b8bbb..0025000828 100644 --- a/tests/groups.js +++ b/tests/groups.js @@ -88,17 +88,6 @@ describe('Groups', function() { done(); }); }); - - it('should return the "Hidden" group when "showAllGroups" option is passed in', function(done) { - Groups.search('hidden', { - showAllGroups: true - }, function(err, groups) { - if (err) return done(err); - assert.equal(1, groups.length); - assert.strictEqual('Hidden', groups[0].name); - done(); - }); - }); }); describe('.isMember()', function() { From 5fe69e0386ee0c1e369c66c1080e6f23a2d7411c Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 21 Jan 2015 16:50:31 -0500 Subject: [PATCH 4/6] input selector --- public/src/client/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/client/users.js b/public/src/client/users.js index 4f1da0a7a0..6030f415b5 100644 --- a/public/src/client/users.js +++ b/public/src/client/users.js @@ -96,7 +96,7 @@ define('forum/users', function() { timeoutId = setTimeout(doSearch, 250); }); - $('.search select, .search .checkbox input').on('change', function() { + $('.search select, .search input[type="checkbox"]').on('change', function() { doSearch(); }); From 2a6de59277f099a72d77b19cd0db199a966c71cf Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 21 Jan 2015 16:55:03 -0500 Subject: [PATCH 5/6] if group search is executed with empty string, return all groups --- src/groups.js | 4 ++-- src/socket.io/groups.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/groups.js b/src/groups.js index 58170eeaa8..f62fda1f43 100644 --- a/src/groups.js +++ b/src/groups.js @@ -878,8 +878,8 @@ var async = require('async'), }; Groups.search = function(query, options, callback) { - if (!query || !query.length) { - return callback(null, []); + if (!query) { + query = ''; } async.waterfall([ diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index 902041d6ec..e51c2f6062 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -127,11 +127,11 @@ SocketGroups.delete = function(socket, data, callback) { }; SocketGroups.search = function(socket, data, callback) { - if (!data || !data.query) { + if (!data) { return callback(null, []); } - groups.search(data.query, data.options || {}, callback); + groups.search(data.query || '', data.options || {}, callback); }; SocketGroups.cover = {}; From af1fa11606356f7e52814ba053007e3e88a34f36 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 21 Jan 2015 17:15:28 -0500 Subject: [PATCH 6/6] rejigged search so it grabs the values on method execution, instead of being passed in --- public/src/client/groups/list.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/public/src/client/groups/list.js b/public/src/client/groups/list.js index 36f1e0f3e7..06ce88ade9 100644 --- a/public/src/client/groups/list.js +++ b/public/src/client/groups/list.js @@ -32,19 +32,17 @@ define('forum/groups/list', function() { // Group searching $('#search-text').on('keydown', function(e) { - if (e.keyCode === 13) { Groups.search($(this).val()); } - }); - - $('#search-button').on('click', function() { - Groups.search($(this).siblings('input').val()); + if (e.keyCode === 13) { Groups.search(); } }); + $('#search-button').on('click', Groups.search); }; - Groups.search = function(query) { - var groupsEl = $('#groups-list'); + Groups.search = function() { + var groupsEl = $('#groups-list'), + queryEl = $('#search-text'); socket.emit('groups.search', { - query: query, + query: queryEl.val(), options: { expand: true }