Commit 8ba11f1b authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Anja Leichsenring
Browse files

[FOLLOWUP][TASK] Hide selected items in multipleSideBySide

The original patch introduced some regressions which are fixed now:

- Deletion of multiple items works correctly now
- Inserting items by the Element Browser does not throw an error anymore

Resolves: #76071
Releases: master, 7.6
Change-Id: Ie16a1d404c2f12e6c952dc5022caff08ec6af171
Reviewed-on: https://review.typo3.org/48062

Reviewed-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes's avatarNicole Cordes <typo3@cordes.co>
Tested-by: default avatarTomita Militaru <militarutomita@gmail.com>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 26c28061
......@@ -130,20 +130,25 @@ define(['jquery',
// Clear elements if exclusive values are found
if (exclusiveValues) {
var $optionSelect = $optionEl.closest('select');
var reenableOptions = false;
var m = new RegExp('(^|,)' + value + '($|,)');
// the new value is exclusive => remove all existing values
if (exclusiveValues.match(m)) {
$fieldEl.empty();
$optionSelect.find('[disabled]').removeClass('hidden').prop('disabled', false);
reenableOptions = true;
} else if ($fieldEl.children('option').length == 1) {
// there is an old value and it was exclusive => it has to be removed
m = new RegExp("(^|,)" + $fieldEl.children('option').prop('value') + "($|,)");
if (exclusiveValues.match(m)) {
$fieldEl.empty();
$optionSelect.find('[disabled]').removeClass('hidden').prop('disabled', false);
reenableOptions = true;
}
}
if (reenableOptions && typeof $optionEl !== 'undefined') {
$optionEl.closest('select').find('[disabled]').removeClass('hidden').prop('disabled', false)
}
}
// Inserting the new element
......@@ -159,7 +164,7 @@ define(['jquery',
}
});
if (addNewValue) {
if (addNewValue && typeof $optionEl !== 'undefined') {
$optionEl.addClass('hidden').prop('disabled', true);
}
}
......@@ -563,10 +568,12 @@ define(['jquery',
FormEngine.removeOption = function($fieldEl, $availableFieldEl) {
var $selected = $fieldEl.find(':selected');
$availableFieldEl
.find('option[value="' + $selected.attr('value') + '"]')
.removeClass('hidden')
.prop('disabled', false);
$selected.each(function() {
$availableFieldEl
.find('option[value="' + $(this).attr('value') + '"]')
.removeClass('hidden')
.prop('disabled', false);
});
// remove the selected options
$selected.remove();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment