From 90458d9195a999ab0ce2b2c936f4a1d716d340fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 18 Oct 2023 23:20:07 +0200 Subject: [PATCH 1/3] mail history grid update --- .../Components/MailHistoryGridControl.php | 15 +++++++++++---- app/Model/Mailing/Mail.php | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php b/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php index 42d36be79..43d2169e8 100644 --- a/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php +++ b/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php @@ -49,6 +49,14 @@ public function createComponentMailHistoryGrid(string $name): void $grid->setItemsPerPageList([25, 50, 100, 250, 500]); $grid->setStrictSessionFilterValues(false); + $grid->addColumnText('recipientUsers', 'admin.mailing.history.recipient_users', 'recipientUsersText') + ->setFilterText() + ->setCondition(static function (QueryBuilder $qb, string $value): void { + $qb->join('m.recipientUsers', 'u') + ->andWhere('u.displayName LIKE :displayName') + ->setParameter('displayName', '%' . $value . '%'); + }); + $grid->addColumnText('recipientRoles', 'admin.mailing.history.recipient_roles', 'recipientRolesText') ->setFilterMultiSelect($this->aclService->getRolesWithoutRolesOptions([Role::GUEST, Role::UNAPPROVED, Role::NONREGISTERED])) ->setCondition(static function (QueryBuilder $qb, ArrayHash $values): void { @@ -65,12 +73,11 @@ public function createComponentMailHistoryGrid(string $name): void ->setParameter('sids', (array) $values); }); - $grid->addColumnText('recipientUsers', 'admin.mailing.history.recipient_users', 'recipientUsersText') + $grid->addColumnText('recipientEmails', 'admin.mailing.history.recipient_emails', 'recipientEmailsText') ->setFilterText() ->setCondition(static function (QueryBuilder $qb, string $value): void { - $qb->join('m.recipientUsers', 'u') - ->andWhere('u.displayName LIKE :displayName') - ->setParameter('displayName', '%' . $value . '%'); + $qb->andWhere('m.recipientUsers LIKE :email') + ->setParameter('email', $value); }); $grid->addColumnText('subject', 'admin.mailing.history.subject') diff --git a/app/Model/Mailing/Mail.php b/app/Model/Mailing/Mail.php index f5e562f54..49bedcac6 100644 --- a/app/Model/Mailing/Mail.php +++ b/app/Model/Mailing/Mail.php @@ -175,6 +175,11 @@ public function setRecipientEmails(array $recipientEmails): void $this->recipientEmails = $recipientEmails; } + public function getRecipientEmailsText(): string + { + return implode(', ', $this->recipientEmails); + } + public function getSubject(): string { return $this->subject; From fd37d5d99e52ae5283eb4061d234c6482e0988e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Thu, 19 Oct 2023 09:37:34 +0200 Subject: [PATCH 2/3] fixes --- .../MailingModule/Forms/SendFormFactory.php | 22 +++++++++---------- app/lang/admin.cs_CZ.neon | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/AdminModule/MailingModule/Forms/SendFormFactory.php b/app/AdminModule/MailingModule/Forms/SendFormFactory.php index 854e885fe..d882cdc9d 100644 --- a/app/AdminModule/MailingModule/Forms/SendFormFactory.php +++ b/app/AdminModule/MailingModule/Forms/SendFormFactory.php @@ -44,6 +44,13 @@ public function create(): Form { $form = $this->baseFormFactory->create(); + $recipientUsersMultiSelect = $form->addMultiSelect( + 'recipientUsers', + 'admin.mailing.send.recipient_users', + $this->userRepository->getUsersOptions(), + ) + ->setHtmlAttribute('data-live-search', 'true'); + $recipientRolesMultiSelect = $form->addMultiSelect( 'recipientRoles', 'admin.mailing.send.recipient_roles', @@ -56,12 +63,10 @@ public function create(): Form $this->subeventService->getSubeventsOptionsWithUsersCount(), ); - $recipientUsersMultiSelect = $form->addMultiSelect( - 'recipientUsers', - 'admin.mailing.send.recipient_users', - $this->userRepository->getUsersOptions(), - ) - ->setHtmlAttribute('data-live-search', 'true'); + $recipientUsersMultiSelect + ->addConditionOn($recipientRolesMultiSelect, Form::BLANK) + ->addConditionOn($recipientSubeventsMultiSelect, Form::BLANK) + ->addRule(Form::FILLED, 'admin.mailing.send.recipients_empty'); $recipientRolesMultiSelect ->addConditionOn($recipientSubeventsMultiSelect, Form::BLANK) @@ -73,11 +78,6 @@ public function create(): Form ->addConditionOn($recipientUsersMultiSelect, Form::BLANK) ->addRule(Form::FILLED, 'admin.mailing.send.recipients_empty'); - $recipientUsersMultiSelect - ->addConditionOn($recipientRolesMultiSelect, Form::BLANK) - ->addConditionOn($recipientSubeventsMultiSelect, Form::BLANK) - ->addRule(Form::FILLED, 'admin.mailing.send.recipients_empty'); - $form->addText('copy', 'admin.mailing.send.copy') ->addCondition(Form::FILLED) ->addRule(Form::EMAIL, 'admin.mailing.send.copy_format'); diff --git a/app/lang/admin.cs_CZ.neon b/app/lang/admin.cs_CZ.neon index 02a84b247..2b2e822a1 100644 --- a/app/lang/admin.cs_CZ.neon +++ b/app/lang/admin.cs_CZ.neon @@ -625,9 +625,10 @@ mailing: heading: "Historie" datetime: "Odesláno" subject: "Předmět" + recipient_users: "Příjemci - uživatelé" recipient_roles: "Příjemci - role" recipient_subevents: "Příjemci - podakce" - recipient_users: "Příjemci - uživatelé" + recipient_emails: "Příjemci - e-maily" automatic: "Automatický" configuration: From 4469fd9b69442dded30d3481905340171b44be0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Thu, 19 Oct 2023 09:41:51 +0200 Subject: [PATCH 3/3] filter fix --- .../MailingModule/Components/MailHistoryGridControl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php b/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php index 43d2169e8..31ea730bf 100644 --- a/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php +++ b/app/AdminModule/MailingModule/Components/MailHistoryGridControl.php @@ -76,8 +76,8 @@ public function createComponentMailHistoryGrid(string $name): void $grid->addColumnText('recipientEmails', 'admin.mailing.history.recipient_emails', 'recipientEmailsText') ->setFilterText() ->setCondition(static function (QueryBuilder $qb, string $value): void { - $qb->andWhere('m.recipientUsers LIKE :email') - ->setParameter('email', $value); + $qb->andWhere('m.recipientEmails LIKE :email') + ->setParameter('email', '%' . $value . '%'); }); $grid->addColumnText('subject', 'admin.mailing.history.subject')