Start fixing Select2 options

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-01-24 13:39:48 +01:00 committed by John Molakvoæ (skjnldsv)
parent 82137f443d
commit 0e2366233a
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
2 changed files with 16 additions and 10 deletions

View File

@ -64,11 +64,11 @@
// add admin groups
$.each(response.data.adminGroups, function(id, group) {
results.push({ id: group.id });
results.push({ id: group.id, displayname: group.name });
});
// add groups
$.each(response.data.groups, function(id, group) {
results.push({ id: group.id });
results.push({ id: group.id, displayname: group.name });
});
// TODO once limit and offset is implemented for groups we should paginate the search results
@ -79,13 +79,21 @@
}
},
initSelection: function (element, callback) {
callback({id: element.val()});
var groupId = element.val();
if (groupId) {
callback({
id: groupId,
displayname: groupId + 'FIXME' // FIXME
});
} else {
callback();
}
},
formatResult: function (element) {
return '<span>' + escapeHTML(element.id) + '</span>';
return '<span>' + escapeHTML(element.displayname) + '</span>';
},
formatSelection: function (element) {
return '<span title="'+escapeHTML(element.id)+'">'+escapeHTML(element.id)+'</span>';
return '<span title="'+escapeHTML(element.id)+'">'+escapeHTML(element.displayname)+'</span>';
}
});
}

View File

@ -73,12 +73,10 @@ OC.Settings = _.extend(OC.Settings, {
return element.id;
},
initSelection: function(element, callback) {
var selection =
_.map(($(element).val() || []).split('|').sort(),
function(groupName) {
var selection = _.map(($(element).val() || []).split('|').sort(), function(groupId) {
return {
id: groupName,
displayname: groupName
id: groupId,
displayname: groupId + 'FIXME' // FIXME
};
});
callback(selection);