Handle saving and loading list page. Add support for showInManageSubscriptionPage checkbox input
MAILPOET-4669
This commit is contained in:
committed by
Aschepikov
parent
31c2915075
commit
48181994d8
@ -34,6 +34,7 @@ class SegmentsResponseBuilder {
|
||||
'deleted_at' => ($deletedAt = $segment->getDeletedAt()) ? $deletedAt->format(self::DATE_FORMAT) : null,
|
||||
'average_engagement_score' => $segment->getAverageEngagementScore(),
|
||||
'filters_connect' => $segment->getFiltersConnectOperator(),
|
||||
'showInManageSubscriptionPage' => $segment->getDisplayInManageSubscriptionPage(),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,9 @@ class SegmentSaveController {
|
||||
$id = isset($data['id']) ? (int)$data['id'] : null;
|
||||
$name = $data['name'] ?? '';
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,8 +133,10 @@ class SegmentsRepository extends Repository {
|
||||
string $description = '',
|
||||
string $type = SegmentEntity::TYPE_DEFAULT,
|
||||
array $filtersData = [],
|
||||
?int $id = null
|
||||
?int $id = null,
|
||||
?int $displayInManageSubscriptionPage = 1
|
||||
): SegmentEntity {
|
||||
$displayInManageSubPage = $type === SegmentEntity::TYPE_DEFAULT ? $displayInManageSubscriptionPage ?? 1 : 0;
|
||||
if ($id) {
|
||||
$segment = $this->findOneById($id);
|
||||
if (!$segment instanceof SegmentEntity) {
|
||||
@ -145,9 +147,11 @@ class SegmentsRepository extends Repository {
|
||||
$segment->setName($name);
|
||||
}
|
||||
$segment->setDescription($description);
|
||||
$segment->setDisplayInManageSubscriptionPage($displayInManageSubPage);
|
||||
} else {
|
||||
$this->verifyNameIsUnique($name, $id);
|
||||
$segment = new SegmentEntity($name, $type, $description);
|
||||
$segment->setDisplayInManageSubscriptionPage($displayInManageSubPage);
|
||||
$this->persist($segment);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user