Skip to content

Commit 1c9f4da

Browse files
committed
[TASK] Rename web component 'typo3-formengine-element-select-check-box'
The functionality of the web component `<typo3-formengine-element- select-check-box></typo3-formengine-element-select-check-box>` should not be exclusively for use in FormEngine. Therefore, the component is renamed and moved. Resolves: #104636 Related: #98683 Related: #104142 Releases: main Change-Id: Id6a639a8a6b262edc19fc0d96831406950e45783 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85652 Tested-by: Christian Kuhn <[email protected]> Reviewed-by: Christian Kuhn <[email protected]> Reviewed-by: Oliver Bartsch <[email protected]> Tested-by: Oliver Bartsch <[email protected]> Reviewed-by: Jasmina Ließmann <[email protected]> Tested-by: Jasmina Ließmann <[email protected]> Tested-by: core-ci <[email protected]>
1 parent 85739f4 commit 1c9f4da

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

Build/Sources/TypeScript/backend/form-engine/element/select-check-box-element.ts renamed to Build/Sources/TypeScript/backend/element/collapsible-element.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,32 @@
1414
import RegularEvent from '@typo3/core/event/regular-event';
1515
import Icons from '@typo3/backend/icons';
1616

17-
enum Identifier {
18-
toggleGroup = '.t3js-toggle-selectcheckbox-group',
19-
}
20-
2117
enum IconIdentifier {
2218
collapse = 'actions-view-list-collapse',
2319
expand = 'actions-view-list-expand',
2420
}
2521

2622
/**
27-
* Module: @typo3/backend/form-engine/element/select-check-box-element
23+
* Module: @typo3/backend/element/collapsible-element
2824
*
29-
* Functionality for the selectCheckBox element
25+
* Functionality for collapsible elements like accordions and panels
3026
*
3127
* @example
32-
* <typo3-formengine-element-select-check-box>
28+
* <typo3-backend-collapsible>
3329
* ...
34-
* </typo3-formengine-element-select-check-box>
30+
* </typo3-backend-collapsible>
3531
*
3632
* This is based on W3C custom elements ("web components") specification, see
3733
* https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements
3834
*/
39-
class SelectCheckBoxElement extends HTMLElement {
35+
class CollapsibleElement extends HTMLElement {
4036

4137
public connectedCallback(): void {
4238
this.registerEventHandler();
4339
}
4440

4541
private registerEventHandler(): void {
46-
new RegularEvent('click', this.toggleGroup).delegateTo(this, Identifier.toggleGroup);
42+
new RegularEvent('click', this.toggleGroup).delegateTo(this, 'button[data-bs-toggle="collapse"]');
4743
}
4844

4945
private toggleGroup(e: MouseEvent, targetEl: HTMLElement): void {
@@ -59,4 +55,4 @@ class SelectCheckBoxElement extends HTMLElement {
5955
}
6056
}
6157

62-
window.customElements.define('typo3-formengine-element-select-check-box', SelectCheckBoxElement);
58+
window.customElements.define('typo3-backend-collapsible', CollapsibleElement);

typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function render(): array
152152
$fieldWizardHtml = $fieldWizardResult['html'];
153153
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false);
154154

155-
$html[] = '<typo3-formengine-element-select-check-box class="formengine-field-item t3js-formengine-field-item" data-formengine-validation-rules="' . htmlspecialchars($this->getValidationDataAsJsonString($config)) . '">';
155+
$html[] = '<typo3-backend-collapsible class="formengine-field-item t3js-formengine-field-item" data-formengine-validation-rules="' . htmlspecialchars($this->getValidationDataAsJsonString($config)) . '">';
156156
$html[] = $fieldInformationHtml;
157157
$html[] = '<div class="form-wizards-wrap">';
158158
$html[] = '<div class="form-wizards-element">';
@@ -174,7 +174,7 @@ public function render(): array
174174
$expanded = ($config['appearance']['expandAll'] ?? false) ? 'true' : 'false';
175175
$icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon((($config['appearance']['expandAll'] ?? false) ? 'actions-view-list-collapse' : 'actions-view-list-expand'), IconSize::SMALL)->render() . '</span>';
176176

177-
$html[] = '<button type="button" class="t3js-toggle-selectcheckbox-group panel-heading panel-heading-button" aria-expanded="' . $expanded . '"';
177+
$html[] = '<button type="button" class="panel-heading panel-heading-button" aria-expanded="' . $expanded . '"';
178178
$html[] = ' aria-controls="' . $groupCollapsibleId . '" data-bs-target="#' . $groupCollapsibleId . '" data-bs-toggle="collapse">';
179179
$html[] = '<span class="flex-grow-1 align-self-center">';
180180
$html[] = $group['header']['icon'];
@@ -249,7 +249,7 @@ public function render(): array
249249

250250
// Add JavaScript module. This is only needed, in case the element
251251
// is not readOnly, since otherwise no checkbox changes take place.
252-
$resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/backend/form-engine/element/select-check-box-element.js');
252+
$resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/backend/element/collapsible-element.js');
253253
$resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create('@typo3/backend/multi-record-selection.js');
254254
}
255255
$html[] = '<tbody>' . implode(LF, $tableRows) . '</tbody>';
@@ -269,7 +269,7 @@ public function render(): array
269269
$html[] = '</div>';
270270
}
271271
$html[] = '</div>';
272-
$html[] = '</typo3-formengine-element-select-check-box>';
272+
$html[] = '</typo3-backend-collapsible>';
273273

274274
$resultArray['html'] = $this->wrapWithFieldsetAndLegend(implode(LF, $html));
275275
return $resultArray;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* This file is part of the TYPO3 CMS project.
3+
*
4+
* It is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License, either version 2
6+
* of the License, or any later version.
7+
*
8+
* For the full copyright and license information, please read the
9+
* LICENSE.txt file that was distributed with this source code.
10+
*
11+
* The TYPO3 project - inspiring people to share!
12+
*/
13+
import RegularEvent from"@typo3/core/event/regular-event.js";import Icons from"@typo3/backend/icons.js";var IconIdentifier;!function(e){e.collapse="actions-view-list-collapse",e.expand="actions-view-list-expand"}(IconIdentifier||(IconIdentifier={}));class CollapsibleElement extends HTMLElement{connectedCallback(){this.registerEventHandler()}registerEventHandler(){new RegularEvent("click",this.toggleGroup).delegateTo(this,'button[data-bs-toggle="collapse"]')}toggleGroup(e,n){e.preventDefault();const t="true"===n.ariaExpanded,l=n.querySelector(".collapseIcon"),o=t?IconIdentifier.collapse:IconIdentifier.expand;Icons.getIcon(o,Icons.sizes.small).then((e=>{l.innerHTML=e}))}}window.customElements.define("typo3-backend-collapsible",CollapsibleElement);

typo3/sysext/backend/Resources/Public/JavaScript/form-engine/element/select-check-box-element.js

-13
This file was deleted.

0 commit comments

Comments
 (0)