From c54bf229427eeb066705b0c68c18ab5547809d2a Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Tue, 3 Sep 2024 17:36:10 +0300 Subject: [PATCH] fix menu crud --- composer.lock | 8 ++++---- kernel/models/Menu.php | 2 +- kernel/modules/menu/models/Menu.php | 2 +- kernel/modules/menu/views/form.php | 4 ++-- kernel/modules/menu/views/index.php | 2 +- kernel/modules/menu/views/view.php | 6 +----- views/admin/menu/form.php | 2 +- 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index 5500333..8d3f30e 100644 --- a/composer.lock +++ b/composer.lock @@ -827,11 +827,11 @@ }, { "name": "itguild/forms", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://git.itguild.info/ItGuild/forms_bundle.git", - "reference": "0501718421203f721cfa750d3d703ed613cd72b7" + "reference": "62e1e8f3382391fd00adb5b4421015c2faa6e19b" }, "require": { "itguild/php-cg-select-v2": "^0.1.0", @@ -855,7 +855,7 @@ "email": "apuc06@mail.ru" } ], - "time": "2024-07-26T13:21:26+00:00" + "time": "2024-09-03T09:45:20+00:00" }, { "name": "itguild/php-cg-select-v2", @@ -2495,5 +2495,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/kernel/models/Menu.php b/kernel/models/Menu.php index 6d8a3b7..a1a92cc 100644 --- a/kernel/models/Menu.php +++ b/kernel/models/Menu.php @@ -28,10 +28,10 @@ class Menu extends Model public static function labels(): array { return [ + 'label' => 'Заголовок', 'parent_id' => 'Родительский пункт меню', 'icon_file' => 'Путь к иконке', 'icon_font' => 'Иконка', - 'label' => 'Заголовок', 'url' => 'URL', 'status' => 'Статус', ]; diff --git a/kernel/modules/menu/models/Menu.php b/kernel/modules/menu/models/Menu.php index 0878900..6c31382 100644 --- a/kernel/modules/menu/models/Menu.php +++ b/kernel/modules/menu/models/Menu.php @@ -28,10 +28,10 @@ class Menu extends Model public static function labels(): array { return [ + 'label' => 'Заголовок', 'parent_id' => 'Родительский пункт меню', 'icon_file' => 'Путь к иконке', 'icon_font' => 'Иконка', - 'label' => 'Заголовок', 'url' => 'URL', 'status' => 'Статус', ]; diff --git a/kernel/modules/menu/views/form.php b/kernel/modules/menu/views/form.php index c5a878d..bd4bc63 100644 --- a/kernel/modules/menu/views/form.php +++ b/kernel/modules/menu/views/form.php @@ -6,7 +6,7 @@ use kernel\models\Menu; $form = new \itguild\forms\ActiveForm(); -$form->beginForm(isset($model) ? "/admin/settings/menu/edit/" . $model->id : "/admin/menu"); +$form->beginForm(isset($model) ? "/admin/settings/menu/edit/" . $model->id : "/admin/settings/menu"); $form->field(class: \itguild\forms\inputs\Select::class, name: "parent_id", params: [ 'class' => "form-control", @@ -16,7 +16,7 @@ $form->field(class: \itguild\forms\inputs\Select::class, name: "parent_id", para ->setOptions(\app\services\MenuService::createLabelArr()) ->render(); -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "icon_file", params: [ +$form->field(class: \itguild\forms\inputs\File::class, name: "icon_file", params: [ 'class' => "form-control", 'value' => $model->icon_file ?? '' ]) diff --git a/kernel/modules/menu/views/index.php b/kernel/modules/menu/views/index.php index fe99715..e55b8fe 100644 --- a/kernel/modules/menu/views/index.php +++ b/kernel/modules/menu/views/index.php @@ -39,7 +39,7 @@ $table->columns([ } ]); $table->beforePrint(function () { - return PrimaryBtn::create("Создать", "/admin/menu/create")->fetch(); + return PrimaryBtn::create("Создать", "/admin/settings/menu/create")->fetch(); //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); }); $table->addAction(MenuViewActionColumn::class); diff --git a/kernel/modules/menu/views/view.php b/kernel/modules/menu/views/view.php index 15f18d5..98c7ee4 100644 --- a/kernel/modules/menu/views/view.php +++ b/kernel/modules/menu/views/view.php @@ -16,11 +16,7 @@ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [ 'params' => ["class" => "table table-bordered", "border" => "2"], 'baseUrl' => "/admin/menu", ])); -$r = new ViewJsonTableEloquentModel($menu, [ - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/menu", -]); -\app\helpers\Debug::dd($r->getJson()); + $table->beforePrint(function () use ($menu) { $btn = PrimaryBtn::create("Список", "/admin/settings/menu")->fetch(); $btn .= SuccessBtn::create("Редактировать", "/admin/settings/menu/update/" . $menu->id)->fetch(); diff --git a/views/admin/menu/form.php b/views/admin/menu/form.php index 9009f1b..30a9c9c 100644 --- a/views/admin/menu/form.php +++ b/views/admin/menu/form.php @@ -16,7 +16,7 @@ $form->field(class: \itguild\forms\inputs\Select::class, name: "parent_id", para ->setOptions(\app\services\MenuService::createLabelArr()) ->render(); -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "icon_file", params: [ +$form->field(class: \itguild\forms\inputs\File::class, name: "icon_file", params: [ 'class' => "form-control", 'value' => $model->icon_file ?? '' ])