From deacd0dfc195bca41af631114804d29937337cd8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 17 Jan 2024 02:11:31 +0900 Subject: . --- services/app/src/Forms/AdminUserEditForm.php | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 services/app/src/Forms/AdminUserEditForm.php (limited to 'services/app/src/Forms/AdminUserEditForm.php') diff --git a/services/app/src/Forms/AdminUserEditForm.php b/services/app/src/Forms/AdminUserEditForm.php new file mode 100644 index 0000000..1a17f6c --- /dev/null +++ b/services/app/src/Forms/AdminUserEditForm.php @@ -0,0 +1,85 @@ + $user->username, + 'is_admin' => $user->is_admin ? 'on' : '', + ]); + } + parent::__construct($state); + } + + public function pageTitle(): string + { + return "管理画面 - ユーザ {$this->user->username} 編集"; + } + + public function redirectUrl(): string + { + return $this->routeParser->urlFor('admin_user_list'); + } + + protected function submitLabel(): string + { + return '保存'; + } + + /** + * @return list + */ + protected function items(): array + { + return [ + new FormItem( + name: 'username', + type: 'text', + label: 'ユーザ名', + isDisabled: true, + ), + new FormItem( + name: 'is_admin', + type: 'checkbox', + label: '管理者', + ), + ]; + } + + /** + * @return array{user: User} + */ + public function getRenderContext(): array + { + return [ + 'user' => $this->user, + ]; + } + + public function submit(): void + { + $is_admin = $this->state->get('is_admin') === 'on'; + + $this->userRepo->update( + $this->user->user_id, + is_admin: $is_admin, + ); + } +} -- cgit v1.2.3-70-g09d2