Commit 2a2b7f46 authored by Georg Ringer's avatar Georg Ringer Committed by Susanne Moog
Browse files

[FEATURE] Always enable filter in SelectMultipleSideBySide fields

The filter functionality of fields `type = select` with
renderType = selectMultipleSideBySide is always enabled now.

Resolves: #88907
Releases: master
Change-Id: I7332f39abd6444fc164e8b60009690f6af637b73
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61428

Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@maxserv.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@maxserv.com>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
parent 09876053
......@@ -20,8 +20,7 @@ enum Selectors {
}
/**
* Select field filter functions, see TCA option "enableMultiSelectFilterTextfield"
* and "multiSelectFilterItems"
* Select field filter functions, see TCA option "multiSelectFilterItems"
*/
class SelectBoxFilter {
private selectElement: HTMLSelectElement = null;
......
......@@ -150,15 +150,13 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
}
// Html stuff for filter and select filter on top of right side of multi select boxes
$filterTextfield = [];
if ($config['enableMultiSelectFilterTextfield']) {
$filterTextfield[] = '<span class="input-group input-group-sm">';
$filterTextfield[] = '<span class="input-group-addon">';
$filterTextfield[] = '<span class="fa fa-filter"></span>';
$filterTextfield[] = '</span>';
$filterTextfield[] = '<input class="t3js-formengine-multiselect-filter-textfield form-control" value="">';
$filterTextfield[] = '</span>';
}
$filterTextfield[] = '<span class="input-group input-group-sm">';
$filterTextfield[] = '<span class="input-group-addon">';
$filterTextfield[] = '<span class="fa fa-filter"></span>';
$filterTextfield[] = '</span>';
$filterTextfield[] = '<input class="t3js-formengine-multiselect-filter-textfield form-control" value="">';
$filterTextfield[] = '</span>';
$filterDropDownOptions = [];
if (isset($config['multiSelectFilterItems']) && is_array($config['multiSelectFilterItems']) && count($config['multiSelectFilterItems']) > 1) {
foreach ($config['multiSelectFilterItems'] as $optionElement) {
......@@ -171,28 +169,22 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
}
}
$filterHtml = [];
if (!empty($filterTextfield) || !empty($filterDropDownOptions)) {
$filterHtml[] = '<div class="form-multigroup-item-wizard">';
if (!empty($filterTextfield) && !empty($filterDropDownOptions)) {
$filterHtml[] = '<div class="t3js-formengine-multiselect-filter-container form-multigroup-wrap">';
$filterHtml[] = '<div class="form-multigroup-item form-multigroup-element">';
$filterHtml[] = '<select class="form-control input-sm t3js-formengine-multiselect-filter-dropdown">';
$filterHtml[] = implode(LF, $filterDropDownOptions);
$filterHtml[] = '</select>';
$filterHtml[] = '</div>';
$filterHtml[] = '<div class="form-multigroup-item form-multigroup-element">';
$filterHtml[] = implode(LF, $filterTextfield);
$filterHtml[] = '</div>';
$filterHtml[] = '</div>';
} elseif (!empty($filterTextfield)) {
$filterHtml[] = implode(LF, $filterTextfield);
} else {
$filterHtml[] = '<select class="form-control input-sm t3js-formengine-multiselect-filter-dropdown">';
$filterHtml[] = implode(LF, $filterDropDownOptions);
$filterHtml[] = '</select>';
}
$filterHtml[] = '<div class="form-multigroup-item-wizard">';
if (!empty($filterDropDownOptions)) {
$filterHtml[] = '<div class="t3js-formengine-multiselect-filter-container form-multigroup-wrap">';
$filterHtml[] = '<div class="form-multigroup-item form-multigroup-element">';
$filterHtml[] = '<select class="form-control input-sm t3js-formengine-multiselect-filter-dropdown">';
$filterHtml[] = implode(LF, $filterDropDownOptions);
$filterHtml[] = '</select>';
$filterHtml[] = '</div>';
$filterHtml[] = '<div class="form-multigroup-item form-multigroup-element">';
$filterHtml[] = implode(LF, $filterTextfield);
$filterHtml[] = '</div>';
$filterHtml[] = '</div>';
} else {
$filterHtml[] = implode(LF, $filterTextfield);
}
$filterHtml[] = '</div>';
$classes = [];
$classes[] = 'form-control';
......
......@@ -52,6 +52,7 @@ class TcaMigration
$tca = $this->removeSelIconFieldPath($tca);
$tca = $this->removeSetToDefaultOnCopy($tca);
$tca = $this->sanitizeControlSectionIntegrity($tca);
$tca = $this->removeEnableMultiSelectFilterTextfieldConfiguration($tca);
return $tca;
}
......@@ -171,6 +172,32 @@ class TcaMigration
return $tca;
}
/**
* Removes configuration removeEnableMultiSelectFilterTextfield
*
* @param array $tca
* @return array the modified TCA structure
*/
protected function removeEnableMultiSelectFilterTextfieldConfiguration(array $tca): array
{
foreach ($tca as $table => &$tableDefinition) {
if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
continue;
}
foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
if (!isset($fieldConfig['config']['enableMultiSelectFilterTextfield'])) {
continue;
}
$this->messages[] = 'The TCA setting \'enableMultiSelectFilterTextfield\' is deprecated '
. ' and should be removed from TCA for ' . $table . '[\'columns\']'
. '[\'' . $fieldName . '\'][\'config\'][\'enableMultiSelectFilterTextfield\']';
unset($fieldConfig['config']['enableMultiSelectFilterTextfield']);
}
}
return $tca;
}
/**
* Removes $TCA[$mytable][ctrl][selicon_field_path]
*
......
......@@ -50,7 +50,6 @@ return [
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'enableMultiSelectFilterTextfield' => true,
'foreign_table' => 'sys_filemounts',
'foreign_table_where' => ' AND sys_filemounts.pid=0',
'size' => 3,
......@@ -249,7 +248,6 @@ return [
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'enableMultiSelectFilterTextfield' => true,
'foreign_table' => 'be_groups',
'foreign_table_where' => 'AND NOT(be_groups.uid = ###THIS_UID###)',
'size' => 5,
......
......@@ -68,7 +68,6 @@ return [
'foreign_table' => 'be_groups',
'size' => 5,
'maxitems' => 20,
'enableMultiSelectFilterTextfield' => true,
'fieldControl' => [
'editPopup' => [
'disabled' => false,
......@@ -126,7 +125,6 @@ return [
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'enableMultiSelectFilterTextfield' => true,
'foreign_table' => 'sys_filemounts',
'foreign_table_where' => ' AND sys_filemounts.pid=0',
'size' => 3,
......
......@@ -354,7 +354,6 @@ return [
],
'exclusiveKeys' => '-1,-2',
'foreign_table' => 'fe_groups',
'enableMultiSelectFilterTextfield' => true
]
],
'extendToSubpages' => [
......@@ -893,8 +892,7 @@ return [
'renderType' => 'selectMultipleSideBySide',
'size' => 10,
'items' => [],
'enableMultiSelectFilterTextfield' => true,
'softref' => 'ext_fileref'
'softref' => 'ext_fileref',
]
],
],
......
.. include:: ../../Includes.txt
=========================================================================
Feature: #88907 - Always enable filter in SelectMultipleSideBySide fields
=========================================================================
See :issue:`88907`
Description
===========
The filter functionality of fields :php:`type = select` with :php:`renderType = selectMultipleSideBySide`
is always enabled now.
Impact
======
Before:
.. codeblock:: php
'tsconfig_includes' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tsconfig_includes',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'size' => 10,
'items' => [],
'enableMultiSelectFilterTextfield' => true,
'softref' => 'ext_fileref'
]
],
Now just omit the line :php:`'enableMultiSelectFilterTextfield' => true`, the behaviour will stay the same.
A migration wizard is available that removes the option from your TCA and leaves a message where code
adaption has to take place.
.. index:: Backend, TCA, ext:core
......@@ -426,4 +426,57 @@ class TcaMigrationTest extends UnitTestCase
$subject = new TcaMigration();
self::assertSame($expectation, $subject->migrate($tca));
}
/**
* @test
*/
public function removeEnableMultiSelectFilterTextfieldConfigurationIsRemoved()
{
$input = [
'aTable' => [
'columns' => [
'aField' => [
'config' => [
'type' => 'input',
'enableMultiSelectFilterTextfield' => false,
],
],
'bField' => [
'config' => [
'type' => 'select',
],
],
'cField' => [
'config' => [
'type' => 'select',
'enableMultiSelectFilterTextfield' => true,
],
],
]
],
];
$expected = [
'aTable' => [
'columns' => [
'aField' => [
'config' => [
'type' => 'input',
],
],
'bField' => [
'config' => [
'type' => 'select',
],
],
'cField' => [
'config' => [
'type' => 'select',
],
],
],
],
];
$subject = new TcaMigration();
$this->assertEquals($expected, $subject->migrate($input));
}
}
......@@ -56,7 +56,6 @@ return [
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'fe_groups',
'foreign_table_where' => 'AND NOT(fe_groups.uid = ###THIS_UID###)',
'enableMultiSelectFilterTextfield' => true,
'size' => 6,
'autoSizeMax' => 10,
'minitems' => 0,
......
......@@ -50,7 +50,6 @@ return [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'fe_groups',
'enableMultiSelectFilterTextfield' => true,
'size' => 6,
'minitems' => 1,
'maxitems' => 50
......
......@@ -131,7 +131,6 @@ return [
'size' => 10,
'maxitems' => 100,
'items' => [],
'enableMultiSelectFilterTextfield' => true,
'softref' => 'ext_fileref'
]
],
......
......@@ -287,7 +287,6 @@ return [
],
'exclusiveKeys' => '-1,-2',
'foreign_table' => 'fe_groups',
'enableMultiSelectFilterTextfield' => true
]
],
'sys_language_uid' => [
......
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