Refine survey editor workflow and publication handling

This commit is contained in:
Jürgen Mummert
2026-05-29 10:19:19 +02:00
parent 6bbded4181
commit 1174410c1b
40 changed files with 1121 additions and 335 deletions
+47 -6
View File
@@ -22,6 +22,8 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
'id' => 'primary',
'alias' => 'unique',
'published' => 'index',
'isActive' => 'index',
'isTemplate' => 'index',
],
],
],
@@ -33,7 +35,7 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
'panelLayout' => 'filter;sort,search,limit',
],
'label' => [
'fields' => ['title', 'categorySummary', 'assignedMembersSummary'],
'fields' => ['title', 'categorySummary', 'assignedMembersSummary', 'templateSummary'],
'showColumns' => true,
],
'global_operations' => [
@@ -52,10 +54,22 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
'href' => 'act=edit',
'icon' => 'header.svg',
],
'publishSurvey' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['publishSurvey'],
'href' => 'act=toggle&field=published',
'icon' => 'visible.svg',
'button_callback' => [SurveyDcaListener::class, 'generatePublishSurveyButton'],
],
'toggleActive' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['toggleActive'],
'href' => 'act=toggle&field=isActive',
'icon' => 'visible.svg',
'button_callback' => [SurveyDcaListener::class, 'generateToggleActiveButton'],
],
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich loeschen?\'))return false;Backend.getScrollOffset()"',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',
@@ -74,7 +88,7 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
],
],
'palettes' => [
'default' => '{title_legend},title,category,description;{assignment_legend},assignedMembers;{publishing_legend},published,isLocked;{meta_legend},createdAt,updatedAt',
'default' => '{title_legend},title,category,description;{assignment_legend},assignedMembers;{publishing_legend},isTemplate;{meta_legend},createdAt,updatedAt',
],
'fields' => [
'id' => [
@@ -105,6 +119,7 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
],
'category' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['category'],
'filter' => true,
'inputType' => 'select',
'foreignKey' => 'tl_survey_category.title',
'eval' => ['multiple' => true, 'chosen' => true, 'tl_class' => 'clr'],
@@ -113,9 +128,8 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
],
'categoryFilter' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['categoryFilter'],
'filter' => true,
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getCategoryOptions'],
'options_callback' => [SurveyDcaListener::class, 'getUsedCategoryFilterOptions'],
'eval' => ['includeBlankOption' => true, 'chosen' => true, 'findInSet' => true],
'sql' => "varchar(255) NOT NULL default ''",
],
@@ -127,8 +141,33 @@ $GLOBALS['TL_DCA']['tl_survey'] = [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['published'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50 m12'],
'save_callback' => [[SurveyDcaListener::class, 'savePublishedState']],
'sql' => "char(1) NOT NULL default ''",
],
'isActive' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['isActive'],
'inputType' => 'checkbox',
'save_callback' => [[SurveyDcaListener::class, 'saveActiveState']],
'sql' => "char(1) NOT NULL default ''",
],
'isTemplate' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['isTemplate'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50 m12'],
'sql' => "char(1) NOT NULL default ''",
],
'templateFilter' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['templateFilter'],
'filter' => true,
'inputType' => 'select',
'options_callback' => [SurveyDcaListener::class, 'getTemplateFilterOptions'],
'eval' => ['includeBlankOption' => true, 'chosen' => true],
'sql' => "char(1) NOT NULL default ''",
],
'templateSummary' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['templateSummary'],
'sql' => "varchar(16) NOT NULL default ''",
],
'isLocked' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey']['isLocked'],
'inputType' => 'checkbox',
@@ -192,7 +231,7 @@ if ('cli' !== PHP_SAPI) {
System::getContainer()->get('database_connection')->fetchFirstColumn('SHOW COLUMNS FROM tl_survey'),
);
$hasListMetadataColumns = !array_diff(
['categoryfilter', 'categorysummary', 'assignedmembersfilter', 'assignedmemberssummary'],
['categoryfilter', 'categorysummary', 'templatefilter', 'templatesummary', 'assignedmembersfilter', 'assignedmemberssummary'],
$columnNames,
);
} catch (\Throwable) {
@@ -205,6 +244,8 @@ if ('cli' !== PHP_SAPI) {
unset(
$GLOBALS['TL_DCA']['tl_survey']['fields']['categoryFilter'],
$GLOBALS['TL_DCA']['tl_survey']['fields']['categorySummary'],
$GLOBALS['TL_DCA']['tl_survey']['fields']['templateFilter'],
$GLOBALS['TL_DCA']['tl_survey']['fields']['templateSummary'],
$GLOBALS['TL_DCA']['tl_survey']['fields']['assignedMembersFilter'],
$GLOBALS['TL_DCA']['tl_survey']['fields']['assignedMembersSummary'],
);
+9
View File
@@ -52,6 +52,15 @@ $GLOBALS['TL_DCA']['tl_survey_answer'] = [
'label' => &$GLOBALS['TL_LANG']['tl_survey_answer']['questionType'],
'sql' => "varchar(32) NOT NULL default ''",
],
'questionLabel' => [
'sql' => "varchar(255) NOT NULL default ''",
],
'questionDescription' => [
'sql' => 'text NULL',
],
'questionSorting' => [
'sql' => 'int(10) unsigned NOT NULL default 0',
],
'value' => [
'label' => &$GLOBALS['TL_LANG']['tl_survey_answer']['value'],
'sql' => 'text NULL',
+1 -1
View File
@@ -34,7 +34,7 @@ $GLOBALS['TL_DCA']['tl_survey_category'] = [
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich loeschen?\'))return false;Backend.getScrollOffset()"',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',
+4 -1
View File
@@ -12,6 +12,9 @@ $GLOBALS['TL_DCA']['tl_survey_condition'] = [
'dataContainer' => DC_Table::class,
'ptable' => 'tl_survey',
'enableVersioning' => true,
'onload_callback' => [
[SurveyDcaListener::class, 'restrictSurveyConditionEditing'],
],
'onsubmit_callback' => [
[SurveyDcaListener::class, 'touchSurveyConditionParent'],
],
@@ -51,7 +54,7 @@ $GLOBALS['TL_DCA']['tl_survey_condition'] = [
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich loeschen?\'))return false;Backend.getScrollOffset()"',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',
+4 -1
View File
@@ -12,6 +12,9 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'dataContainer' => DC_Table::class,
'ptable' => 'tl_survey',
'enableVersioning' => true,
'onload_callback' => [
[SurveyDcaListener::class, 'restrictSurveyContentEditing'],
],
'onsubmit_callback' => [
[SurveyDcaListener::class, 'touchSurveyContentParent'],
],
@@ -55,7 +58,7 @@ $GLOBALS['TL_DCA']['tl_survey_content'] = [
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich loeschen?\'))return false;Backend.getScrollOffset()"',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',
+1 -1
View File
@@ -47,7 +47,7 @@ $GLOBALS['TL_DCA']['tl_survey_editor'] = [
'delete' => [
'href' => 'act=delete',
'icon' => 'delete.svg',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich loeschen?\'))return false;Backend.getScrollOffset()"',
'attributes' => 'onclick="if(!confirm(\'Eintrag wirklich löschen?\'))return false;Backend.getScrollOffset()"',
],
'show' => [
'href' => 'act=show',