Commit f40edb43 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Jan Helke
Browse files

[FEATURE] Allow exclusion of records in localization wizard

This patch adds a checkbox next to each record that is about to be
localized in the wizard. All checkboxes are enabled by default.

Additionally, a filter is introduced that checks that all transmitted UIDs
are actually localizable and removes invalid values.

Resolves: #80866
Releases: master
Change-Id: I73299eb921caba98628afc41b0dddd6c0f4c09e6
Reviewed-on: https://review.typo3.org/52467

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarHenrik Elsner <helsner@dfau.de>
Tested-by: default avatarHenrik Elsner <helsner@dfau.de>
Reviewed-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Tested-by: Jan Helke's avatarJan Helke <typo3@helke.de>
parent cde924eb
......@@ -5,3 +5,14 @@ $option-margin-bottom: $padding-small-horizontal;
margin-bottom: $option-margin-bottom;
}
}
[data-slide="localize-summary"] {
.input-group {
margin-bottom: $option-margin-bottom;
.form-control {
height: auto;
font-weight: normal;
}
}
}
......@@ -167,12 +167,51 @@ class LocalizationController
return $response;
}
// Filter transmitted but invalid uids
$params['uidList'] = $this->filterInvalidUids(
(int)$params['pageId'],
(int)$params['colPos'],
(int)$params['destLanguageId'],
(int)$params['srcLanguageId'],
$params['uidList']
);
$this->process($params);
$response->getBody()->write(json_encode([]));
return $response;
}
/**
* Gets all possible UIDs of a page, colPos and language that might be processed and removes invalid UIDs that might
* be smuggled in.
*
* @param int $pageId
* @param int $colPos
* @param int $destLanguageId
* @param int $srcLanguageId
* @param array $transmittedUidList
* @return array
*/
protected function filterInvalidUids(
int $pageId,
int $colPos,
int $destLanguageId,
int $srcLanguageId,
array $transmittedUidList
): array {
// Get all valid uids that can be processed
$validUidList = $result = $this->localizationRepository->getRecordsToCopyDatabaseResult(
$pageId,
$colPos,
$destLanguageId,
$srcLanguageId,
'uid'
);
return array_intersect(array_unique($transmittedUidList), array_column($validUidList->fetchAll(), 'uid'));
}
/**
* Processes the localization actions
*
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -157,21 +157,49 @@ define([
Localization.records = [];
$.each(result, function(_, record) {
var label = ' (' + record.uid + ') ' + record.title;
Localization.records.push(record.uid);
$summary.append(
$('<div />', {class: 'col-sm-6'}).text(' (' + record.uid + ') ' + record.title).prepend(record.icon)
$('<div />', {'class': 'col-sm-6'}).append(
$('<div />', {'class': 'input-group'}).append(
$('<span />', {'class': 'input-group-addon'}).append(
$('<input />', {type: 'checkbox', id: 'record-uid-' + record.uid, checked: 'checked', 'data-uid': record.uid, 'aria-label': label})
),
$('<label />', {'class': 'form-control', for: 'record-uid-' + record.uid}).text(label).prepend(record.icon)
)
)
);
});
$slide.html($summary);
// Unlock button as we don't have an option
Wizard.unlockNextStep();
Wizard.getComponent().on('change', 'input[type="checkbox"]', function() {
var $me = $(this),
uid = $me.data('uid');
if ($me.is(':checked')) {
Localization.records.push(uid);
} else {
var index = Localization.records.indexOf(uid);
if (index > -1) {
Localization.records.splice(index, 1);
}
}
if (Localization.records.length > 0) {
Wizard.unlockNextStep();
} else {
Wizard.lockNextStep();
}
});
});
});
});
Wizard.addFinalProcessingSlide(function() {
Localization.localizeRecords(
$triggerButton.data('pageId'),
$triggerButton.data('colposId'),
$triggerButton.data('languageId'),
Localization.records
).done(function() {
......@@ -241,15 +269,17 @@ define([
* Localize records
*
* @param {Integer} pageId
* @param {Integer} colPos
* @param {Integer} languageId
* @param {Array} uidList
* @return {Promise}
*/
Localization.localizeRecords = function(pageId, languageId, uidList) {
Localization.localizeRecords = function(pageId, colPos, languageId, uidList) {
return $.ajax({
url: TYPO3.settings.ajaxUrls['records_localize'],
data: {
pageId: pageId,
colPos: colPos,
srcLanguageId: Localization.settings.language,
destLanguageId: languageId,
action: Localization.settings.mode,
......
.. include:: ../../Includes.txt
===================================================================
Feature: #80866 - Allow exclusion of records in localization wizard
===================================================================
See :issue:`80866`
Description
===========
Using the localization wizard enables a user now to exclude certain records from localization in the ongoing localization process.
Impact
======
Each record in the localization wizard that will be translated or copied now offers a checkbox that allows the exclusion of the record.
.. index:: Backend
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