From f26fd1d86e365d3acf194ae7f0dfe06a8907b803 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Tue, 20 Oct 2026 12:09:20 +0330 Subject: [PATCH] changes of giftCard page --- .../abshode-domain-lookup/learned-notes.md | 5 ++ app/Services/AdminPageAccess.php | 64 ++++++++++++++++--- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/.cursor/skills/abshode-domain-lookup/learned-notes.md b/.cursor/skills/abshode-domain-lookup/learned-notes.md index 7080ea5..ed5a768 100644 --- a/.cursor/skills/abshode-domain-lookup/learned-notes.md +++ b/.cursor/skills/abshode-domain-lookup/learned-notes.md @@ -20,3 +20,8 @@ - 2026-09-09 | رمز ادمین ≠ لاگین اپ | `Customer::setPasswordAttribute` + `AuthController` + `updateAdmin` | قبل از هش/لاگین ارقام فارسی→انگلیسی؛ jwt hash=false؛ آنلاین فقط password غیرخالی بفرست - 2026-10-20 | دسترسی صفحات مدیر | `users.page_access` + `AdminPageAccess` + ادمین `adminPageAccess.ts` / ویرایش مدیران | null=کامل؛ درخت مشاهده/ویرایش/حذف؛ ورود=اولین صفحه مجاز؛ منوی ممنوع=«شما به این صفحه دسترسی ندارید» - 2026-10-20 | ویرایش/حذف کارت هدیه | `GiftCardController::update/destroy` + `giftCards/components/table.vue` | PUT/DELETE `/admin/giftcard/{id}`؛ کارت استفاده‌شده حذف نمی‌شود و مقدار/تعدادش عوض نمی‌شود +- 2026-10-20 | دکمه ویرایش/حذف گیفت | `allowsPageFlag` + `giftCards/components/table.vue` | بدون edit/delete روی giftCardMain دکمه و دیالوگ باز نمی‌شود +- 2026-10-20 | دسترسی عملیات جدول | `PAGE_TABLE_ACTIONS` + `usePageActionAccess` + `AdminPageAccess::ACTIONS` | هر صفحه فقط عملیات ستون خودش؛ مشاهده جدا؛ رکورد قدیمی بدون actions ویرایش/حذف را از همان فیلد و بقیه را از مشاهده می‌گیرد +- 2026-10-20 | چیدمان درخت دسترسی | `users/components/ManagerPageAccessTree.vue` | هر صفحه یک کالپس؛ وضعیت روی هدر؛ عملیات جدول داخل همان صفحه +- 2026-10-20 | مشخصات کارت هدیه | `giftCards/index.vue` تابع `info` | کدهای یکتا در مودال مشخصات نیست؛ همان جدول کدها +- 2026-10-20 | کپی کد هدیه | `giftCards/components/GiftCardCodesSheet.vue` | کنار کد هر ردیف آیکون کپی؛ پیام «کد کپی شد» diff --git a/app/Services/AdminPageAccess.php b/app/Services/AdminPageAccess.php index d0e2d15..76c9cb0 100644 --- a/app/Services/AdminPageAccess.php +++ b/app/Services/AdminPageAccess.php @@ -56,6 +56,31 @@ class AdminPageAccess 'usersMain', ]; + /** کلید عملیات ستون هر صفحه؛ با PAGE_TABLE_ACTIONS ادمین یکی بماند. */ + public const ACTIONS = [ + 'customerMain_limitedOrder' => ['charge', 'tahesab', 'zarin', 'pargar', 'accountingCode', 'info', 'edit', 'referral', 'sms', 'approve', 'archive', 'active', 'trade'], + 'customerMain_archive' => ['restore', 'info'], + 'customerMain_specialPrice' => ['edit', 'toggle', 'delete'], + 'customerMain_goldCredit' => ['detail', 'edit', 'approve', 'reject'], + 'productsMain_limitedOrder' => ['buy', 'sell', 'list', 'tv', 'edit', 'archive'], + 'productsMain_archive' => ['restore', 'info'], + 'ordersMain' => ['info'], + 'transactionsMain' => ['info'], + 'accountsMain' => ['toggle', 'delete'], + 'walletMain' => ['info'], + 'physicalWithdrawMain' => ['amount', 'approve', 'status', 'factor'], + 'withdrawMain' => ['confirm', 'factor', 'status', 'weight', 'tahesab', 'zarin'], + 'pricingMain' => ['details'], + 'priceTriggers' => ['edit', 'toggle', 'delete'], + 'conditionalOrders' => ['edit', 'toggle', 'delete'], + 'accountingMain' => ['doc', 'register', 'send'], + 'appNotifications' => ['recipients', 'readers', 'edit', 'toggle', 'delete'], + 'automations' => ['preview', 'log', 'edit', 'toggle', 'delete'], + 'giftCardMain' => ['info', 'codes', 'edit', 'delete'], + 'discounts' => ['edit'], + 'usersMain' => ['info', 'edit', 'delete'], + ]; + private const ALIASES = [ 'dashboard' => 'dashboardMain', 'main' => 'dashboardMain', @@ -113,21 +138,43 @@ class AdminPageAccess $view = self::toBool($row['view'] ?? false); $edit = self::toBool($row['edit'] ?? false); $delete = self::toBool($row['delete'] ?? false); - if ($edit || $delete) { + $actions = null; + if (is_array($row['actions'] ?? null)) { + $actions = []; + foreach (self::ACTIONS[$key] ?? [] as $actionKey) { + $actions[$actionKey] = self::toBool($row['actions'][$actionKey] ?? false); + } + if (array_key_exists('edit', $actions)) { + $edit = $actions['edit']; + } + if (array_key_exists('delete', $actions)) { + $delete = $actions['delete']; + } + } + if ($edit || $delete || ($actions && in_array(true, $actions, true))) { $view = true; } if (!$view) { $edit = false; $delete = false; + if (is_array($actions)) { + foreach ($actions as $actionKey => $enabled) { + $actions[$actionKey] = false; + } + } } - if (!$view && !$edit && !$delete) { + if (!$view && !$edit && !$delete && !($actions && in_array(true, $actions, true))) { continue; } - $out[$key] = [ + $stored = [ 'view' => $view, 'edit' => $edit, 'delete' => $delete, ]; + if (is_array($actions) && $actions) { + $stored['actions'] = $actions; + } + $out[$key] = $stored; } return $out; @@ -163,11 +210,12 @@ class AdminPageAccess if (!is_array($row)) { return false; } - if ($action === 'delete') { - return !empty($row['delete']); - } - if ($action === 'edit') { - return !empty($row['edit']); + if ($action === 'delete' || $action === 'edit') { + $actions = $row['actions'] ?? null; + if (is_array($actions) && array_key_exists($action, $actions)) { + return !empty($actions[$action]); + } + return !empty($row[$action]); } return !empty($row['view']); }