Skip to content

Commit

Permalink
[TASK] Compile backend amd modules with webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed Aug 22, 2019
1 parent 4c07790 commit 192c6e7
Show file tree
Hide file tree
Showing 28 changed files with 1,658 additions and 1,098 deletions.
19 changes: 3 additions & 16 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public function initializeAction(): void

$pageRenderer = $this->moduleTemplate->getPageRenderer();
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
$pageRenderer->addCssFile('../typo3conf/ext/blog/Resources/Public/Css/bootstrap.min.css', 'stylesheet', 'all', '', false);
$pageRenderer->addCssFile('../typo3conf/ext/blog/Resources/Public/Css/backend.css', 'stylesheet', 'all', '', false);
$pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/backend.min.css', 'stylesheet', 'all', '', false);
}

public function initializeSetupWizardAction(): void
Expand All @@ -124,21 +123,9 @@ public function initializeCommentsAction(): void

protected function initializeDataTables(): void
{
$blogPath = ExtensionManagementUtility::extPath('blog', 'Resources/Public/JavaScript/');
$blogPath = PathUtility::getAbsoluteWebPath($blogPath);
$pageRenderer = $this->moduleTemplate->getPageRenderer();
$pageRenderer->addRequireJsConfiguration([
'paths' => [
'datatables_bootstrap' => $blogPath . 'dataTables.bootstrap.min'
],
'map' => [
'*' => [
'datatables.net' => 'datatables',
]
]
]);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Blog/DataTables');
$pageRenderer->addCssFile('../typo3conf/ext/blog/Resources/Public/Css/dataTables.bootstrap.min.css', 'stylesheet', 'all', '', false);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Blog/Datatables');
$pageRenderer->addCssFile('../typo3conf/ext/blog/Resources/Public/Css/Datatables.min.css', 'stylesheet', 'all', '', false);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions Classes/Form/Wizards/SocialImageWizardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public function indexAction(ServerRequestInterface $request): ResponseInterface
$this->moduleTemplate->setContent($this->view->render());
$pageRenderer = $this->moduleTemplate->getPageRenderer();
$pageRenderer->addCssFile('EXT:blog/Resources/Public/Css/SocialImageWizard.css');
$pageRenderer->addJsFile('EXT:blog/Resources/Public/JavaScript/fabric.min.js');
$pageRenderer->addJsFile('EXT:blog/Resources/Public/JavaScript/SocialImageApp.js');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Blog/SocialImageApp');
return GeneralUtility::makeInstance(HtmlResponse::class, $this->moduleTemplate->renderContent());
}

Expand Down
61 changes: 61 additions & 0 deletions Resources/Private/JavaScript/backend/Datatables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* Module: TYPO3/CMS/Blog/DataTables
*/
import 'datatables.net-bs/css/dataTables.bootstrap.min.css';

import $ from 'jquery';
import 'datatables.net';
import 'datatables.net-bs';

$('.dataTables').DataTable({
"columns": function() {
return $(this).data('columns')
},
"pageLength": 10,
"initComplete": function () {
this.api().columns().every( function () {
var column = this;
if ($(column.header()).data('filter') === true) {
var select = $('<select><option value="">' + $(column.header()).text() + '</option></select>')
.appendTo( $(column.header()).empty() )
.on('click', function(e) {
e.stopPropagation();
})
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? val : '', true, false )
.draw();
} );
var values = [];
column.data().each(function(d, j) {
var $object = $(d);
if ($object.find('li').length > 0) {
$object.find('li').each(function() {
var str = $(this).text().trim();
if (str !== '') {
values.push(str);
}
});
} else {
if (d !== '') {
var str = $('<span>').text(d).text().trim();
if (str !== '') {
values.push(str);
}
}
}
});
values = values.filter(function (value, index, self) {
return self.indexOf(value) === index;
});
$(values).sort().each(function() {
var value = this;
select.append( '<option value="'+value+'">'+value+'</option>' )
} );
}
} );
}
});
30 changes: 30 additions & 0 deletions Resources/Private/JavaScript/backend/MassUpdate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Module: TYPO3/CMS/Blog/MassUpdate
*/
import $ from 'jquery';

var MassUpdate = {
checkboxTriggerSelector: '.t3js-check-multiple-selection',
checkboxSelector: '.t3js-check-multiple-selection input[type="checkbox"]',
actionButton: '.t3js-check-multiple-action'
};

MassUpdate.initialize = function () {
$(function () {
$(document).on('click', MassUpdate.checkboxTriggerSelector, function() {
MassUpdate.updateButton();
});
});
};

MassUpdate.updateButton = function() {
var active = false;
$(MassUpdate.checkboxSelector).each(function() {
if ($(this).prop('checked')) {
active = true;
}
});
$(MassUpdate.actionButton).prop('disabled', !active);
};

MassUpdate.initialize();
43 changes: 43 additions & 0 deletions Resources/Private/JavaScript/backend/SetupWizard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Module: TYPO3/CMS/Blog/SetupWizard
*/
import $ from "jquery";
import Modal from "TYPO3/CMS/Backend/Modal";
import Severity from "TYPO3/CMS/Backend/Severity";

var SetupWizard = {
triggerSelector: '.t3js-setup-wizard-trigger',
modalContentSelector: '.t3js-setup-wizard-step1 .step-content'
};

SetupWizard.initialize = function() {
$(document).on('click', SetupWizard.triggerSelector, function(e) {
e.preventDefault();
var $element = $(this);
var $content = $(SetupWizard.modalContentSelector).clone();
var buttons = [
{
text: $element.data('button-close-text') || 'Close',
active: true,
btnClass: 'btn-default',
trigger: function() {
Modal.currentModal.trigger('modal-dismiss');
}
},
{
text: $element.data('button-ok-text') || 'OK',
btnClass: 'btn-primary',
trigger: function(evt) {
Modal.currentModal.trigger('modal-dismiss');
self.location.href = $element.attr('href')
.replace('%40title', Modal.currentModal.find('input[name="title"]').val())
.replace('%40template', Modal.currentModal.find('input[name="template"]:checked').length)
.replace('%40install', Modal.currentModal.find('input[name="install"]:checked').length);
}
}
];
Modal.show('Blog Setup Wizard', $content, Severity.notice, buttons);
});
};

SetupWizard.initialize();
Loading

0 comments on commit 192c6e7

Please sign in to comment.