From 136a60fb0bbd8f082b234369a0883e4119192900 Mon Sep 17 00:00:00 2001 From: Vlad Chiovianu Date: Thu, 31 Mar 2022 19:41:29 +0300 Subject: [PATCH] implements hidden actions --- src/Attributes/Structure.php | 6 +++--- src/Services/Builder.php | 2 ++ src/Services/Form.php | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Attributes/Structure.php b/src/Attributes/Structure.php index f872227..722d38c 100644 --- a/src/Attributes/Structure.php +++ b/src/Attributes/Structure.php @@ -7,9 +7,9 @@ class Structure public const Mandatory = ['method', 'sections', 'routeParams']; public const Optional = [ - 'actions', 'authorize', 'autosave', 'clearErrorsControl', 'debounce', - 'dividerTitlePlacement', 'icon', 'labels', 'params', 'routePrefix', - 'routes', 'tabs', 'title', + 'actions', 'authorize', 'autosave', 'clearErrorsControl', 'debounce', + 'dividerTitlePlacement', 'hiddenActions', 'icon', 'labels', 'params', + 'routePrefix', 'routes', 'tabs', 'title', ]; public const SectionMandatory = ['columns', 'fields']; diff --git a/src/Services/Builder.php b/src/Services/Builder.php index 4eb66ab..a052747 100644 --- a/src/Services/Builder.php +++ b/src/Services/Builder.php @@ -187,6 +187,8 @@ private function actionConfig($action): array return [ 'button' => config('enso.forms.buttons.'.$action), 'forbidden' => $this->isForbidden($route), + 'hidden' => $this->template->has('hiddenActions') && + $this->template->get('hiddenActions')->contains($action), $routeOrPath => $value, ]; } diff --git a/src/Services/Form.php b/src/Services/Form.php index d58d3a8..a4d7e00 100644 --- a/src/Services/Form.php +++ b/src/Services/Form.php @@ -146,6 +146,13 @@ public function showSection($fields): self return $this; } + public function hiddenActions(string|array $actions): self + { + $this->template->set('hiddenActions', new Obj($actions)); + + return $this; + } + public function hideTab($tabs): self { $this->tabVisibility($tabs, $hidden = true);