summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-02-23 21:51:53 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-02-23 21:51:53 +0100
commit66e3211fd8a57b0fb296d1dcc980272721e9f99d (patch)
tree28de9408be379de6e7049dd97b9fc896d1e330e9 /settings/js
parentc350da1a283be82ba4d535069d5d760fb3355e5a (diff)
parente144d3aa49a1e4a3bb487ada9d83a2b4c81e6630 (diff)
downloadnextcloud-server-66e3211fd8a57b0fb296d1dcc980272721e9f99d.tar.gz
nextcloud-server-66e3211fd8a57b0fb296d1dcc980272721e9f99d.zip
Merge pull request #13439 from owncloud/app-filter
Make the search box filter apps
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/apps.js133
1 files changed, 85 insertions, 48 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js
index f844bcc08e2..c15d6a0f74d 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -330,67 +330,104 @@ OC.Settings.Apps = OC.Settings.Apps || {
$('div#app-'+appId+' .warning')
.hide()
.text('');
- }
+ },
-};
+ filter: function(query) {
+ query = query.toLowerCase();
+ $('#apps-list').find('.section').addClass('hidden');
-$(document).ready(function () {
- OC.Settings.Apps.loadCategories();
+ var apps = _.filter(OC.Settings.Apps.State.apps, function (app) {
+ return app.name.toLowerCase().indexOf(query) !== -1;
+ });
- $(document).on('click', 'ul#apps-categories li', function () {
- var categoryId = $(this).data('categoryId');
- OC.Settings.Apps.loadCategory(categoryId);
- });
+ apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
+ return app.description.toLowerCase().indexOf(query) !== -1;
+ }));
- $(document).on('click', '#apps-list input.enable', function () {
- var appId = $(this).data('appid');
- var element = $(this);
- var active = $(this).data('active');
+ apps = _.uniq(apps, function(app){return app.id;});
- OC.Settings.Apps.enableApp(appId, active, element);
- });
+ _.each(apps, function (app) {
+ $('#app-' + app.id).removeClass('hidden');
+ });
- $(document).on('click', '#apps-list input.uninstall', function () {
- var appId = $(this).data('appid');
- var element = $(this);
+ $('#searchresults').hide();
+ },
- OC.Settings.Apps.uninstallApp(appId, element);
- });
+ /**
+ * Initializes the apps list
+ */
+ initialize: function($el) {
+ OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search);
+ OC.Settings.Apps.loadCategories();
- $(document).on('click', '#apps-list input.update', function () {
- var appId = $(this).data('appid');
- var element = $(this);
+ $(document).on('click', 'ul#apps-categories li', function () {
+ var categoryId = $(this).data('categoryId');
+ OC.Settings.Apps.loadCategory(categoryId);
+ });
- OC.Settings.Apps.updateApp(appId, element);
- });
+ $(document).on('click', '#apps-list input.enable', function () {
+ var appId = $(this).data('appid');
+ var element = $(this);
+ var active = $(this).data('active');
- $(document).on('change', '#group_select', function() {
- var element = $(this).parent().find('input.enable');
- var groups = $(this).val();
- if (groups && groups !== '') {
- groups = groups.split(',');
- } else {
- groups = [];
- }
+ OC.Settings.Apps.enableApp(appId, active, element);
+ });
- var appId = element.data('appid');
- if (appId) {
- OC.Settings.Apps.enableApp(appId, false, element, groups);
- OC.Settings.Apps.State.apps[appId].groups = groups;
- }
- });
+ $(document).on('click', '#apps-list input.uninstall', function () {
+ var appId = $(this).data('appid');
+ var element = $(this);
- $(document).on('change', ".groups-enable", function() {
- var $select = $(this).parent().find('#group_select');
- $select.val('');
+ OC.Settings.Apps.uninstallApp(appId, element);
+ });
- if (this.checked) {
- OC.Settings.Apps.setupGroupsSelect($select);
- } else {
- $select.select2('destroy');
- }
+ $(document).on('click', '#apps-list input.update', function () {
+ var appId = $(this).data('appid');
+ var element = $(this);
+
+ OC.Settings.Apps.updateApp(appId, element);
+ });
+
+ $(document).on('change', '#group_select', function() {
+ var element = $(this).parent().find('input.enable');
+ var groups = $(this).val();
+ if (groups && groups !== '') {
+ groups = groups.split(',');
+ } else {
+ groups = [];
+ }
+
+ var appId = element.data('appid');
+ if (appId) {
+ OC.Settings.Apps.enableApp(appId, false, element, groups);
+ OC.Settings.Apps.State.apps[appId].groups = groups;
+ }
+ });
+
+ $(document).on('change', ".groups-enable", function() {
+ var $select = $(this).parent().find('#group_select');
+ $select.val('');
+
+ if (this.checked) {
+ OC.Settings.Apps.setupGroupsSelect($select);
+ } else {
+ $select.select2('destroy');
+ }
- $select.change();
- });
+ $select.change();
+ });
+ }
+};
+
+OC.Settings.Apps.Search = {
+ attach: function (search) {
+ search.setFilter('settings', OC.Settings.Apps.filter);
+ }
+};
+
+$(document).ready(function () {
+ // HACK: FIXME: use plugin approach
+ if (!window.TESTING) {
+ OC.Settings.Apps.initialize($('#apps-list'));
+ }
});