Przeglądaj źródła

refactored menu

Alexander Musikhin 2 tygodni temu
rodzic
commit
84faaef1d8

+ 20 - 0
app/Http/Controllers/UnderDevelopmentController.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Contracts\View\View;
+use Illuminate\Http\Request;
+
+class UnderDevelopmentController extends Controller
+{
+    public function __invoke(Request $request): View
+    {
+        $title = (string) $request->route('title', 'Раздел');
+
+        return view('development.index', [
+            'active' => (string) $request->route('active', 'development'),
+            'title' => $title,
+            'sectionTitle' => $title,
+        ]);
+    }
+}

+ 8 - 1
config/access_routes.php

@@ -3,6 +3,9 @@
 return [
     'exact' => [
         'area.ajax-get-areas-by-district' => 'areas.ajax.view',
+        'calculations.index' => true,
+        'common-catalog.index' => true,
+        'documents.index' => true,
         'getFilters' => 'filters.view',
         'notifications.index' => true,
         'notifications.read-all' => true,
@@ -11,6 +14,10 @@ return [
         'product.search' => 'catalog.search',
         'pricing_codes.get_description' => 'pricing_codes.search',
         'pricing_codes.search' => 'pricing_codes.search',
+        'schedule.orders' => true,
+        'schedule.deliveries' => true,
+        'stock.index' => true,
+        'stock.orders' => true,
         'user.profile' => 'profile.view',
         'profile.store' => 'profile.update',
         'profile.delete' => 'profile.delete',
@@ -137,7 +144,7 @@ return [
             'generate-reclamation-pack' => 'reclamations.documents.generate',
         ],
         'pricing_codes.' => [
-            'index' => 'pricing_codes.view',
+            'index' => ['pricing_codes.view', 'spare_parts.view'],
             'store' => 'pricing_codes.create',
             'update' => 'pricing_codes.update',
             'destroy' => 'pricing_codes.delete',

+ 18 - 18
docs/refactor/plan.md

@@ -82,24 +82,24 @@
 
 ## Этап 1. Реорганизация меню и заглушки
 
-Статус: **готов к реализации**.
-
-- [ ] Проверить текущие permissions для всех существующих пунктов меню.
-- [ ] Для новых пунктов-заглушек открыть доступ всем авторизованным пользователям.
-- [ ] Добавить общий механизм страницы `В разработке`.
-- [ ] Добавить маршруты для новых разделов-заглушек.
-- [ ] Перестроить `resources/views/layouts/menu.blade.php` под новую древовидную структуру.
-- [ ] Сгруппировать существующие пункты ДКР внутрь верхнего меню `ДКР`.
-- [ ] Оставить `Каталог` внутри меню `ДКР`.
-- [ ] Добавить отдельный верхний пункт `Каталог общий`.
-- [ ] Сгруппировать `График монтажей` внутрь верхнего меню `Графики`.
-- [ ] Добавить заглушки `График заказов` и `График доставок`.
-- [ ] Разложить `Рекламации` на `Все` и `ДКР`.
-- [ ] Оставить `Запчасти` отдельной верхней группой с текущими вкладками.
-- [ ] Добавить заглушки `Склад наличие -> Наличие` и `Склад наличие -> Заказы`.
-- [ ] Добавить заглушки `Документация`, `Каталог общий`, `Калькуляции`.
-- [ ] Проверить, что выбранный год не скрывает и не фильтрует новые модули.
-- [ ] Переименовать группу `Администрирование` в `Администратор`.
+Статус: **реализован, ожидает пользовательской проверки**.
+
+- [x] Проверить текущие permissions для всех существующих пунктов меню.
+- [x] Для новых пунктов-заглушек открыть доступ всем авторизованным пользователям.
+- [x] Добавить общий механизм страницы `В разработке`.
+- [x] Добавить маршруты для новых разделов-заглушек.
+- [x] Перестроить `resources/views/layouts/menu.blade.php` под новую древовидную структуру.
+- [x] Сгруппировать существующие пункты ДКР внутрь верхнего меню `ДКР`.
+- [x] Оставить `Каталог` внутри меню `ДКР`.
+- [x] Добавить отдельный верхний пункт `Каталог общий`.
+- [x] Сгруппировать `График монтажей` внутрь верхнего меню `Графики`.
+- [x] Добавить заглушки `График заказов` и `График доставок`.
+- [x] Разложить `Рекламации` на `Все` и `ДКР`.
+- [x] Оставить `Запчасти` отдельной верхней группой с текущими вкладками.
+- [x] Добавить заглушки `Склад наличие -> Наличие` и `Склад наличие -> Заказы`.
+- [x] Добавить заглушки `Документация`, `Каталог общий`, `Калькуляции`.
+- [x] Проверить, что выбранный год не скрывает и не фильтрует новые модули.
+- [x] Переименовать группу `Администрирование` в `Администратор`.
 - [ ] Проверить отображение меню для основных ролей.
 
 ## Этап 2. Адаптация существующих разделов после переноса

+ 14 - 0
resources/views/development/index.blade.php

@@ -0,0 +1,14 @@
+@extends('layouts.app')
+
+@section('content')
+    <div class="row justify-content-center">
+        <div class="col-12 col-lg-8 col-xl-6">
+            <div class="card">
+                <div class="card-body text-center py-5">
+                    <h1 class="h4 mb-3">{{ $sectionTitle }}</h1>
+                    <p class="text-muted mb-0">В разработке</p>
+                </div>
+            </div>
+        </div>
+    </div>
+@endsection

+ 128 - 58
resources/views/layouts/menu.blade.php

@@ -1,57 +1,129 @@
 @if(auth()->check())
-    @if(hasPermission('orders.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'orders') active @endif" href="{{ route('order.index', session('gp_orders')) }}">Площадки</a></li>
-    @endif
+    @php
+        $dkrActive = in_array($active ?? '', [
+            'orders',
+            'product_sku',
+            'catalog',
+            'reports',
+            'responsibles',
+            'maf_order',
+        ], true);
 
-    @if(hasPermission('maf.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'product_sku') active @endif"
-                                href="{{ route('product_sku.index', session('gp_product_sku')) }}">МАФ</a></li>
-    @endif
-    @if(hasPermission('catalog.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'catalog') active @endif"
-                                href="{{ route('catalog.index', session('gp_products')) }}">Каталог</a></li>
-    @endif
-    @if(hasPermission('reports.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'reports') active @endif"
-                                href="{{ route('reports.index', session('gp_reports')) }}">Отчёты</a></li>
-    @endif
-    @if(hasPermission('responsibles.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'responsibles') active @endif" href="{{ route('responsible.index', session('gp_responsibles')) }}">Ответственные</a></li>
+        $schedulesActive = in_array($active ?? '', [
+            'schedule_orders',
+            'schedule_deliveries',
+            'schedule',
+        ], true);
+
+        $reclamationsActive = ($active ?? '') === 'reclamations';
+
+        $sparePartsActive = in_array($active ?? '', [
+            'spare_parts',
+            'spare_part_orders',
+            'spare_part_inventory',
+            'pricing_codes',
+        ], true);
+
+        $stockActive = in_array($active ?? '', ['stock', 'stock_orders'], true);
+
+        $adminActive = in_array($active ?? '', [
+            'contractors',
+            'contracts',
+            'users',
+            'roles',
+            'admin_settings',
+            'admin_districts',
+            'admin_areas',
+            'notification_logs',
+            'import',
+            'year-data',
+            'clear-data',
+        ], true);
+    @endphp
+
+    @if(hasAnyPermission([
+        'orders.view',
+        'maf.view',
+        'catalog.view',
+        'reports.view',
+        'responsibles.view',
+        'maf_orders.view',
+    ]))
+        <li class="nav-item dropdown">
+            <a class="nav-link dropdown-toggle @if($dkrActive) active @endif" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+                ДКР
+            </a>
+            <ul class="dropdown-menu">
+                @if(hasPermission('orders.view'))<li><a class="dropdown-item @if(($active ?? '') === 'orders') active @endif" href="{{ route('order.index', session('gp_orders')) }}">Площадки</a></li>@endif
+                @if(hasPermission('maf.view'))<li><a class="dropdown-item @if(($active ?? '') === 'product_sku') active @endif" href="{{ route('product_sku.index', session('gp_product_sku')) }}">МАФ</a></li>@endif
+                @if(hasPermission('catalog.view'))<li><a class="dropdown-item @if(($active ?? '') === 'catalog') active @endif" href="{{ route('catalog.index', session('gp_products')) }}">Каталог</a></li>@endif
+                @if(hasPermission('reports.view'))<li><a class="dropdown-item @if(($active ?? '') === 'reports') active @endif" href="{{ route('reports.index', session('gp_reports')) }}">Отчёты</a></li>@endif
+                @if(hasPermission('responsibles.view'))<li><a class="dropdown-item @if(($active ?? '') === 'responsibles') active @endif" href="{{ route('responsible.index', session('gp_responsibles')) }}">Ответственные</a></li>@endif
+                @if(hasPermission('maf_orders.view'))<li><a class="dropdown-item @if(($active ?? '') === 'maf_order') active @endif" href="{{ route('maf_order.index', session('gp_maf_order')) }}">Заказы МАФ</a></li>@endif
+            </ul>
+        </li>
     @endif
+
+    <li class="nav-item dropdown">
+        <a class="nav-link dropdown-toggle @if($schedulesActive) active @endif" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+            Графики
+        </a>
+        <ul class="dropdown-menu">
+            <li><a class="dropdown-item @if(($active ?? '') === 'schedule_orders') active @endif" href="{{ route('schedule.orders') }}">График заказов</a></li>
+            <li><a class="dropdown-item @if(($active ?? '') === 'schedule_deliveries') active @endif" href="{{ route('schedule.deliveries') }}">График доставок</a></li>
+            @if(hasPermission('schedule.view'))<li><a class="dropdown-item @if(($active ?? '') === 'schedule') active @endif" href="{{ route('schedule.index', session('gp_schedule')) }}">График монтажей</a></li>@endif
+        </ul>
+    </li>
+
     @if(hasPermission('reclamations.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'reclamations') active @endif"
-                                href="{{ route('reclamations.index', session('gp_reclamations')) }}">Рекламации</a></li>
+        <li class="nav-item dropdown">
+            <a class="nav-link dropdown-toggle @if($reclamationsActive) active @endif" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+                Рекламации
+            </a>
+            <ul class="dropdown-menu">
+                <li><a class="dropdown-item @if(($active ?? '') === 'reclamations' && request('tab') !== 'dkr') active @endif" href="{{ route('reclamations.index', session('gp_reclamations')) }}">Все</a></li>
+                <li><a class="dropdown-item @if(($active ?? '') === 'reclamations' && request('tab') === 'dkr') active @endif" href="{{ route('reclamations.index', array_merge((array) session('gp_reclamations', []), ['tab' => 'dkr'])) }}">ДКР</a></li>
+            </ul>
+        </li>
     @endif
 
     @if(hasPermission('spare_parts.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'spare_parts') active @endif"
-                                href="{{ route('spare_parts.index', session('gp_spare_parts', [])) }}">Запчасти</a></li>
+        <li class="nav-item dropdown">
+            <a class="nav-link dropdown-toggle @if($sparePartsActive) active @endif" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+                Запчасти
+            </a>
+            <ul class="dropdown-menu">
+                <li><a class="dropdown-item @if(($active ?? '') === 'spare_parts') active @endif" href="{{ route('spare_parts.index', session('gp_spare_parts', [])) }}">Каталог</a></li>
+                @if(hasPermission('spare_part_orders.view'))<li><a class="dropdown-item @if(($active ?? '') === 'spare_part_orders') active @endif" href="{{ route('spare_part_orders.index') }}">Заказы запчастей</a></li>@endif
+                @if(hasPermission('spare_part_inventory.view'))<li><a class="dropdown-item @if(($active ?? '') === 'spare_part_inventory') active @endif" href="{{ route('spare_part_inventory.index') }}">Контроль наличия</a></li>@endif
+                <li><a class="dropdown-item @if(($active ?? '') === 'pricing_codes') active @endif" href="{{ route('pricing_codes.index') }}">Справочник расшифровок</a></li>
+                <li><a class="dropdown-item" href="{{ route('spare_parts.help') }}">Справка</a></li>
+            </ul>
+        </li>
     @endif
 
-    @if(hasPermission('schedule.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'schedule') active @endif"
-                                href="{{ route('schedule.index', session('gp_schedule')) }}">График монтажей</a></li>
-    @endif
+    <li class="nav-item dropdown">
+        <a class="nav-link dropdown-toggle @if($stockActive) active @endif" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+            Склад наличие
+        </a>
+        <ul class="dropdown-menu">
+            <li><a class="dropdown-item @if(($active ?? '') === 'stock') active @endif" href="{{ route('stock.index') }}">Наличие</a></li>
+            <li><a class="dropdown-item @if(($active ?? '') === 'stock_orders') active @endif" href="{{ route('stock.orders') }}">Заказы</a></li>
+        </ul>
+    </li>
 
+    <li class="nav-item">
+        <a class="nav-link @if(($active ?? '') === 'common_catalog') active @endif" href="{{ route('common-catalog.index') }}">Каталог общий</a>
+    </li>
+
+    <li class="nav-item">
+        <a class="nav-link @if(($active ?? '') === 'documents') active @endif" href="{{ route('documents.index') }}">Документация</a>
+    </li>
+
+    <li class="nav-item">
+        <a class="nav-link @if(($active ?? '') === 'calculations') active @endif" href="{{ route('calculations.index') }}">Калькуляции</a>
+    </li>
 
-    @if(hasPermission('maf_orders.view'))
-        <li class="nav-item"><a class="nav-link @if($active == 'maf_order') active @endif"
-                                href="{{ route('maf_order.index', session('gp_maf_order')) }}">Заказы МАФ</a></li>
-    @endif
-    @if(hasPermission('contractors.view') && !hasAnyPermission([
-        'contracts.view',
-        'users.view',
-        'admin.settings.view',
-        'districts.view',
-        'areas.view',
-        'admin.notification_logs.view',
-        'import.view',
-        'admin.year_data.view',
-        'admin.clear_data.view',
-    ]))
-        <li class="nav-item"><a class="nav-link @if($active == 'contractors') active @endif"
-                                href="{{ route('contractors.index', session('gp_contractors')) }}">Подрядчики</a></li>
-    @endif
     @if(hasAnyPermission([
         'contractors.view',
         'contracts.view',
@@ -66,24 +138,22 @@
         'admin.clear_data.view',
     ]))
         <li class="nav-item dropdown">
-            <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
-               aria-haspopup="true" aria-expanded="false">
-                Администрирование
+            <a class="nav-link dropdown-toggle @if($adminActive) active @endif" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
+                Администратор
             </a>
             <ul class="dropdown-menu dropdown-menu-end">
-                @if(hasPermission('contractors.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('contractors.index', session('gp_contractors')) }}">Подрядчики</a></li>@endif
-                @if(hasPermission('contracts.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('contract.index', session('gp_contracts')) }}">Договоры</a></li>@endif
-                @if(hasPermission('users.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('user.index', session('gp_users')) }}">Пользователи</a></li>@endif
-                @if(hasPermission('admin.roles'))<li class="dropdown-item"><a class="nav-link" href="{{ route('admin.roles.index') }}">Роли и права</a></li>@endif
-                @if(hasPermission('admin.settings.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('admin.settings.index') }}">Настройки</a></li>@endif
-                @if(hasPermission('districts.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('admin.district.index') }}">Округа</a></li>@endif
-                @if(hasPermission('areas.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('admin.area.index') }}">Районы</a></li>@endif
-                @if(hasPermission('admin.notification_logs.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('admin.notifications.log') }}">Журнал уведомлений</a></li>@endif
-                @if(hasPermission('import.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('import.index', session('gp_import')) }}">Импорт</a></li>@endif
-                @if(hasPermission('admin.year_data.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('year-data.index') }}">Экспорт/Импорт года</a></li>@endif
-                @if(hasPermission('admin.clear_data.view'))<li class="dropdown-item"><a class="nav-link" href="{{ route('clear-data.index') }}">Удалить данные</a></li>@endif
+                @if(hasPermission('contractors.view'))<li><a class="dropdown-item @if(($active ?? '') === 'contractors') active @endif" href="{{ route('contractors.index', session('gp_contractors')) }}">Подрядчики</a></li>@endif
+                @if(hasPermission('contracts.view'))<li><a class="dropdown-item @if(($active ?? '') === 'contracts') active @endif" href="{{ route('contract.index', session('gp_contracts')) }}">Договоры</a></li>@endif
+                @if(hasPermission('users.view'))<li><a class="dropdown-item @if(($active ?? '') === 'users') active @endif" href="{{ route('user.index', session('gp_users')) }}">Пользователи</a></li>@endif
+                @if(hasPermission('admin.roles'))<li><a class="dropdown-item @if(($active ?? '') === 'roles') active @endif" href="{{ route('admin.roles.index') }}">Роли и права</a></li>@endif
+                @if(hasPermission('admin.settings.view'))<li><a class="dropdown-item @if(($active ?? '') === 'admin_settings') active @endif" href="{{ route('admin.settings.index') }}">Настройки</a></li>@endif
+                @if(hasPermission('districts.view'))<li><a class="dropdown-item @if(($active ?? '') === 'admin_districts') active @endif" href="{{ route('admin.district.index') }}">Округа</a></li>@endif
+                @if(hasPermission('areas.view'))<li><a class="dropdown-item @if(($active ?? '') === 'admin_areas') active @endif" href="{{ route('admin.area.index') }}">Районы</a></li>@endif
+                @if(hasPermission('admin.notification_logs.view'))<li><a class="dropdown-item @if(($active ?? '') === 'notification_logs') active @endif" href="{{ route('admin.notifications.log') }}">Журнал уведомлений</a></li>@endif
+                @if(hasPermission('import.view'))<li><a class="dropdown-item @if(($active ?? '') === 'import') active @endif" href="{{ route('import.index', session('gp_import')) }}">Импорт</a></li>@endif
+                @if(hasPermission('admin.year_data.view'))<li><a class="dropdown-item @if(($active ?? '') === 'year-data') active @endif" href="{{ route('year-data.index') }}">Экспорт/Импорт года</a></li>@endif
+                @if(hasPermission('admin.clear_data.view'))<li><a class="dropdown-item @if(($active ?? '') === 'clear-data') active @endif" href="{{ route('clear-data.index') }}">Удалить данные</a></li>@endif
             </ul>
         </li>
-
     @endif
 @endif

+ 38 - 0
routes/web.php

@@ -26,6 +26,7 @@ use App\Http\Controllers\SparePartController;
 use App\Http\Controllers\SparePartInventoryController;
 use App\Http\Controllers\SparePartOrderController;
 use App\Http\Controllers\SparePartReservationController;
+use App\Http\Controllers\UnderDevelopmentController;
 use App\Http\Controllers\UserController;
 use App\Http\Controllers\UserNotificationController;
 use Illuminate\Http\Request;
@@ -151,6 +152,43 @@ Route::middleware(['auth:web', 'route.permission'])->group(function () {
 
     Route::get('get-filters', [FilterController::class, 'getFilters'])->name('getFilters');
 
+    Route::get('common-catalog', UnderDevelopmentController::class)
+        ->defaults('title', 'Каталог общий')
+        ->defaults('active', 'common_catalog')
+        ->name('common-catalog.index');
+
+    Route::prefix('schedules')->name('schedule.')->group(function () {
+        Route::get('orders', UnderDevelopmentController::class)
+            ->defaults('title', 'График заказов')
+            ->defaults('active', 'schedule_orders')
+            ->name('orders');
+        Route::get('deliveries', UnderDevelopmentController::class)
+            ->defaults('title', 'График доставок')
+            ->defaults('active', 'schedule_deliveries')
+            ->name('deliveries');
+    });
+
+    Route::prefix('stock')->name('stock.')->group(function () {
+        Route::get('', UnderDevelopmentController::class)
+            ->defaults('title', 'Склад наличие')
+            ->defaults('active', 'stock')
+            ->name('index');
+        Route::get('orders', UnderDevelopmentController::class)
+            ->defaults('title', 'Заказы склада')
+            ->defaults('active', 'stock_orders')
+            ->name('orders');
+    });
+
+    Route::get('documents', UnderDevelopmentController::class)
+        ->defaults('title', 'Документация')
+        ->defaults('active', 'documents')
+        ->name('documents.index');
+
+    Route::get('calculations', UnderDevelopmentController::class)
+        ->defaults('title', 'Калькуляции')
+        ->defaults('active', 'calculations')
+        ->name('calculations.index');
+
     Route::group([], function () {
         Route::prefix('responsibles')->group(function (){
             Route::get('', [ResponsibleController::class, 'index'])->name('responsible.index');