Merge pull request #1693 from nextcloud/fix-authors-with-mail-and-homepage
Fix authors with mail and homepage
This commit is contained in:
commit
1992d4be48
1 changed files with 46 additions and 6 deletions
|
@ -184,7 +184,15 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
|||
}
|
||||
|
||||
if (_.isArray(app.author)) {
|
||||
app.author = app.author.join(', ');
|
||||
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);
|
||||
|
@ -486,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');
|
||||
|
@ -502,25 +528,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) {
|
||||
if (_.isArray(app.author)) {
|
||||
return app.author.join(', ').toLowerCase().indexOf(query) !== -1;
|
||||
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 app.author.toLowerCase().indexOf(query) !== -1;
|
||||
return OC.Settings.Apps._search(app.author, query);
|
||||
}));
|
||||
|
||||
// App status
|
||||
|
|
Loading…
Reference in a new issue