Skip to content
Snippets Groups Projects
Commit 73e22368 authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

don't mix avatar URL with label text, fixes #3585

Closes #3585

Merge request studip/studip!2491
parent f7cccf79
No related branches found
No related tags found
No related merge requests found
...@@ -17,18 +17,18 @@ ...@@ -17,18 +17,18 @@
<a href="#" class="quickfilter" data-quickfilter="<?= md5($title); ?>"><?= htmlReady($title); ?> (<?= count($users); ?>)</a> <a href="#" class="quickfilter" data-quickfilter="<?= md5($title); ?>"><?= htmlReady($title); ?> (<?= count($users); ?>)</a>
<select multiple="multiple" id="<?= $name . '_quickfilter_' . md5($title); ?>" style="display: none;"> <select multiple="multiple" id="<?= $name . '_quickfilter_' . md5($title); ?>" style="display: none;">
<? foreach($users as $user) : ?> <? foreach($users as $user) : ?>
<option value="<?= $user->id ?>"><?= Avatar::getAvatar($user->id)->getURL(Avatar::MEDIUM); ?> -- <?= htmlReady($user->getFullName('full_rev')) ?> -- <?= htmlReady($user->perms) ?> (<?= htmlReady($user->username)?>)</option> <option value="<?= $user->id ?>" data-avatar="<?= htmlReady(Avatar::getAvatar($user->id)->getURL(Avatar::MEDIUM)) ?>"><?= htmlReady($user->getFullName('full_rev')) ?> -- <?= htmlReady($user->perms) ?> (<?= htmlReady($user->username)?>)</option>
<? endforeach; ?> <? endforeach; ?>
</select> </select>
<? endforeach; ?></p> <? endforeach; ?></p>
<select multiple="multiple" id="<?= $name . '_selectbox'; ?>" name="<?= $name . '_selectbox'; ?>[]" data-init-js="true"> <select multiple="multiple" id="<?= $name . '_selectbox'; ?>" name="<?= $name . '_selectbox'; ?>[]" data-init-js="true">
<? foreach ($defaultSelectableUsers as $person): ?> <? foreach ($defaultSelectableUsers as $person): ?>
<option value="<?= $person->id ?>"><?= Avatar::getAvatar($person->id)->getURL(Avatar::MEDIUM); ?> -- <?= htmlReady($person->getFullName('full_rev')) ?> -- <?= htmlReady($person->perms) ?> (<?= htmlReady($person->username)?>)</option> <option value="<?= $person->id ?>" data-avatar="<?= htmlReady(Avatar::getAvatar($person->id)->getURL(Avatar::MEDIUM)) ?>"><?= htmlReady($person->getFullName('full_rev')) ?> -- <?= htmlReady($person->perms) ?> (<?= htmlReady($person->username)?>)</option>
<? endforeach; ?> <? endforeach; ?>
</select> </select>
<select multiple="multiple" id="<?= $name . '_selectbox_default'; ?>" style="display: none;"> <select multiple="multiple" id="<?= $name . '_selectbox_default'; ?>" style="display: none;">
<? foreach ($defaultSelectedUsers as $person): ?> <? foreach ($defaultSelectedUsers as $person): ?>
<option value="<?= $person->id ?>"><?= Avatar::getAvatar($person->id)->getURL(Avatar::MEDIUM); ?> -- <?= htmlReady($person->getFullName('full_rev')) ?> -- <?= htmlReady($person->perms) ?> (<?= htmlReady($person->username)?>)</option> <option value="<?= $person->id ?>" data-avatar="<?= htmlReady(Avatar::getAvatar($person->id)->getURL(Avatar::MEDIUM)) ?>"><?= htmlReady($person->getFullName('full_rev')) ?> -- <?= htmlReady($person->perms) ?> (<?= htmlReady($person->username)?>)</option>
<? endforeach; ?> <? endforeach; ?>
</select> </select>
......
...@@ -62,12 +62,13 @@ const MultiPersonSearch = { ...@@ -62,12 +62,13 @@ const MultiPersonSearch = {
count += MultiPersonSearch.append( count += MultiPersonSearch.append(
$(this).val(), $(this).val(),
$(this).text(), $(this).text(),
$(this).data('avatar'),
MultiPersonSearch.isAlreadyMember($(this).val()) MultiPersonSearch.isAlreadyMember($(this).val())
); );
}); });
if (count == 0) { if (count == 0) {
MultiPersonSearch.append('--', $gettext(' Dieser Filter enthält keine (neuen) Personen.'), true); MultiPersonSearch.append('--', $gettext(' Dieser Filter enthält keine (neuen) Personen.'), null, true);
} }
MultiPersonSearch.refresh(); MultiPersonSearch.refresh();
...@@ -95,14 +96,15 @@ const MultiPersonSearch = { ...@@ -95,14 +96,15 @@ const MultiPersonSearch = {
$.each(data, function(i, item) { $.each(data, function(i, item) {
searchcount += MultiPersonSearch.append( searchcount += MultiPersonSearch.append(
item.user_id, item.user_id,
item.avatar + ' -- ' + item.text, item.text,
item.avatar,
item.member item.member
); );
}); });
MultiPersonSearch.refresh(); MultiPersonSearch.refresh();
if (searchcount == 0) { if (searchcount == 0) {
MultiPersonSearch.append('--', not_found_template({ needle: searchterm }), true); MultiPersonSearch.append('--', not_found_template({ needle: searchterm }), null, true);
MultiPersonSearch.refresh(); MultiPersonSearch.refresh();
} }
} }
...@@ -135,13 +137,16 @@ const MultiPersonSearch = { ...@@ -135,13 +137,16 @@ const MultiPersonSearch = {
MultiPersonSearch.removeAllNotSelected(); MultiPersonSearch.removeAllNotSelected();
}, },
append: function(value, text, selected) { append: function(value, text, avatar, disabled) {
if ($('#' + this.name + '_selectbox option[value=' + value + ']').length == 0) { if ($('#' + this.name + '_selectbox option[value=' + value + ']').length == 0) {
$('#' + this.name + '_selectbox').multiSelect('addOption', { $('#' + this.name + '_selectbox').multiSelect('addOption', {
value: value, value: value,
text: text, text: text,
disabled: selected disabled: disabled
}); });
if (avatar) {
$('#' + this.name + '_selectbox option[value=' + value + ']').attr('style', 'background-image: url(' + avatar + ')');
}
return 1; return 1;
} }
return 0; return 0;
......
...@@ -38,15 +38,13 @@ import { $gettext } from './lib/gettext.js'; ...@@ -38,15 +38,13 @@ import { $gettext } from './lib/gettext.js';
MultiSelect.prototype.generateLisFromOption = function (option, index, $container) { MultiSelect.prototype.generateLisFromOption = function (option, index, $container) {
let $option = $(option), let $option = $(option),
chunks = $option.html().split(/\s--\s/); chunks = $option.text().split(/\s--\s/);
if (index === -1) { if (index === -1) {
$option.prop('disabled', true); $option.prop('disabled', true);
index = undefined; index = undefined;
} }
if (chunks.length > 1) { if (chunks.length > 1) {
$option.attr('style', 'background-image: url(' + encodeURI(chunks.shift().trim()) + ')');
$option.text(chunks.join("\n")); $option.text(chunks.join("\n"));
if ($option.is(':disabled')) { if ($option.is(':disabled')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment