Merge pull request #2093 from nextcloud/fix-single-author-with-details

Fix single author with details
This commit is contained in:
Joas Schilling 2016-11-14 09:50:57 +01:00 committed by GitHub
commit 4c6e9dccfe
2 changed files with 33 additions and 11 deletions

View File

@ -189,6 +189,8 @@ OC.Settings.Apps = OC.Settings.Apps || {
} }
}); });
app.author = authors.join(', '); app.author = authors.join(', ');
} else if (typeof app.author !== 'string') {
app.author = app.author['@value'];
} }
var html = template(app); var html = template(app);
@ -539,8 +541,8 @@ OC.Settings.Apps = OC.Settings.Apps || {
// Author Name // Author Name
apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) { apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
var authors = [];
if (_.isArray(app.author)) { if (_.isArray(app.author)) {
var authors = [];
_.each(app.author, function (author) { _.each(app.author, function (author) {
if (typeof author === 'string') { if (typeof author === 'string') {
authors.push(author); authors.push(author);
@ -555,6 +557,15 @@ OC.Settings.Apps = OC.Settings.Apps || {
} }
}); });
return OC.Settings.Apps._search(authors.join(' '), query); return OC.Settings.Apps._search(authors.join(' '), query);
} else if (typeof app.author !== 'string') {
authors.push(app.author['@value']);
if (!_.isUndefined(app.author['@attributes']['homepage'])) {
authors.push(app.author['@attributes']['homepage']);
}
if (!_.isUndefined(app.author['@attributes']['mail'])) {
authors.push(app.author['@attributes']['mail']);
}
return OC.Settings.Apps._search(authors.join(' '), query);
} }
return OC.Settings.Apps._search(app.author, query); return OC.Settings.Apps._search(app.author, query);
})); }));

View File

@ -185,26 +185,32 @@ describe('OC.Settings.Apps tests', function() {
{ {
id: 'foo', id: 'foo',
name: 'Foo app', name: 'Foo app',
level: 0 level: 0,
author: 'foo'
}, },
{ {
id: 'alpha', id: 'alpha',
name: 'Alpha app', name: 'Alpha app',
level: 300 level: 300,
author: ['alpha', 'beta']
}, },
{ {
id: 'nolevel', id: 'nolevel',
name: 'No level' name: 'No level',
author: 'bar'
}, },
{ {
id: 'zork', id: 'zork',
name: 'Some famous adventure game', name: 'Some famous adventure game',
level: 200 level: 200,
author: 'baz'
}, },
{ {
id: 'delta', id: 'delta',
name: 'Mathematical symbol', name: 'Mathematical symbol',
level: 200 level: 200,
author: 'foobar'
} }
] ]
}) })
@ -217,26 +223,31 @@ describe('OC.Settings.Apps tests', function() {
'foo': { 'foo': {
id: 'foo', id: 'foo',
name: 'Foo app', name: 'Foo app',
level: 0 level: 0,
author: 'foo'
}, },
'alpha': { 'alpha': {
id: 'alpha', id: 'alpha',
name: 'Alpha app', name: 'Alpha app',
level: 300 level: 300,
author: ['alpha', 'beta']
}, },
'nolevel': { 'nolevel': {
id: 'nolevel', id: 'nolevel',
name: 'No level' name: 'No level',
author: 'bar'
}, },
'zork': { 'zork': {
id: 'zork', id: 'zork',
name: 'Some famous adventure game', name: 'Some famous adventure game',
level: 200 level: 200,
author: 'baz',
}, },
'delta': { 'delta': {
id: 'delta', id: 'delta',
name: 'Mathematical symbol', name: 'Mathematical symbol',
level: 200 level: 200,
author: 'foobar'
} }
}); });
}); });