From 87bbfc75f3ed0e105ae8fe77d82909e9d77789b2 Mon Sep 17 00:00:00 2001 From: kentah <158997636+KentaHizume@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:47:52 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=E4=B8=8B=E8=A8=98=E3=81=AE3=E7=AE=87?= =?UTF-8?q?=E6=89=80=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6=E3=80=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=80=85=E3=81=A7=E3=81=AA=E3=81=91=E3=82=8C=E3=81=B0?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E9=9D=9E=E6=B4=BB=E6=80=A7?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=20=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AE=E8=BF=BD=E5=8A=A0=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=20=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2=E3=81=AE=E6=9B=B4=E6=96=B0=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=80=81=E5=89=8A=E9=99=A4=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/src/stores/authentication/authentication.ts | 10 ++++++++++ .../admin/src/views/catalog/ItemsAddView.vue | 4 +++- .../admin/src/views/catalog/ItemsEditView.vue | 11 +++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/samples/web-csr/dressca-frontend/admin/src/stores/authentication/authentication.ts b/samples/web-csr/dressca-frontend/admin/src/stores/authentication/authentication.ts index 2d504d4e2..84c623197 100644 --- a/samples/web-csr/dressca-frontend/admin/src/stores/authentication/authentication.ts +++ b/samples/web-csr/dressca-frontend/admin/src/stores/authentication/authentication.ts @@ -53,5 +53,15 @@ export const useAuthenticationStore = defineStore({ isAuthenticated(state) { return state.authenticationState; }, + /** + * ユーザーが特定のロールに属するかどうかを判定する関数を取得します。 + * ストアのゲッターには直接パラメーターを渡すことができないので、 + * 関数を経由してパラメーターを受け取る必要があります。 + * @param state 状態。 + * @returns ユーザーが特定のロールに属するかどうかを判定する関数。 + */ + isInRole(state) { + return (role: string) => state.userRoles.includes(role); + }, }, }); diff --git a/samples/web-csr/dressca-frontend/admin/src/views/catalog/ItemsAddView.vue b/samples/web-csr/dressca-frontend/admin/src/views/catalog/ItemsAddView.vue index 617d58444..2f737fd34 100644 --- a/samples/web-csr/dressca-frontend/admin/src/views/catalog/ItemsAddView.vue +++ b/samples/web-csr/dressca-frontend/admin/src/views/catalog/ItemsAddView.vue @@ -14,9 +14,11 @@ import type { GetCatalogBrandsResponse, GetCatalogCategoriesResponse, } from '@/generated/api-client'; +import { useAuthenticationStore } from '@/stores/authentication/authentication'; const router = useRouter(); const customErrorHandler = useCustomErrorHandler(); +const authenticationStore = useAuthenticationStore(); const { errors, values, meta, defineField } = useForm({ validationSchema: catalogItemSchema, @@ -211,7 +213,7 @@ onMounted(async () => {