diff --git a/Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ColumnSelectorButton.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ColumnSelectorButton.ts similarity index 96% rename from Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ColumnSelectorButton.ts rename to Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ColumnSelectorButton.ts index 881740c38af11d2306fc590c0a0c6e8dfb229589..ee9777c18cef105e098db4154e40bb0b8d4d30a4 100644 --- a/Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ColumnSelectorButton.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/ColumnSelectorButton.ts @@ -22,10 +22,10 @@ import {AjaxResponse} from 'TYPO3/CMS/Core/Ajax/AjaxResponse'; import Notification = require('TYPO3/CMS/Backend/Notification'); enum Selectors { - columnsSelector = '.t3js-record-column-selector', + columnsSelector = '.t3js-column-selector', columnsContainerSelector = '.t3js-column-selector-container', columnsFilterSelector = 'input[name="columns-filter"]', - columnsSelectorActionsSelector = '.t3js-record-column-selector-actions' + columnsSelectorActionsSelector = '.t3js-column-selector-actions' } enum SelectorActions { @@ -35,10 +35,10 @@ enum SelectorActions { } /** - * Module: TYPO3/CMS/Recordlist/ColumnSelectorButton + * Module: TYPO3/CMS/Backend/ColumnSelectorButton * * @example - * <typo3-recordlist-column-selector-button + * <typo3-backend-column-selector-button * url="/url/to/column/selector/form" * target="/url/to/go/after/column/selection" * title="Show columns" @@ -47,9 +47,9 @@ enum SelectorActions { * close="Error" * > * <button>Show columns/button> - * </typo3-recordlist-column-selector-button> + * </typo3-backend-column-selector-button> */ -@customElement('typo3-recordlist-column-selector-button') +@customElement('typo3-backend-column-selector-button') class ColumnSelectorButton extends LitElement { @property({type: String}) url: string; @property({type: String}) target: string; @@ -181,7 +181,7 @@ class ColumnSelectorButton extends LitElement { this.abortSelection(); return; } - (new AjaxRequest(TYPO3.settings.ajaxUrls.record_show_columns)) + (new AjaxRequest(TYPO3.settings.ajaxUrls.show_columns)) .post('', {body: new FormData(form)}) .then(async (response: AjaxResponse): Promise<any> => { const data = await response.resolve(); diff --git a/typo3/sysext/recordlist/Classes/Controller/ColumnSelectorController.php b/typo3/sysext/backend/Classes/Controller/ColumnSelectorController.php similarity index 92% rename from typo3/sysext/recordlist/Classes/Controller/ColumnSelectorController.php rename to typo3/sysext/backend/Classes/Controller/ColumnSelectorController.php index 33dbbb678bd8ad36d277fe96cb0ff92f562f05d3..2ed0d4d206e1c11c1b057ed6f4e41004af5bad08 100644 --- a/typo3/sysext/recordlist/Classes/Controller/ColumnSelectorController.php +++ b/typo3/sysext/backend/Classes/Controller/ColumnSelectorController.php @@ -15,7 +15,7 @@ declare(strict_types=1); * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\Recordlist\Controller; +namespace TYPO3\CMS\Backend\Controller; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; @@ -25,11 +25,10 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; -use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; use TYPO3Fluid\Fluid\View\ViewInterface; /** - * Controller for handling the display column selection for records, typically executed from the list module. + * Controller for handling the display column selection for records, typically executed from list modules. * * @internal This class is a specific Backend controller implementation and is not part of the TYPO3's Core API. */ @@ -72,7 +71,7 @@ class ColumnSelectorController return $this->jsonResponse([ 'success' => false, 'message' => htmlspecialchars( - $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:updateColumnView.nothingUpdated') + $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_column_selector.xlf:updateColumnView.nothingUpdated') ) ]); } @@ -102,7 +101,7 @@ class ColumnSelectorController $view = GeneralUtility::makeInstance(StandaloneView::class); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName( - 'EXT:recordlist/Resources/Private/Templates/ColumnSelector.html' + 'EXT:backend/Resources/Private/Templates/ColumnSelector.html' )); $view->assignMultiple([ @@ -132,10 +131,7 @@ class ColumnSelectorController $fields = $this->getFileFields(); } else { // Request fields from table and add pseudo fields - $fields = array_merge( - GeneralUtility::makeInstance(DatabaseRecordList::class)->makeFieldList($table, false, true), - self::PSEUDO_FIELDS - ); + $fields = array_merge(BackendUtility::getAllowedFieldsForTable($table), self::PSEUDO_FIELDS); } $columns = $specialColumns = $disabledColumns = []; @@ -207,7 +203,7 @@ class ColumnSelectorController { // Get all sys_file fields expect excluded ones $fileFields = array_filter( - GeneralUtility::makeInstance(DatabaseRecordList::class)->makeFieldList('sys_file', false, true), + BackendUtility::getAllowedFieldsForTable('sys_file'), static fn (string $field): bool => !in_array($field, self::EXCLUDE_FILE_FIELDS, true) ); @@ -216,7 +212,7 @@ class ColumnSelectorController // Get all sys_file_metadata fields expect excluded ones $fileMetaDataFields = array_filter( - GeneralUtility::makeInstance(DatabaseRecordList::class)->makeFieldList('sys_file_metadata', false, true), + BackendUtility::getAllowedFieldsForTable('sys_file_metadata'), static fn (string $field): bool => !in_array($field, $excludeFields, true) ); diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index a6dc7b2dbe1169e81f0ba5b0bea209f41e106041..3fb413b84260d5a5d7d10cfd36e8c32991c7948b 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -3628,6 +3628,71 @@ class BackendUtility return !empty($GLOBALS['TCA'][$table]['ctrl']['security']['ignoreRootLevelRestriction']); } + /** + * Get all fields of a table, which are allowed for the current user + * + * @param string $table Table name + * @param bool $checkUserAccess If set, users access to the field (non-exclude-fields) is checked. + * @return string[] Array, where values are fieldnames + * @internal should only be used from within TYPO3 Core + */ + public static function getAllowedFieldsForTable(string $table, bool $checkUserAccess = true): array + { + if (!is_array($GLOBALS['TCA'][$table]['columns'] ?? null)) { + self::getLogger()->error('TCA is broken for the table "' . $table . '": no required "columns" entry in TCA.'); + return []; + } + + $fieldList = []; + $backendUser = self::getBackendUserAuthentication(); + + // Traverse configured columns and add them to field array, if available for user. + foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $fieldValue) { + if (($fieldValue['config']['type'] ?? '') === 'none') { + // Never render or fetch type=none fields from db + continue; + } + if (!$checkUserAccess + || ( + ( + !($fieldValue['exclude'] ?? null) + || $backendUser->check('non_exclude_fields', $table . ':' . $fieldName) + ) + && ($fieldValue['config']['type'] ?? '') !== 'passthrough' + ) + ) { + $fieldList[] = $fieldName; + } + } + + $fieldList[] = 'uid'; + $fieldList[] = 'pid'; + + // Add more special fields (e.g. date fields) if user should not be checked or is admin + if (!$checkUserAccess || $backendUser->isAdmin()) { + if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'] ?? false) { + $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['tstamp']; + } + if ($GLOBALS['TCA'][$table]['ctrl']['crdate'] ?? false) { + $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['crdate']; + } + if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id'] ?? false) { + $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['cruser_id']; + } + if ($GLOBALS['TCA'][$table]['ctrl']['sortby'] ?? false) { + $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['sortby']; + } + if (self::isTableWorkspaceEnabled($table)) { + $fieldList[] = 't3ver_state'; + $fieldList[] = 't3ver_wsid'; + $fieldList[] = 't3ver_oid'; + } + } + + // Return unique field list + return array_values(array_unique($fieldList)); + } + /** * @param string $table * @return Connection diff --git a/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php b/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php index e608ca1ff433f4adef57e7078e015706bba123fe..7874bbff7f6325bfb999cfa19db78a6f5600636b 100644 --- a/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php +++ b/typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php @@ -319,5 +319,16 @@ return [ 'context_help' => [ 'path' => '/context-help', 'target' => \TYPO3\CMS\Backend\Controller\ContextHelpAjaxController::class . '::getHelpAction' - ] + ], + + // column selector + 'show_columns' => [ + 'path' => '/show/columns', + 'methods' => ['POST'], + 'target' => \TYPO3\CMS\Backend\Controller\ColumnSelectorController::class . '::updateVisibleColumnsAction' + ], + 'show_columns_selector' => [ + 'path' => '/show/columns/selector', + 'target' => \TYPO3\CMS\Backend\Controller\ColumnSelectorController::class . '::showColumnsSelectorAction' + ], ]; diff --git a/typo3/sysext/backend/Configuration/Services.yaml b/typo3/sysext/backend/Configuration/Services.yaml index 921589da63ee6e7884f1cd6b8580a871cd5bb663..6ad5f33e2020c2da34ee5ddd51b89152a97449d0 100644 --- a/typo3/sysext/backend/Configuration/Services.yaml +++ b/typo3/sysext/backend/Configuration/Services.yaml @@ -98,6 +98,9 @@ services: TYPO3\CMS\Backend\Controller\SwitchUserController: tags: ['backend.controller'] + TYPO3\CMS\Backend\Controller\ColumnSelectorController: + tags: ['backend.controller'] + TYPO3\CMS\Backend\Controller\Wizard\TableController: tags: ['backend.controller'] diff --git a/typo3/sysext/backend/Resources/Private/Language/locallang_column_selector.xlf b/typo3/sysext/backend/Resources/Private/Language/locallang_column_selector.xlf new file mode 100644 index 0000000000000000000000000000000000000000..adf93dc1a213f88fd8e08bfecc16bbf6898b7856 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Language/locallang_column_selector.xlf @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> + <file source-language="en" datatype="plaintext" original="EXT:backend/Resources/Private/Language/locallang_column_selector.xlf" date="2021-08-25T02:11:02Z" product-name="backend"> + <header/> + <body> + <trans-unit id="showColumns" resname="showColumns"> + <source>Show Columns</source> + </trans-unit> + <trans-unit id="showColumnsSelection" resname="showColumnsSelection"> + <source>Show columns for %s</source> + </trans-unit> + <trans-unit id="updateColumnView" resname="updateColumnView"> + <source>Update</source> + </trans-unit> + <trans-unit id="updateColumnView.nothingUpdated" resname="updateColumnView.nothingUpdated"> + <source>No columns were updated</source> + </trans-unit> + <trans-unit id="updateColumnView.error" resname="updateColumnView.error"> + <source>Could not update columns</source> + </trans-unit> + <trans-unit id="columnsFilter" resname="columnsFilter"> + <source>Filter by:</source> + </trans-unit> + </body> + </file> +</xliff> diff --git a/typo3/sysext/recordlist/Resources/Private/Templates/ColumnSelector.html b/typo3/sysext/backend/Resources/Private/Templates/ColumnSelector.html similarity index 94% rename from typo3/sysext/recordlist/Resources/Private/Templates/ColumnSelector.html rename to typo3/sysext/backend/Resources/Private/Templates/ColumnSelector.html index feded6a586231f5302a9eac41f29726ea47aa840..3a5a95db31a3c5ccd685117a1babf62fea9e22eb 100644 --- a/typo3/sysext/recordlist/Resources/Private/Templates/ColumnSelector.html +++ b/typo3/sysext/backend/Resources/Private/Templates/ColumnSelector.html @@ -4,12 +4,12 @@ <div class="row row-cols-auto justify-content-between"> <div class="col flex-grow-1"> <div class="input-group"> - <span class="input-group-addon" id="columns-filter-label"><f:translate key="LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:columnsFilter" /></span> + <span class="input-group-addon" id="columns-filter-label"><f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:columnsFilter" /></span> <input type="search" name="columns-filter" class="form-control" value="" aria-labelledby="columns-filter-label" placeholder="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.enterSearchString')}"> </div> </div> <div class="col"> - <div class="row row-cols-auto justify-content-end g-2 t3js-record-column-selector-actions"> + <div class="row row-cols-auto justify-content-end g-2 t3js-column-selector-actions"> <div class="col"> <button type="button" class="btn btn-default disabled" data-action="select-all"> <core:icon identifier="actions-check-square"/> <f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.checkAll" /> @@ -38,7 +38,7 @@ type="checkbox" id="select-column-{table}-{column.name}" name="selectedColumns[]" - class="form-check-input t3js-record-column-selector" + class="form-check-input t3js-column-selector" value="{column.name}" {f:if(condition:'{column.selected}', then:' checked')} {f:if(condition:'{column.disabled}', then: 'disabled')} diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ColumnSelectorButton.js b/typo3/sysext/backend/Resources/Public/JavaScript/ColumnSelectorButton.js new file mode 100644 index 0000000000000000000000000000000000000000..e3ea8a0b876e4cf25e96e28494fb30524b798d9a --- /dev/null +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ColumnSelectorButton.js @@ -0,0 +1,13 @@ +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ +var __decorate=this&&this.__decorate||function(e,t,o,l){var r,n=arguments.length,s=n<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,o):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,l);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(s=(n<3?r(s):n>3?r(t,o,s):r(t,o))||s);return n>3&&s&&Object.defineProperty(t,o,s),s},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","lit","lit/decorators","TYPO3/CMS/Backend/Enum/Severity","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Core/lit-helper","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Notification"],(function(e,t,o,l,r,n,s,c,i,a){"use strict";var d,u,p;Object.defineProperty(t,"__esModule",{value:!0}),i=__importDefault(i),function(e){e.columnsSelector=".t3js-column-selector",e.columnsContainerSelector=".t3js-column-selector-container",e.columnsFilterSelector='input[name="columns-filter"]',e.columnsSelectorActionsSelector=".t3js-column-selector-actions"}(u||(u={})),function(e){e.toggle="select-toggle",e.all="select-all",e.none="select-none"}(p||(p={}));let m=d=class extends o.LitElement{constructor(){super(),this.title="Show columns",this.ok=c.lll("button.ok")||"Update",this.close=c.lll("button.close")||"Close",this.error="Could not update columns",this.addEventListener("click",e=>{e.preventDefault(),this.showColumnSelectorModal()})}static toggleSelectorActions(e,t,o,l=!1){t.classList.add("disabled");for(let o=0;o<e.length;o++)if(!e[o].disabled&&!e[o].checked&&(l||!d.isColumnHidden(e[o]))){t.classList.remove("disabled");break}o.classList.add("disabled");for(let t=0;t<e.length;t++)if(!e[t].disabled&&e[t].checked&&(l||!d.isColumnHidden(e[t]))){o.classList.remove("disabled");break}}static isColumnHidden(e){var t;return null===(t=e.closest(u.columnsContainerSelector))||void 0===t?void 0:t.classList.contains("hidden")}static filterColumns(e,t){t.forEach(t=>{var o;const l=t.closest(u.columnsContainerSelector);if(!t.disabled&&null!==l){const t=null===(o=l.querySelector(".form-check-label-text"))||void 0===o?void 0:o.textContent;t&&t.length&&l.classList.toggle("hidden",""!==e.value&&!RegExp(e.value,"i").test(t.trim().replace(/\[\]/g,"").replace(/\s+/g," ")))}})}render(){return o.html`<slot></slot>`}showColumnSelectorModal(){this.url&&this.target&&s.advanced({content:this.url,title:this.title,severity:r.SeverityEnum.notice,size:s.sizes.medium,type:s.types.ajax,buttons:[{text:this.close,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>s.dismiss()},{text:this.ok,btnClass:"btn-"+n.getCssClass(r.SeverityEnum.info),name:"update",trigger:()=>this.proccessSelection(s.currentModal[0])}],ajaxCallback:()=>this.handleModalContentLoaded(s.currentModal[0])})}proccessSelection(e){const t=e.querySelector("form");null!==t?new i.default(TYPO3.settings.ajaxUrls.show_columns).post("",{body:new FormData(t)}).then(async e=>{const t=await e.resolve();!0===t.success?(this.ownerDocument.location.href=this.target,this.ownerDocument.location.reload(!0)):a.error(t.message||"No update was performed"),s.dismiss()}).catch(()=>{this.abortSelection()}):this.abortSelection()}handleModalContentLoaded(e){const t=e.querySelector("form");if(null===t)return;t.addEventListener("submit",e=>{e.preventDefault()});const o=e.querySelectorAll(u.columnsSelector),l=e.querySelector(u.columnsFilterSelector),r=e.querySelector(u.columnsSelectorActionsSelector),n=r.querySelector('button[data-action="'+p.all+'"]'),s=r.querySelector('button[data-action="'+p.none+'"]');o.length&&null!==l&&null!==n&&null!==s&&(d.toggleSelectorActions(o,n,s,!0),o.forEach(e=>{e.addEventListener("change",()=>{d.toggleSelectorActions(o,n,s)})}),l.addEventListener("keydown",e=>{const t=e.target;"Escape"===e.code&&(e.stopImmediatePropagation(),t.value="")}),l.addEventListener("keyup",e=>{d.filterColumns(e.target,o),d.toggleSelectorActions(o,n,s)}),l.addEventListener("search",e=>{d.filterColumns(e.target,o),d.toggleSelectorActions(o,n,s)}),r.querySelectorAll("button[data-action]").forEach(e=>{e.addEventListener("click",e=>{e.preventDefault();const t=e.currentTarget;if(t.dataset.action){switch(t.dataset.action){case p.toggle:o.forEach(e=>{e.disabled||d.isColumnHidden(e)||(e.checked=!e.checked)});break;case p.all:o.forEach(e=>{e.disabled||d.isColumnHidden(e)||(e.checked=!0)});break;case p.none:o.forEach(e=>{e.disabled||d.isColumnHidden(e)||(e.checked=!1)});break;default:a.warning("Unknown selector action")}d.toggleSelectorActions(o,n,s)}})}))}abortSelection(){a.error(this.error),s.dismiss()}};__decorate([l.property({type:String})],m.prototype,"url",void 0),__decorate([l.property({type:String})],m.prototype,"target",void 0),__decorate([l.property({type:String})],m.prototype,"title",void 0),__decorate([l.property({type:String})],m.prototype,"ok",void 0),__decorate([l.property({type:String})],m.prototype,"close",void 0),__decorate([l.property({type:String})],m.prototype,"error",void 0),m=d=__decorate([l.customElement("typo3-backend-column-selector-button")],m)})); \ No newline at end of file diff --git a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php index 4af0141923195ad17825e7d3f711b2010fdb9773..d20647e0cab5d09cb7a7632fad02d29773f2e5e0 100644 --- a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php +++ b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php @@ -23,6 +23,7 @@ use Psr\EventDispatcher\EventDispatcherInterface; use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher; use TYPO3\CMS\Backend\Tests\Unit\Utility\Fixtures\LabelFromItemListMergedReturnsCorrectFieldsFixture; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Configuration\Event\ModifyLoadedPageTsConfigEvent; @@ -1224,4 +1225,56 @@ class BackendUtilityTest extends UnitTestCase $uid = 42; self::assertSame(42, BackendUtility::wsMapId($tableName, $uid)); } + + /** + * @test + */ + public function makeFieldListReturnsEmptyArrayOnBrokenTca(): void + { + $GLOBALS['BE_USER'] = new BackendUserAuthentication(); + self::assertEmpty(BackendUtility::getAllowedFieldsForTable('myTabe', false)); + } + + /** + * @test + */ + public function makeFieldListReturnsUniqueList(): void + { + $GLOBALS['BE_USER'] = new BackendUserAuthentication(); + $GLOBALS['TCA']['myTable'] = [ + 'ctrl'=> [ + 'tstamp' => 'updatedon', + // Won't be added due to defined in "columns" + 'crdate' => 'createdon', + 'cruser_id' => 'createdby', + 'sortby' => 'sorting', + 'versioningWS' => true, + ], + 'columns' => [ + // Regular field + 'title' => [ + 'config' => [ + 'type' => 'input' + ], + ], + // Overwrite automatically set management field from "ctrl" + 'createdon' => [ + 'config' => [ + 'type' => 'input' + ], + ], + // Won't be added due to type "none" + 'reference' => [ + 'config' => [ + 'type' => 'none' + ], + ] + ] + ]; + + self::assertEquals( + ['title', 'createdon', 'uid', 'pid', 'updatedon', 'createdby', 'sorting', 't3ver_state', 't3ver_wsid', 't3ver_oid'], + BackendUtility::getAllowedFieldsForTable('myTable', false) + ); + } } diff --git a/typo3/sysext/filelist/Classes/Controller/FileListController.php b/typo3/sysext/filelist/Classes/Controller/FileListController.php index fd1c1eb3d55c6b885f06cbb32a6d9790462ea9c9..30e8abd961d1cc4aa92dd2818084f1d968152514 100644 --- a/typo3/sysext/filelist/Classes/Controller/FileListController.php +++ b/typo3/sysext/filelist/Classes/Controller/FileListController.php @@ -269,7 +269,7 @@ class FileListController implements LoggerAwareInterface $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/MultiRecordSelection'); - $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ColumnSelectorButton'); + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ColumnSelectorButton'); $this->pageRenderer->addInlineLanguageLabelFile( 'EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons' @@ -411,11 +411,11 @@ class FileListController implements LoggerAwareInterface if ($this->getBackendUser()->getTSConfig()['options.']['file_list.']['displayColumnSelector'] ?? true) { $this->view->assign('columnSelector', [ 'url' => $this->uriBuilder->buildUriFromRoute( - 'ajax_record_show_columns_selector', + 'ajax_show_columns_selector', ['id' => $this->id, 'table' => '_FILE'] ), 'title' => sprintf( - $lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:showColumnsSelection'), + $lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:showColumnsSelection'), $lang->sL($GLOBALS['TCA']['sys_file']['ctrl']['title'] ?? ''), ), ]); diff --git a/typo3/sysext/filelist/Resources/Private/Templates/File/List.html b/typo3/sysext/filelist/Resources/Private/Templates/File/List.html index 74653e46b7552e76df652690f33ed2891a508065..410d151771e19672c17b8542292aaff86fc6cd51 100644 --- a/typo3/sysext/filelist/Resources/Private/Templates/File/List.html +++ b/typo3/sysext/filelist/Resources/Private/Templates/File/List.html @@ -82,18 +82,18 @@ <div class="row row-cols-auto align-items-center gx-3"> <f:if condition="{columnSelector}"> <div class="col"> - <typo3-recordlist-column-selector-button + <typo3-backend-column-selector-button url="{columnSelector.url}" target="{listUrl}" title="{columnSelector.title}" - ok="{f:translate(key: 'LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:updateColumnView')}" + ok="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:updateColumnView')}" close="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.cancel')}" - error="{f:translate(key: 'LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:updateColumnView.error')}"> + error="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:updateColumnView.error')}"> <button type="button" class="btn btn-default btn-sm" title="{columnSelector.title}"> <core:icon identifier="actions-options" size="small" /> - <f:translate key="LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:showColumns" /> + <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:showColumns" /> </button> - </typo3-recordlist-column-selector-button> + </typo3-backend-column-selector-button> </div> </f:if> <f:if condition="{displayThumbs.enabled}"> diff --git a/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php b/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php index b073849a20165398517d7a31d46dec99051689be..b356455edde06bab695dd8df70fa7bbe6a4c1357 100644 --- a/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php @@ -45,8 +45,8 @@ class DatabaseBrowser extends AbstractElementBrowser implements ElementBrowserIn parent::initialize(); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/BrowseDatabase'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tree/PageBrowser'); + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ColumnSelectorButton'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/RecordDownloadButton'); - $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ColumnSelectorButton'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/RecordSearch'); } diff --git a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php index 37d16f05c0534e6adac9dfeaf1aedb3974eaafe6..bd2faed6d6a34c5c6d1041c3812300fe33fd0251 100644 --- a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php +++ b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php @@ -111,10 +111,10 @@ class RecordListController $this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/RecordDownloadButton'); - $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ColumnSelectorButton'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/ClearCache'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Recordlist/RecordSearch'); $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler'); + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ColumnSelectorButton'); $this->pageRenderer->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf'); BackendUtility::lockRecords(); diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php index 6ff5aa8a8dff140cbf8a5f8561a9cbc97dde82e1..31d48863b63ec3ca6315a62076a1c09602187f44 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php @@ -39,7 +39,6 @@ use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException; use TYPO3\CMS\Core\LinkHandling\LinkService; use TYPO3\CMS\Core\Localization\LanguageService; -use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Service\DependencyOrderingService; use TYPO3\CMS\Core\Type\Bitmask\Permission; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; @@ -440,7 +439,7 @@ class DatabaseRecordList // Setting fields selected in columnSelectorBox (saved in uc) $rowListArray = []; if (is_array($this->setFields[$table] ?? null)) { - $rowListArray = $this->makeFieldList($table, false, true); + $rowListArray = BackendUtility::getAllowedFieldsForTable($table); if ($includeMetaColumns) { $rowListArray[] = '_PATH_'; $rowListArray[] = '_REF_'; @@ -531,7 +530,7 @@ class DatabaseRecordList } // Unique list! $selectFields = array_unique($selectFields); - $fieldListFields = $this->makeFieldList($table, true); + $fieldListFields = BackendUtility::getAllowedFieldsForTable($table, false); // Making sure that the fields in the field-list ARE in the field-list from TCA! return array_intersect($selectFields, $fieldListFields); } @@ -2043,29 +2042,29 @@ class DatabaseRecordList $lang = $this->getLanguageService(); $tableIdentifier = $table . (($table === 'pages' && $this->showOnlyTranslatedRecords) ? '_translated' : ''); $columnSelectorUrl = $this->uriBuilder->buildUriFromRoute( - 'ajax_record_show_columns_selector', + 'ajax_show_columns_selector', ['id' => $this->id, 'table' => $table] ); $columnSelectorTitle = sprintf( - $lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:showColumnsSelection'), + $lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:showColumnsSelection'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'] ?? '') ?: $table, ); return ' <div class="pull-right me-2 p-0"> - <typo3-recordlist-column-selector-button + <typo3-backend-column-selector-button url="' . htmlspecialchars($columnSelectorUrl) . '" target="' . htmlspecialchars($this->listURL() . '#t3-table-' . $tableIdentifier) . '" title="' . htmlspecialchars($columnSelectorTitle) . '" - ok="' . htmlspecialchars($lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:updateColumnView')) . '" + ok="' . htmlspecialchars($lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:updateColumnView')) . '" close="' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.cancel')) . '" - error="' . htmlspecialchars($lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:updateColumnView.error')) . '" + error="' . htmlspecialchars($lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:updateColumnView.error')) . '" > <button type="button" class="btn btn-default btn-sm" title="' . htmlspecialchars($columnSelectorTitle) . '">' . $this->iconFactory->getIcon('actions-options', Icon::SIZE_SMALL) . ' ' . - htmlspecialchars($lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang.xlf:showColumns')) . + htmlspecialchars($lang->sL('LLL:EXT:backend/Resources/Private/Language/locallang_column_selector:showColumns')) . '</button> - </typo3-recordlist-column-selector-button> + </typo3-backend-column-selector-button> </div>'; } @@ -2544,7 +2543,7 @@ class DatabaseRecordList $queryBuilder->setFirstResult($firstResult); } if ($addSorting) { - if ($this->sortField && in_array($this->sortField, $this->makeFieldList($table, true))) { + if ($this->sortField && in_array($this->sortField, BackendUtility::getAllowedFieldsForTable($table, false))) { $queryBuilder->orderBy($this->sortField, $this->sortRev ? 'DESC' : 'ASC'); } else { $orderBy = ($GLOBALS['TCA'][$table]['ctrl']['sortby'] ?? '') ?: $GLOBALS['TCA'][$table]['ctrl']['default_sortby'] ?? ''; @@ -2910,68 +2909,6 @@ class DatabaseRecordList ); } - /** - * Makes the list of fields to select for a table - * - * @param string $table Table name - * @param bool $dontCheckUser If set, users access to the field (non-exclude-fields) is NOT checked. - * @param bool $addDateFields If set, also adds crdate and tstamp fields (note: they will also be added if user is admin or dontCheckUser is set) - * @return string[] Array, where values are fieldnames to include in query - */ - public function makeFieldList($table, $dontCheckUser = false, $addDateFields = false) - { - $backendUser = $this->getBackendUserAuthentication(); - $fieldList = []; - - // Check table: - if (is_array($GLOBALS['TCA'][$table]['columns'] ?? null)) { - // Traverse configured columns and add them to field array, if available for user. - foreach ($GLOBALS['TCA'][$table]['columns'] as $fieldName => $fieldValue) { - if (($fieldValue['config']['type'] ?? '') === 'none') { - // Never render or fetch type=none fields from db - continue; - } - if ($dontCheckUser - || (!($fieldValue['exclude'] ?? null) || $backendUser->check('non_exclude_fields', $table . ':' . $fieldName)) && ($fieldValue['config']['type'] ?? '') !== 'passthrough' - ) { - $fieldList[] = $fieldName; - } - } - - $fieldList[] = 'uid'; - $fieldList[] = 'pid'; - - // Add date fields - if ($dontCheckUser || $backendUser->isAdmin() || $addDateFields) { - if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'] ?? false) { - $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['tstamp']; - } - if ($GLOBALS['TCA'][$table]['ctrl']['crdate'] ?? false) { - $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['crdate']; - } - } - // Add more special fields: - if ($dontCheckUser || $backendUser->isAdmin()) { - if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id'] ?? false) { - $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['cruser_id']; - } - if ($GLOBALS['TCA'][$table]['ctrl']['sortby'] ?? false) { - $fieldList[] = $GLOBALS['TCA'][$table]['ctrl']['sortby']; - } - if (BackendUtility::isTableWorkspaceEnabled($table)) { - $fieldList[] = 't3ver_state'; - $fieldList[] = 't3ver_wsid'; - $fieldList[] = 't3ver_oid'; - } - } - } else { - GeneralUtility::makeInstance(LogManager::class) - ->getLogger(__CLASS__) - ->error('TCA is broken for the table "' . $table . '": no required "columns" entry in TCA.'); - } - return array_values(array_unique($fieldList)); - } - /** * Set URL parameters to override or add in the listUrl() method. * diff --git a/typo3/sysext/recordlist/Configuration/Backend/AjaxRoutes.php b/typo3/sysext/recordlist/Configuration/Backend/AjaxRoutes.php index 45e448f8c1f18e52e8a2a70034f38fdc5a237834..c21bbf2b46f6c8c422e18ab2bce95753178ee4a6 100644 --- a/typo3/sysext/recordlist/Configuration/Backend/AjaxRoutes.php +++ b/typo3/sysext/recordlist/Configuration/Backend/AjaxRoutes.php @@ -11,13 +11,4 @@ return [ 'path' => '/record/download/settings', 'target' => \TYPO3\CMS\Recordlist\Controller\RecordDownloadController::class . '::downloadSettingsAction' ], - 'record_show_columns' => [ - 'path' => '/record/show/columns', - 'methods' => ['POST'], - 'target' => \TYPO3\CMS\Recordlist\Controller\ColumnSelectorController::class . '::updateVisibleColumnsAction' - ], - 'record_show_columns_selector' => [ - 'path' => '/record/show/columns/selector', - 'target' => \TYPO3\CMS\Recordlist\Controller\ColumnSelectorController::class . '::showColumnsSelectorAction' - ], ]; diff --git a/typo3/sysext/recordlist/Configuration/Services.yaml b/typo3/sysext/recordlist/Configuration/Services.yaml index 75cb064b520757edb1714da7aa53dbdf0b39d9b8..77d156c0cedf1e1341d59e542eb0073a3adc79c5 100644 --- a/typo3/sysext/recordlist/Configuration/Services.yaml +++ b/typo3/sysext/recordlist/Configuration/Services.yaml @@ -13,9 +13,6 @@ services: TYPO3\CMS\Recordlist\Controller\RecordDownloadController: tags: ['backend.controller'] - TYPO3\CMS\Recordlist\Controller\ColumnSelectorController: - tags: ['backend.controller'] - TYPO3\CMS\Recordlist\Controller\ElementBrowserController: tags: ['backend.controller'] diff --git a/typo3/sysext/recordlist/Resources/Private/Language/locallang.xlf b/typo3/sysext/recordlist/Resources/Private/Language/locallang.xlf index ecacf15fa35b5ae5ae4724d979079baab48b233e..5e76af1d94993088ead03e59fbc43756c687ff7d 100644 --- a/typo3/sysext/recordlist/Resources/Private/Language/locallang.xlf +++ b/typo3/sysext/recordlist/Resources/Private/Language/locallang.xlf @@ -3,24 +3,6 @@ <file source-language="en" datatype="plaintext" original="EXT:recordlist/Resources/Private/Language/locallang.xlf" date="2017-02-03T21:13:02Z" product-name="recordlist"> <header/> <body> - <trans-unit id="showColumns" resname="showColumns"> - <source>Show Columns</source> - </trans-unit> - <trans-unit id="showColumnsSelection" resname="showColumnsSelection"> - <source>Show columns for %s</source> - </trans-unit> - <trans-unit id="updateColumnView" resname="updateColumnView"> - <source>Update</source> - </trans-unit> - <trans-unit id="updateColumnView.nothingUpdated" resname="updateColumnView.nothingUpdated"> - <source>No columns were updated</source> - </trans-unit> - <trans-unit id="updateColumnView.error" resname="updateColumnView.error"> - <source>Could not update columns</source> - </trans-unit> - <trans-unit id="columnsFilter" resname="columnsFilter"> - <source>Filter by:</source> - </trans-unit> <trans-unit id="error.linkHandlerTitleMissing" resname="error.linkHandlerTitleMissing"> <source>[title missing]</source> </trans-unit> diff --git a/typo3/sysext/recordlist/Resources/Public/JavaScript/ColumnSelectorButton.js b/typo3/sysext/recordlist/Resources/Public/JavaScript/ColumnSelectorButton.js deleted file mode 100644 index 39c6e82c9b9c253d76f22d3c704393166a13f9c0..0000000000000000000000000000000000000000 --- a/typo3/sysext/recordlist/Resources/Public/JavaScript/ColumnSelectorButton.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ -var __decorate=this&&this.__decorate||function(e,t,o,r){var l,n=arguments.length,c=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(c=(n<3?l(c):n>3?l(t,o,c):l(t,o))||c);return n>3&&c&&Object.defineProperty(t,o,c),c},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define(["require","exports","lit","lit/decorators","TYPO3/CMS/Backend/Enum/Severity","TYPO3/CMS/Backend/Severity","TYPO3/CMS/Backend/Modal","TYPO3/CMS/Core/lit-helper","TYPO3/CMS/Core/Ajax/AjaxRequest","TYPO3/CMS/Backend/Notification"],(function(e,t,o,r,l,n,c,s,i,a){"use strict";var d,u,p;Object.defineProperty(t,"__esModule",{value:!0}),i=__importDefault(i),function(e){e.columnsSelector=".t3js-record-column-selector",e.columnsContainerSelector=".t3js-column-selector-container",e.columnsFilterSelector='input[name="columns-filter"]',e.columnsSelectorActionsSelector=".t3js-record-column-selector-actions"}(u||(u={})),function(e){e.toggle="select-toggle",e.all="select-all",e.none="select-none"}(p||(p={}));let m=d=class extends o.LitElement{constructor(){super(),this.title="Show columns",this.ok=s.lll("button.ok")||"Update",this.close=s.lll("button.close")||"Close",this.error="Could not update columns",this.addEventListener("click",e=>{e.preventDefault(),this.showColumnSelectorModal()})}static toggleSelectorActions(e,t,o,r=!1){t.classList.add("disabled");for(let o=0;o<e.length;o++)if(!e[o].disabled&&!e[o].checked&&(r||!d.isColumnHidden(e[o]))){t.classList.remove("disabled");break}o.classList.add("disabled");for(let t=0;t<e.length;t++)if(!e[t].disabled&&e[t].checked&&(r||!d.isColumnHidden(e[t]))){o.classList.remove("disabled");break}}static isColumnHidden(e){var t;return null===(t=e.closest(u.columnsContainerSelector))||void 0===t?void 0:t.classList.contains("hidden")}static filterColumns(e,t){t.forEach(t=>{var o;const r=t.closest(u.columnsContainerSelector);if(!t.disabled&&null!==r){const t=null===(o=r.querySelector(".form-check-label-text"))||void 0===o?void 0:o.textContent;t&&t.length&&r.classList.toggle("hidden",""!==e.value&&!RegExp(e.value,"i").test(t.trim().replace(/\[\]/g,"").replace(/\s+/g," ")))}})}render(){return o.html`<slot></slot>`}showColumnSelectorModal(){this.url&&this.target&&c.advanced({content:this.url,title:this.title,severity:l.SeverityEnum.notice,size:c.sizes.medium,type:c.types.ajax,buttons:[{text:this.close,active:!0,btnClass:"btn-default",name:"cancel",trigger:()=>c.dismiss()},{text:this.ok,btnClass:"btn-"+n.getCssClass(l.SeverityEnum.info),name:"update",trigger:()=>this.proccessSelection(c.currentModal[0])}],ajaxCallback:()=>this.handleModalContentLoaded(c.currentModal[0])})}proccessSelection(e){const t=e.querySelector("form");null!==t?new i.default(TYPO3.settings.ajaxUrls.record_show_columns).post("",{body:new FormData(t)}).then(async e=>{const t=await e.resolve();!0===t.success?(this.ownerDocument.location.href=this.target,this.ownerDocument.location.reload(!0)):a.error(t.message||"No update was performed"),c.dismiss()}).catch(()=>{this.abortSelection()}):this.abortSelection()}handleModalContentLoaded(e){const t=e.querySelector("form");if(null===t)return;t.addEventListener("submit",e=>{e.preventDefault()});const o=e.querySelectorAll(u.columnsSelector),r=e.querySelector(u.columnsFilterSelector),l=e.querySelector(u.columnsSelectorActionsSelector),n=l.querySelector('button[data-action="'+p.all+'"]'),c=l.querySelector('button[data-action="'+p.none+'"]');o.length&&null!==r&&null!==n&&null!==c&&(d.toggleSelectorActions(o,n,c,!0),o.forEach(e=>{e.addEventListener("change",()=>{d.toggleSelectorActions(o,n,c)})}),r.addEventListener("keydown",e=>{const t=e.target;"Escape"===e.code&&(e.stopImmediatePropagation(),t.value="")}),r.addEventListener("keyup",e=>{d.filterColumns(e.target,o),d.toggleSelectorActions(o,n,c)}),r.addEventListener("search",e=>{d.filterColumns(e.target,o),d.toggleSelectorActions(o,n,c)}),l.querySelectorAll("button[data-action]").forEach(e=>{e.addEventListener("click",e=>{e.preventDefault();const t=e.currentTarget;if(t.dataset.action){switch(t.dataset.action){case p.toggle:o.forEach(e=>{e.disabled||d.isColumnHidden(e)||(e.checked=!e.checked)});break;case p.all:o.forEach(e=>{e.disabled||d.isColumnHidden(e)||(e.checked=!0)});break;case p.none:o.forEach(e=>{e.disabled||d.isColumnHidden(e)||(e.checked=!1)});break;default:a.warning("Unknown selector action")}d.toggleSelectorActions(o,n,c)}})}))}abortSelection(){a.error(this.error),c.dismiss()}};__decorate([r.property({type:String})],m.prototype,"url",void 0),__decorate([r.property({type:String})],m.prototype,"target",void 0),__decorate([r.property({type:String})],m.prototype,"title",void 0),__decorate([r.property({type:String})],m.prototype,"ok",void 0),__decorate([r.property({type:String})],m.prototype,"close",void 0),__decorate([r.property({type:String})],m.prototype,"error",void 0),m=d=__decorate([r.customElement("typo3-recordlist-column-selector-button")],m)})); \ No newline at end of file diff --git a/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php b/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php deleted file mode 100644 index 1282949fec5a300989a69a1d1811d59d3b5f40c9..0000000000000000000000000000000000000000 --- a/typo3/sysext/recordlist/Tests/Unit/RecordList/DatabaseRecordListTest.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -declare(strict_types=1); - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -namespace TYPO3\CMS\Recordlist\Tests\Unit\RecordList; - -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; -use TYPO3\CMS\Backend\Routing\Router; -use TYPO3\CMS\Backend\Routing\UriBuilder; -use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\CMS\Core\Imaging\Icon; -use TYPO3\CMS\Core\Imaging\IconFactory; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; -use TYPO3\TestingFramework\Core\Unit\UnitTestCase; - -class DatabaseRecordListTest extends UnitTestCase -{ - use ProphecyTrait; - - protected $resetSingletonInstances = true; - - protected DatabaseRecordList $subject; - - protected function setUp(): void - { - parent::setUp(); - - $iconFactoryProphecy = $this->prophesize(IconFactory::class); - $iconFactoryProphecy->getIcon(Argument::cetera())->shouldBeCalled()->willReturn(new Icon()); - GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal()); - GeneralUtility::setSingletonInstance(UriBuilder::class, new UriBuilder(new Router())); - - $GLOBALS['BE_USER'] = new BackendUserAuthentication(); - - $this->subject = new DatabaseRecordList(); - } - - /** - * @test - */ - public function makeFieldListReturnsEmptyArrayOnBrokenTca(): void - { - self::assertEmpty($this->subject->makeFieldList('myTabe', true, true)); - } - - /** - * @test - */ - public function makeFieldListReturnsUniqueList(): void - { - $GLOBALS['TCA']['myTable'] = [ - 'ctrl'=> [ - 'tstamp' => 'updatedon', - // Won't be added due to defined in "columns" - 'crdate' => 'createdon', - 'cruser_id' => 'createdby', - 'sortby' => 'sorting', - 'versioningWS' => true, - ], - 'columns' => [ - // Regular field - 'title' => [ - 'config' => [ - 'type' => 'input' - ], - ], - // Overwrite automatically set management field from "ctrl" - 'createdon' => [ - 'config' => [ - 'type' => 'input' - ], - ], - // Won't be added due to type "none" - 'reference' => [ - 'config' => [ - 'type' => 'none' - ], - ] - ] - ]; - - self::assertEquals( - ['title', 'createdon', 'uid', 'pid', 'updatedon', 'createdby', 'sorting', 't3ver_state', 't3ver_wsid', 't3ver_oid'], - $this->subject->makeFieldList('myTable', true, true) - ); - } -}