summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-10-11 10:35:02 +0200
committerJoas Schilling <coding@schilljs.com>2016-10-11 10:35:02 +0200
commitd511acdf665357493fe34bbe631086760a5b9d12 (patch)
treebaff49bc649bd53b3e38154a390ef7cdf4d5aa0b /settings
parentb1314942d7b82dce28d9ee41523a68f0b40eab91 (diff)
downloadnextcloud-server-d511acdf665357493fe34bbe631086760a5b9d12.tar.gz
nextcloud-server-d511acdf665357493fe34bbe631086760a5b9d12.zip
Better search functionality
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'settings')
-rw-r--r--settings/js/apps.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js
index cd554812ec9..5fc366c4921 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -494,6 +494,24 @@ OC.Settings.Apps = OC.Settings.Apps || {
);
},
+ /**
+ * Splits the query by spaces and tries to find all substring in the app
+ * @param {string} string
+ * @param {string} query
+ * @returns {boolean}
+ */
+ _search: function(string, query) {
+ var keywords = query.split(' '),
+ stringLower = string.toLowerCase(),
+ found = true;
+
+ _.each(keywords, function(keyword) {
+ found = found && stringLower.indexOf(keyword) !== -1;
+ });
+
+ return found;
+ },
+
filter: function(query) {
var $appList = $('#apps-list'),
$emptyList = $('#apps-list-empty');
@@ -510,17 +528,17 @@ OC.Settings.Apps = OC.Settings.Apps || {
// App Name
var apps = _.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.name.toLowerCase().indexOf(query) !== -1;
+ return OC.Settings.Apps._search(app.name, query);
});
// App ID
apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.id.toLowerCase().indexOf(query) !== -1;
+ return OC.Settings.Apps._search(app.id, query);
}));
// App Description
apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
- return app.description.toLowerCase().indexOf(query) !== -1;
+ return OC.Settings.Apps._search(app.description, query);
}));
// Author Name
@@ -540,9 +558,9 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
}
});
- return authors.join(' ').toLowerCase().indexOf(query) !== -1;
+ return OC.Settings.Apps._search(authors.join(' '), query);
}
- return app.author.toLowerCase().indexOf(query) !== -1;
+ return OC.Settings.Apps._search(app.author, query);
}));
// App status