Handle saving and loading list page. Add support for showInManageSubscriptionPage checkbox input

MAILPOET-4669
This commit is contained in:
Oluwaseun Olorunsola
2022-11-02 13:15:23 +01:00
committed by Aschepikov
parent 31c2915075
commit 48181994d8
3 changed files with 8 additions and 2 deletions

View File

@ -34,6 +34,7 @@ class SegmentsResponseBuilder {
'deleted_at' => ($deletedAt = $segment->getDeletedAt()) ? $deletedAt->format(self::DATE_FORMAT) : null, 'deleted_at' => ($deletedAt = $segment->getDeletedAt()) ? $deletedAt->format(self::DATE_FORMAT) : null,
'average_engagement_score' => $segment->getAverageEngagementScore(), 'average_engagement_score' => $segment->getAverageEngagementScore(),
'filters_connect' => $segment->getFiltersConnectOperator(), 'filters_connect' => $segment->getFiltersConnectOperator(),
'showInManageSubscriptionPage' => $segment->getDisplayInManageSubscriptionPage(),
]; ];
} }

View File

@ -33,8 +33,9 @@ class SegmentSaveController {
$id = isset($data['id']) ? (int)$data['id'] : null; $id = isset($data['id']) ? (int)$data['id'] : null;
$name = $data['name'] ?? ''; $name = $data['name'] ?? '';
$description = $data['description'] ?? ''; $description = $data['description'] ?? '';
$displayInManageSubPage = $data['showInManageSubscriptionPage'] ?? null;
return $this->segmentsRepository->createOrUpdate($name, $description, SegmentEntity::TYPE_DEFAULT, [], $id); return $this->segmentsRepository->createOrUpdate($name, $description, SegmentEntity::TYPE_DEFAULT, [], $id, $displayInManageSubPage);
} }
/** /**

View File

@ -133,8 +133,10 @@ class SegmentsRepository extends Repository {
string $description = '', string $description = '',
string $type = SegmentEntity::TYPE_DEFAULT, string $type = SegmentEntity::TYPE_DEFAULT,
array $filtersData = [], array $filtersData = [],
?int $id = null ?int $id = null,
?int $displayInManageSubscriptionPage = 1
): SegmentEntity { ): SegmentEntity {
$displayInManageSubPage = $type === SegmentEntity::TYPE_DEFAULT ? $displayInManageSubscriptionPage ?? 1 : 0;
if ($id) { if ($id) {
$segment = $this->findOneById($id); $segment = $this->findOneById($id);
if (!$segment instanceof SegmentEntity) { if (!$segment instanceof SegmentEntity) {
@ -145,9 +147,11 @@ class SegmentsRepository extends Repository {
$segment->setName($name); $segment->setName($name);
} }
$segment->setDescription($description); $segment->setDescription($description);
$segment->setDisplayInManageSubscriptionPage($displayInManageSubPage);
} else { } else {
$this->verifyNameIsUnique($name, $id); $this->verifyNameIsUnique($name, $id);
$segment = new SegmentEntity($name, $type, $description); $segment = new SegmentEntity($name, $type, $description);
$segment->setDisplayInManageSubscriptionPage($displayInManageSubPage);
$this->persist($segment); $this->persist($segment);
} }