diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2016-10-11 15:29:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 15:29:04 +0300 |
commit | 6fdef86eeb7aabc5e3f9476790b9bc3f3394ae10 (patch) | |
tree | 8edd5f4496ec4895897f03dadb5d930beefc44c0 /settings | |
parent | d7dbec5ee5ebccbfaeb061c99c47e2141a5c435a (diff) | |
parent | 4074d90ef19e548998cf9caaec6c2c63d05f7273 (diff) |
Merge pull request #1690 from nextcloud/backport-1586-fix-multi-translation-names-and-descriptions-9
[stable9] Fix multi translation names and descriptions
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/apps.js | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/settings/js/apps.js b/settings/js/apps.js index 18c2ffd2f67..3f8a7645cf4 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -165,6 +165,18 @@ OC.Settings.Apps = OC.Settings.Apps || { app.previewAsIcon = true; } + if (_.isArray(app.author)) { + var authors = []; + _.each(app.author, function (author) { + if (typeof author === 'string') { + authors.push(author); + } else { + authors.push(author['@value']); + } + }); + app.author = authors.join(', '); + } + var html = template(app); if (selector) { selector.html(html); @@ -450,6 +462,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'); @@ -466,22 +496,39 @@ 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 apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) { - return app.author.toLowerCase().indexOf(query) !== -1; + if (_.isArray(app.author)) { + var authors = []; + _.each(app.author, function (author) { + if (typeof author === 'string') { + authors.push(author); + } else { + authors.push(author['@value']); + if (!_.isUndefined(author['@attributes']['homepage'])) { + authors.push(author['@attributes']['homepage']); + } + if (!_.isUndefined(author['@attributes']['mail'])) { + authors.push(author['@attributes']['mail']); + } + } + }); + return OC.Settings.Apps._search(authors.join(' '), query); + } + return OC.Settings.Apps._search(app.author, query); })); // App status |