Skip to content

Commit

Permalink
Added support for mixed arrays of authors with or without extra info
Browse files Browse the repository at this point in the history
  • Loading branch information
splitt3r authored and phil-davis committed Jan 8, 2018
1 parent d68646f commit 2e6a1ad
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions settings/js/admin-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
app.previewAsIcon = true;
}

if (_.isArray(app.author)) {
app.author = app.author.join(', ');
}

if (_.isObject(app.author) && !_.isUndefined(app.author['@value'])) {
app.author = app.author['@value'];
}
app.author = this._parseAppAuthor(app.author);

var html = template(app);
if (selector) {
Expand Down Expand Up @@ -208,7 +202,33 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
},

isType: function(app, type){
/**
* Parses the author(s) from the app info response.
*
* @param {(string|string[]|Object|Object[])} author - A string or an array of Objects or strings or both representing the author info from apps info.xml.
* @return {string}
*/
_parseAppAuthor: function (author) {
if (_.isObject(author) && !_.isUndefined(author['@value'])) {
return author['@value'];
}

if (_.isArray(author)) {
var authorNames = [];
for (var i = 0; i < author.length; i++) {
if (_.isObject(author[i]) && !_.isUndefined(author[i]['@value'])) {
authorNames.push(author[i]['@value']);
} else {
authorNames.push(author[i]);
}
}
return authorNames.join(', ');
}

return author;
},

isType: function(app, type) {
return app.types && app.types.indexOf(type) !== -1;
},

Expand Down Expand Up @@ -492,13 +512,7 @@ OC.Settings.Apps = OC.Settings.Apps || {
if (_.isUndefined(app.author)) {
return false;
}
if (_.isArray(app.author)) {
return app.author.join(' ').toLowerCase().indexOf(query) !== -1;
}
if (_.isObject(app.author) && !_.isUndefined(app.author['@value'])) {
return app.author['@value'].toLowerCase().indexOf(query) !== -1;
}
return app.author.toLowerCase().indexOf(query) !== -1;
return self._parseAppAuthor(app.author).toLowerCase().indexOf(query) !== -1;
}));

// App status
Expand Down

0 comments on commit 2e6a1ad

Please sign in to comment.