Fix backend survey action labels
This commit is contained in:
@@ -337,7 +337,9 @@ final class MemberSurveyEditController extends AbstractFrontendModuleController
|
||||
{
|
||||
$questionLabels = [];
|
||||
$questionSortings = [];
|
||||
$questionPositions = [];
|
||||
$rules = [];
|
||||
$position = 1;
|
||||
|
||||
foreach ($questions as $question) {
|
||||
$questionId = (int) ($question->id ?? 0);
|
||||
@@ -348,6 +350,7 @@ final class MemberSurveyEditController extends AbstractFrontendModuleController
|
||||
|
||||
$questionLabels[$questionId] = (string) ($question->question ?? '');
|
||||
$questionSortings[$questionId] = (int) ($question->sorting ?? 0);
|
||||
$questionPositions[$questionId] = $position++;
|
||||
}
|
||||
|
||||
foreach ($questions as $question) {
|
||||
@@ -371,6 +374,8 @@ final class MemberSurveyEditController extends AbstractFrontendModuleController
|
||||
'answerValue' => $answerValue,
|
||||
'sourceQuestion' => $questionId,
|
||||
'targetQuestion' => $targetQuestionId,
|
||||
'sourcePosition' => $questionPositions[$questionId] ?? 0,
|
||||
'targetPosition' => $questionPositions[$targetQuestionId] ?? 0,
|
||||
'sourceQuestionLabel' => (string) ($question->question ?? ''),
|
||||
'targetQuestionLabel' => $questionLabels[$targetQuestionId] ?? '',
|
||||
'sourceSorting' => $questionSortings[$questionId] ?? 0,
|
||||
@@ -386,6 +391,8 @@ final class MemberSurveyEditController extends AbstractFrontendModuleController
|
||||
'answerValue' => (string) ($condition['answerValue'] ?? ''),
|
||||
'sourceQuestion' => $sourceQuestionId,
|
||||
'targetQuestion' => (int) ($condition['targetQuestion'] ?? 0),
|
||||
'sourcePosition' => $questionPositions[$sourceQuestionId] ?? 0,
|
||||
'targetPosition' => $questionPositions[(int) ($condition['targetQuestion'] ?? 0)] ?? 0,
|
||||
'sourceQuestionLabel' => (string) ($condition['sourceQuestionLabel'] ?? ''),
|
||||
'targetQuestionLabel' => (string) ($condition['targetQuestionLabel'] ?? ''),
|
||||
'sourceSorting' => $questionSortings[$sourceQuestionId] ?? 0,
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Mummert\SurveyBundle\EventListener;
|
||||
|
||||
use Contao\Config;
|
||||
use Contao\CoreBundle\DataContainer\DataContainerOperation;
|
||||
use Contao\CoreBundle\Routing\ContentUrlGenerator;
|
||||
use Contao\CoreBundle\Framework\ContaoFramework;
|
||||
use Contao\DataContainer;
|
||||
@@ -37,18 +38,19 @@ final class SurveyDcaListener
|
||||
return $this->surveyRepository->ensurePublicAlias((string) $value, (int) ($dataContainer->id ?? 0));
|
||||
}
|
||||
|
||||
public function generateCopyPublicLinkButton(array $row, ?string $href, string $label, string $title, ?string $icon, string $attributes): string
|
||||
public function generateCopyPublicLinkButton(DataContainerOperation $operation): void
|
||||
{
|
||||
$row = $operation->getRecord() ?? [];
|
||||
$publicUrl = $this->buildSurveyPageUrl((string) ($row['alias'] ?? ''), 'surveyReaderPage');
|
||||
$label = 'Link kopieren';
|
||||
$title = 'Den öffentlichen Link in die Zwischenablage kopieren';
|
||||
|
||||
if (null === $publicUrl) {
|
||||
return sprintf(
|
||||
$operation->setHtml(sprintf(
|
||||
'<span title="%s">%s</span>',
|
||||
htmlspecialchars('In den Contao-Einstellungen ist noch keine Reader-Seite hinterlegt oder der Link-Schlüssel ist ungültig.', ENT_QUOTES),
|
||||
Image::getHtml($icon ?? 'copy.svg', $label)
|
||||
);
|
||||
Image::getHtml('copy.svg', 'Link kopieren')
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$copyScript = sprintf(
|
||||
@@ -58,50 +60,58 @@ final class SurveyDcaListener
|
||||
json_encode('Bestätigung', JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
'<a href="#" title="%s" onclick="%s"%s>%s</a>',
|
||||
htmlspecialchars($title, ENT_QUOTES),
|
||||
htmlspecialchars($copyScript, ENT_QUOTES),
|
||||
$attributes,
|
||||
Image::getHtml($icon ?? 'copy.svg', $label).' '.$label
|
||||
);
|
||||
$operation->setUrl('#');
|
||||
$operation['label'] = 'Link kopieren';
|
||||
$operation['title'] = 'Den öffentlichen Link in die Zwischenablage kopieren';
|
||||
$operation['icon'] = 'copy.svg';
|
||||
$operation['attributes']
|
||||
->set('onclick', $copyScript)
|
||||
->set('data-contao--tooltips-target', 'tooltip')
|
||||
;
|
||||
}
|
||||
|
||||
public function generateShowResultsButton(array $row, ?string $href, string $label, string $title, ?string $icon, string $attributes): string
|
||||
public function generateShowResultsButton(DataContainerOperation $operation): void
|
||||
{
|
||||
$row = $operation->getRecord() ?? [];
|
||||
$resultsUrl = $this->buildSurveyPageUrl((string) ($row['alias'] ?? ''), 'surveyResultsPage');
|
||||
$label = 'Ergebnisse anzeigen';
|
||||
$title = 'Die Ergebnisse dieser Umfrage im Frontend anzeigen';
|
||||
|
||||
if (null === $resultsUrl) {
|
||||
return sprintf(
|
||||
$operation->setHtml(sprintf(
|
||||
'<span title="%s">%s</span>',
|
||||
htmlspecialchars('In den Contao-Einstellungen ist noch keine Ergebnisseite hinterlegt oder der Link-Schlüssel ist ungültig.', ENT_QUOTES),
|
||||
Image::getHtml($icon ?? 'show.svg', $label)
|
||||
);
|
||||
Image::getHtml('show.svg', 'Ergebnisse anzeigen')
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<a href="%s" title="%s" target="_blank" rel="noreferrer"%s>%s</a>',
|
||||
htmlspecialchars($resultsUrl, ENT_QUOTES),
|
||||
htmlspecialchars($title, ENT_QUOTES),
|
||||
$attributes,
|
||||
Image::getHtml($icon ?? 'show.svg', $label).' '.$label
|
||||
);
|
||||
$operation->setUrl($resultsUrl);
|
||||
$operation['label'] = 'Ergebnisse anzeigen';
|
||||
$operation['title'] = 'Die Ergebnisse dieser Umfrage im Frontend anzeigen';
|
||||
$operation['icon'] = 'show.svg';
|
||||
$operation['attributes']
|
||||
->set('target', '_blank')
|
||||
->set('rel', 'noreferrer')
|
||||
->set('data-contao--tooltips-target', 'tooltip')
|
||||
;
|
||||
}
|
||||
|
||||
public function generatePublishedWarningButton(array $row, ?string $href, string $label, string $title, ?string $icon, string $attributes): string
|
||||
public function generatePublishedWarningButton(DataContainerOperation $operation): void
|
||||
{
|
||||
$row = $operation->getRecord() ?? [];
|
||||
|
||||
if ('1' !== (string) ($row['published'] ?? '')) {
|
||||
return '';
|
||||
$operation->setHtml('');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
$operation->setHtml(sprintf(
|
||||
'<span title="%s"%s>%s</span>',
|
||||
htmlspecialchars('Umfrage bereits veröffentlicht, keine Änderungen an den Fragen vornehmen!', ENT_QUOTES),
|
||||
$attributes,
|
||||
Image::getHtml($icon ?? 'important.svg', $label)
|
||||
);
|
||||
$operation['attributes'],
|
||||
Image::getHtml('important.svg', 'Veröffentlichungshinweis')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,7 +76,7 @@ final class SurveyRepository
|
||||
LEFT JOIN tl_survey_content q ON q.pid = s.id
|
||||
LEFT JOIN tl_survey_submission sub ON sub.survey = s.id
|
||||
GROUP BY s.id
|
||||
ORDER BY s.updatedAt DESC, s.title ASC
|
||||
ORDER BY s.title ASC, s.id ASC
|
||||
SQL,
|
||||
['member' => $memberId],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user