From 72639caa77589768cc82a69579197b60963c959f Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sat, 21 Jun 2025 18:48:52 +0200 Subject: [PATCH] edit poll groups Signed-off-by: dartcafe --- lib/Controller/PollController.php | 15 ++ lib/Service/PollService.php | 21 ++ src/Api/modules/polls.ts | 21 ++ .../Actions/modules/ActionEditGroup.vue | 57 +++++ src/components/PollGroup/PollGroupEditDlg.vue | 200 ++++++++++++++++++ src/stores/polls.ts | 53 +++-- src/views/PollList.vue | 8 + 7 files changed, 362 insertions(+), 13 deletions(-) create mode 100644 src/components/Actions/modules/ActionEditGroup.vue create mode 100644 src/components/PollGroup/PollGroupEditDlg.vue diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index f5d3a1d903..d3a29969a7 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -313,6 +313,21 @@ public function addPollToPollGroup(int $pollId, int $pollGroupId): JSONResponse ]); } + /** + * Update Pollgroup + */ + #[NoAdminRequired] + #[FrontpageRoute(verb: 'PUT', url: '/pollgroup/{pollGroupId}/update')] + public function updatePollGroup( + int $pollGroupId, + string $title, + string $titleExt, + string $description, + ): JSONResponse { + return $this->response(fn () => [ + 'pollGroup' => $this->pollService->updatePollGroup($pollGroupId, $title, $titleExt, $description), + ]); + } /** * Remove poll from pollgroup * @param int $pollId Poll id diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php index 92b0fbf1a6..2db1c161d0 100644 --- a/lib/Service/PollService.php +++ b/lib/Service/PollService.php @@ -72,6 +72,27 @@ public function listPollGroups(): array { return $this->pollGroupMapper->list(); } + public function updatePollGroup( + int $pollGroupId, + string $title, + string $titleExt, + string $description, + ): PollGroup { + try { + $pollGroup = $this->pollGroupMapper->find($pollGroupId); + if ($pollGroup->getOwner() !== $this->userSession->getCurrentUserId()) { + throw new ForbiddenException('You do not have permission to edit this poll group'); + } + $pollGroup->setTitle($title); + $pollGroup->setTitleExt($titleExt); + $pollGroup->setDescription($description); + + $pollGroup = $this->pollGroupMapper->update($pollGroup); + return $pollGroup; + } catch (DoesNotExistException $e) { + throw new NotFoundException('Poll group not found'); + } + } public function addPollToPollGroup( int $pollId, ?int $pollGroupId = null, diff --git a/src/Api/modules/polls.ts b/src/Api/modules/polls.ts index 7d84a42d39..9558c18c5b 100644 --- a/src/Api/modules/polls.ts +++ b/src/Api/modules/polls.ts @@ -76,6 +76,27 @@ const polls = { }) }, + updatePollGroup( + pollGroupId: number, + title: string, + titleExt: string, + description: string, + ): Promise> { + return httpInstance.request({ + method: 'PUT', + url: `pollgroup/${pollGroupId}/update`, + data: { + title, + titleExt, + description, + }, + cancelToken: + cancelTokenHandlerObject[ + this.updatePollGroup.name + ].handleRequestCancellation().token, + }) + }, + getPolls(): Promise< AxiosResponse<{ polls: Poll[] diff --git a/src/components/Actions/modules/ActionEditGroup.vue b/src/components/Actions/modules/ActionEditGroup.vue new file mode 100644 index 0000000000..ee4bf934e3 --- /dev/null +++ b/src/components/Actions/modules/ActionEditGroup.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/components/PollGroup/PollGroupEditDlg.vue b/src/components/PollGroup/PollGroupEditDlg.vue new file mode 100644 index 0000000000..b93cdd9b16 --- /dev/null +++ b/src/components/PollGroup/PollGroupEditDlg.vue @@ -0,0 +1,200 @@ + + + + +