Skip to content

Commit

Permalink
[TASK] Update datatables, drop RequireJS, use Luxon instead of Moment,
Browse files Browse the repository at this point in the history
…resolves #358
  • Loading branch information
fsuter committed Jan 10, 2025
1 parent c32d95b commit d82f89a
Show file tree
Hide file tree
Showing 16 changed files with 340 additions and 412 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2025-01-10 Francois Suter (Idéative) <[email protected]>

* Update datatables, drop RequireJS, use Luxon instead of Moment, resolves #358

2025-01-02 Francois Suter (Idéative) <[email protected]>

* Drop Extbase usage for logs, resolves #362
Expand Down
13 changes: 3 additions & 10 deletions Classes/Controller/DataModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Cobweb\ExternalImport\Domain\Repository\ConfigurationRepository;
use Cobweb\ExternalImport\Domain\Repository\SchedulerRepository;
use Cobweb\ExternalImport\Importer;
use Cobweb\ExternalImport\Utility\CompatibilityUtility;
use Cobweb\ExternalImport\Utility\CsvUtility;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
Expand Down Expand Up @@ -584,16 +585,8 @@ protected function loadResources(): void
ExtensionManagementUtility::extPath('external_import') . 'Resources/Public/'
);
$this->pageRenderer->addCssFile($publicResourcesPath . 'StyleSheet/ExternalImport.css');
/*
$this->pageRenderer->addRequireJsConfiguration(
[
'paths' => [
'datatables' => $publicResourcesPath . 'JavaScript/Contrib/datatables',
],
]
);
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/ExternalImport/DataModule');
*/
$this->pageRenderer->loadJavaScriptModule('@cobweb/externalimport/data-module.js');
$this->pageRenderer->loadJavaScriptModule('@cobweb/externalimport-contribs/datatables.min.js');
$this->pageRenderer->addInlineLanguageLabelFile('EXT:external_import/Resources/Private/Language/JavaScript.xlf');

// Evaluate write access on all tables
Expand Down
25 changes: 2 additions & 23 deletions Classes/Controller/LogModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,8 @@ protected function loadResources(): void
ExtensionManagementUtility::extPath('external_import') . 'Resources/Public/'
);
$this->pageRenderer->addCssFile($publicResourcesPath . 'StyleSheet/ExternalImport.css');
// TODO: remove when compatibility with v11 is dropped
if (CompatibilityUtility::isV11()) {
$this->pageRenderer->addCssFile($publicResourcesPath . 'StyleSheet/ExternalImport11.css');
}
$this->pageRenderer->addRequireJsConfiguration(
[
'paths' => [
'datatables' => $publicResourcesPath . 'JavaScript/Contrib/datatables',
],
]
);
// TODO: remove and replace with Luxon when compatibility with v11 is dropped
// Reference: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.1/Important-88158-ReplacedMomentJsWithLuxon.html
if (CompatibilityUtility::isV12()) {
$this->pageRenderer->addRequireJsConfiguration(
[
'paths' => [
'moment' => $publicResourcesPath . 'JavaScript/Contrib/moment',
],
]
);
}
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/ExternalImport/LogModule');
$this->pageRenderer->loadJavaScriptModule('@cobweb/externalimport/log-module.js');
$this->pageRenderer->loadJavaScriptModule('@cobweb/externalimport-contribs/datatables.min.js');
$this->pageRenderer->addInlineLanguageLabelFile('EXT:external_import/Resources/Private/Language/JavaScript.xlf');
}

Expand Down
8 changes: 6 additions & 2 deletions Classes/Domain/Model/Dto/QueryParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ public function setAllParameters(array $parameters): void
// Assemble list of search columns
$this->setSearchColumns($parameters['columns']);
// Ordering column name must match existing column
$column = (int)$parameters['order'][0]['column'];
if ($parameters['order'] ?? false) {
$column = $parameters['order'][0]['column'] ? (int)$parameters['order'][0]['column'] : null;
} else {
$column = null;
}
if (array_key_exists($column, $parameters['columns'])) {
$columnName = $parameters['columns'][$column]['name'];
} else {
$columnName = '';
}
$this->setOrder($columnName);
$direction = strtoupper($parameters['order'][0]['dir']);
$direction = strtoupper($parameters['order'][0]['dir'] ?? 'asc');
$this->setDirection($direction);
}

Expand Down
49 changes: 0 additions & 49 deletions Classes/Utility/CompatibilityUtility.php

This file was deleted.

11 changes: 11 additions & 0 deletions Configuration/JavaScriptModules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
'dependencies' => [
'backend',
],
'imports' => [
'@cobweb/externalimport/' => 'EXT:external_import/Resources/Public/JavaScript/',
'@cobweb/externalimport-contribs/' => 'EXT:external_import/Resources/Public/JavaScript/Contrib/',
],
];
8 changes: 0 additions & 8 deletions Resources/Private/Templates/LogModule/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ <h1><f:translate id="logList" /></h1>
</table>
</div>
</div>
<!-- Icons -->
<div id="tx_externalimport_loglist_icons" class="hidden">
<div id="icon_information"><span class="log-icon-information"><core:icon identifier="actions-info-circle-alt" size="small" /></span></div>
<div id="icon_notification"><span class="log-icon-notification"><core:icon identifier="actions-info-circle-alt" size="small" /></span></div>
<div id="icon_success"><span class="log-icon-success"><core:icon identifier="actions-check-circle-alt" size="small" /></span></div>
<div id="icon_warning"><span class="log-icon-warning"><core:icon identifier="actions-exclamation-circle-alt" size="small" /></span></div>
<div id="icon_danger"><span class="log-icon-danger"><core:icon identifier="actions-exclamation-circle-alt" size="small" /></span></div>
</div>
<!-- Loading mask -->
<div id="tx_externalimport_loglist_loader">
<core:icon identifier="spinner-circle-dark" size="large" />
Expand Down
9 changes: 9 additions & 0 deletions Resources/Public/JavaScript/Contrib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# How to update datatables

Go to datatables.net > Download and select the following options:

- for the styling framework: Bootstrap 5
- for the packages: jQuery 3 and DataTables
- no extensions

Download the minified version and replace the file in this folder.
22 changes: 0 additions & 22 deletions Resources/Public/JavaScript/Contrib/datatables.js

This file was deleted.

26 changes: 26 additions & 0 deletions Resources/Public/JavaScript/Contrib/datatables.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Resources/Public/JavaScript/Contrib/moment.js

This file was deleted.

212 changes: 0 additions & 212 deletions Resources/Public/JavaScript/DataModule.js

This file was deleted.

Loading

0 comments on commit d82f89a

Please sign in to comment.