Commit f6ec9646 authored by Benni Mack's avatar Benni Mack Committed by Frank Nägler
Browse files

[FEATURE] Allow CEs to be saved directly in NewContentElement wizard

When creating content elements via the NewContentElement wizard,
a new option "saveAndClose" can be defined via PageTSconfig
to skip the "FormEngine" part and save a record directly.

This is especially handy for Content Types like "divider" or
for extensions handling with grids.

This saves clicks for the editor, and matched with the
tt_content_defVals it would be possible to create "quick create"
content elements directly via the New Content Element wizard
with pre-defined values.

The feature is enabled by default for the CType "divider".

Resolves: #90461
Releases: master
Change-Id: I5fe171ac1b243c22d4ed9e14f1a5f3c00c088a21
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63341


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarDavid Steeb <david.steeb@b13.de>
Tested-by: Frank Nägler's avatarFrank Nägler <frank.naegler@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarDavid Steeb <david.steeb@b13.de>
Reviewed-by: Frank Nägler's avatarFrank Nägler <frank.naegler@typo3.org>
parent 41d7cee8
......@@ -101,6 +101,11 @@ class NewContentElementController
*/
protected $moduleTemplate;
/**
* @var UriBuilder
*/
protected $uriBuilder;
/**
* Constructor
*/
......@@ -110,6 +115,7 @@ class NewContentElementController
$GLOBALS['SOBE'] = $this;
$this->view = $this->getFluidTemplateObject();
$this->menuItemView = $this->getFluidTemplateObject('MenuItem.html');
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
}
/**
......@@ -178,8 +184,7 @@ class NewContentElementController
protected function onClickInsertRecord(string $clientContext): string
{
// $this->uid_pid can be negative (= pointing to tt_content record) or positive (= "page ID")
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$location = (string)$uriBuilder->buildUriFromRoute('record_edit', [
$location = (string)$this->uriBuilder->buildUriFromRoute('record_edit', [
'edit[tt_content][' . $this->uid_pid . ']' => 'new',
'defVals[tt_content][colPos]' => $this->colPos,
'defVals[tt_content][sys_language_uid]' => $this->sys_language,
......@@ -254,6 +259,20 @@ class NewContentElementController
$aOnClick = "document.editForm.defValues.value=unescape('" . rawurlencode($wInfo['params']) . "');goToalt_doc();";
}
// Go to DataHandler directly instead of FormEngine
if ($wInfo['saveAndClose'] ?? false) {
$urlParams = [];
$id = uniqid('NEW');
parse_str($wInfo['params'], $urlParams);
$urlParams['data']['tt_content'][$id] = $urlParams['defVals']['tt_content'] ?? [];
$urlParams['data']['tt_content'][$id]['colPos'] = $this->colPos;
$urlParams['data']['tt_content'][$id]['pid'] = $this->uid_pid;
$urlParams['data']['tt_content'][$id]['sys_language_uid'] = $this->sys_language;
$urlParams['redirect'] = GeneralUtility::_GP('returnUrl');
unset($urlParams['defVals']);
$url = $this->uriBuilder->buildUriFromRoute('tce_db', $urlParams);
$aOnClick = 'list_frame.location.href=' . GeneralUtility::quoteJSvalue((string)$url) . '; return false';
}
$icon = $this->moduleTemplate->getIconFactory()->getIcon($wInfo['iconIdentifier'])->render();
$this->menuItemView->assignMultiple([
......@@ -410,6 +429,7 @@ class NewContentElementController
{
$itemConf['title'] = $this->getLanguageService()->sL($itemConf['title']);
$itemConf['description'] = $this->getLanguageService()->sL($itemConf['description']);
$itemConf['saveAndClose'] = (bool)$itemConf['saveAndClose'];
$itemConf['tt_content_defValues'] = $itemConf['tt_content_defValues.'];
unset($itemConf['tt_content_defValues.']);
return $itemConf;
......
.. include:: ../../Includes.txt
===========================================================================
Feature: #90461 - Quick-Create Content Elements via NewContentElementWizard
===========================================================================
See :issue:`90461`
Description
===========
The new Content Element wizard within the Page Module now contains
an option called "saveAndClose" which directs a user back to the
Page Module directly instead of showing the FormEngine.
This is especially useful for custom content elements or container
content types where pre-defined values can be put in place directly,
saving editors one click on content creation.
The functionality is disabled by default, but explicitly enabled for the Content Type "divider".
Impact
======
This definition can be put into PageTSconfig (e.g. EXT:my_extension/Configuration/Page/main.tsconfig) with the new flag "saveAndClose" enabled.
.. code-block:: typoscript
mod.wizards.newContentElement.wizardItems {
common.elements {
my_element {
iconIdentifier = content-my-icon
title = LLL:EXT:my_extension/Resources/Private/Language/ContentTypes.xlf:my_element_title
description = LLL:EXT:my_extension/Resources/Private/Language/ContentTypes.xlf:my_element_description
tt_content_defValues {
CType = my_element
header = Hello my friend
}
saveAndClose = true
}
}
}
.. index:: Backend, TSConfig, ext:backend
\ No newline at end of file
......@@ -192,6 +192,7 @@ mod.wizards.newContentElement.wizardItems {
tt_content_defValues {
CType = div
}
saveAndClose = true
}
shortcut {
iconIdentifier = content-special-shortcut
......
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