diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-02-23 15:29:25 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-02-23 15:29:25 +0100 |
commit | e144d3aa49a1e4a3bb487ada9d83a2b4c81e6630 (patch) | |
tree | 9bff13d230fd5b28f745cc5c23e9e6165380903b /settings/js/apps.js | |
parent | 3632962000311e67447f5e3c97cd33095281c7ba (diff) | |
download | nextcloud-server-e144d3aa49a1e4a3bb487ada9d83a2b4c81e6630.tar.gz nextcloud-server-e144d3aa49a1e4a3bb487ada9d83a2b4c81e6630.zip |
Added unit test for app filter
Diffstat (limited to 'settings/js/apps.js')
-rw-r--r-- | settings/js/apps.js | 122 |
1 files changed, 66 insertions, 56 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js index 6e78ce2a6e8..c15d6a0f74d 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -334,7 +334,7 @@ OC.Settings.Apps = OC.Settings.Apps || { filter: function(query) { query = query.toLowerCase(); - $('#apps-list').find('.section').hide(); + $('#apps-list').find('.section').addClass('hidden'); var apps = _.filter(OC.Settings.Apps.State.apps, function (app) { return app.name.toLowerCase().indexOf(query) !== -1; @@ -347,77 +347,87 @@ OC.Settings.Apps = OC.Settings.Apps || { apps = _.uniq(apps, function(app){return app.id;}); _.each(apps, function (app) { - $('#app-' + app.id).show(); + $('#app-' + app.id).removeClass('hidden'); }); $('#searchresults').hide(); - } -}; + }, -OC.Settings.Apps.Search = { - attach: function (search) { - search.setFilter('settings', OC.Settings.Apps.filter); - } -}; + /** + * Initializes the apps list + */ + initialize: function($el) { + OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search); + OC.Settings.Apps.loadCategories(); -$(document).ready(function () { - OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search); - OC.Settings.Apps.loadCategories(); + $(document).on('click', 'ul#apps-categories li', function () { + var categoryId = $(this).data('categoryId'); + OC.Settings.Apps.loadCategory(categoryId); + }); - $(document).on('click', 'ul#apps-categories li', function () { - var categoryId = $(this).data('categoryId'); - OC.Settings.Apps.loadCategory(categoryId); - }); + $(document).on('click', '#apps-list input.enable', function () { + var appId = $(this).data('appid'); + var element = $(this); + var active = $(this).data('active'); - $(document).on('click', '#apps-list input.enable', function () { - var appId = $(this).data('appid'); - var element = $(this); - var active = $(this).data('active'); + OC.Settings.Apps.enableApp(appId, active, element); + }); - OC.Settings.Apps.enableApp(appId, active, element); - }); + $(document).on('click', '#apps-list input.uninstall', function () { + var appId = $(this).data('appid'); + var element = $(this); - $(document).on('click', '#apps-list input.uninstall', function () { - var appId = $(this).data('appid'); - var element = $(this); + OC.Settings.Apps.uninstallApp(appId, element); + }); - OC.Settings.Apps.uninstallApp(appId, element); - }); + $(document).on('click', '#apps-list input.update', function () { + var appId = $(this).data('appid'); + var element = $(this); - $(document).on('click', '#apps-list input.update', function () { - var appId = $(this).data('appid'); - var element = $(this); + OC.Settings.Apps.updateApp(appId, element); + }); - 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 = []; + } - $(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; + } + }); - 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(''); - $(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'); + } - 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')); + } }); |