From 9279f2b3ee197e1f20d449bc5ccfaff3fa4ca81e Mon Sep 17 00:00:00 2001 From: Robbert <104075630+RobbertRitsema@users.noreply.github.com> Date: Fri, 13 Jan 2023 14:47:10 +0100 Subject: [PATCH] feat: add custom icon for table (#2) * add custom icon for table * linting --- src/NotFound/Layout/Elements/LayoutBar.php | 1 + src/NotFound/Layout/Elements/LayoutButton.php | 2 +- src/NotFound/Layout/Elements/Table/LayoutTable.php | 8 ++++++++ src/NotFound/Layout/Helpers/LayoutInputDropdownHelper.php | 2 +- src/NotFound/Layout/Inputs/AbstractInput.php | 4 ++-- src/NotFound/Layout/Inputs/LayoutInputCheckbox.php | 2 +- src/NotFound/Layout/Inputs/LayoutInputDropdown.php | 2 +- src/NotFound/Layout/Inputs/LayoutInputFile.php | 2 +- src/NotFound/Layout/Inputs/LayoutInputImage.php | 2 +- src/NotFound/Layout/Inputs/LayoutInputTags.php | 4 ++-- src/NotFound/Layout/LayoutResponse.php | 2 +- src/NotFound/Layout/Validations/IsText.php | 2 +- 12 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/NotFound/Layout/Elements/LayoutBar.php b/src/NotFound/Layout/Elements/LayoutBar.php index 712c145..dfbd52d 100644 --- a/src/NotFound/Layout/Elements/LayoutBar.php +++ b/src/NotFound/Layout/Elements/LayoutBar.php @@ -12,6 +12,7 @@ public function __construct() public function removePadding(): self { $this->properties->removePadding = true; + return $this; } diff --git a/src/NotFound/Layout/Elements/LayoutButton.php b/src/NotFound/Layout/Elements/LayoutButton.php index 66b15d4..237d5f5 100644 --- a/src/NotFound/Layout/Elements/LayoutButton.php +++ b/src/NotFound/Layout/Elements/LayoutButton.php @@ -20,7 +20,7 @@ public function setSticky(): self public function addAlternative(string $internal, string $display_name): self { - if (!isset($this->properties->alternatives)) { + if (! isset($this->properties->alternatives)) { $this->properties->alternatives = []; } $this->properties->alternatives[$internal] = $display_name; diff --git a/src/NotFound/Layout/Elements/Table/LayoutTable.php b/src/NotFound/Layout/Elements/Table/LayoutTable.php index ef17e41..72aa8ec 100644 --- a/src/NotFound/Layout/Elements/Table/LayoutTable.php +++ b/src/NotFound/Layout/Elements/Table/LayoutTable.php @@ -30,6 +30,7 @@ public function __construct(bool $sort = true, bool $delete = true, bool $edit = $this->properties->sort = $sort; $this->properties->delete = $delete; $this->properties->edit = $edit; + $this->properties->editIcon = 'edit'; $this->properties->create = $create; } @@ -55,6 +56,13 @@ public function setTotalItems(int $number) return $this; } + public function setCustomEditIcon(string $iconName) + { + $this->properties->editIcon = $iconName; + + return $this; + } + public function build(): object { return (object) ['type' => $this->type, 'properties' => $this->properties]; diff --git a/src/NotFound/Layout/Helpers/LayoutInputDropdownHelper.php b/src/NotFound/Layout/Helpers/LayoutInputDropdownHelper.php index f66e2b0..6b57945 100644 --- a/src/NotFound/Layout/Helpers/LayoutInputDropdownHelper.php +++ b/src/NotFound/Layout/Helpers/LayoutInputDropdownHelper.php @@ -29,7 +29,7 @@ public function __construct( protected bool $required = false, ) { if ($internal === null) { - $internal = $model->getTable() . '_id'; + $internal = $model->getTable().'_id'; } $this->dropdown = new LayoutInputDropdown($internal, $label); diff --git a/src/NotFound/Layout/Inputs/AbstractInput.php b/src/NotFound/Layout/Inputs/AbstractInput.php index c48ea72..efd3649 100644 --- a/src/NotFound/Layout/Inputs/AbstractInput.php +++ b/src/NotFound/Layout/Inputs/AbstractInput.php @@ -2,8 +2,8 @@ namespace NotFound\Layout\Inputs; -use NotFound\Layout\Elements\AbstractLayout; use Illuminate\Support\Facades\Log; +use NotFound\Layout\Elements\AbstractLayout; abstract class AbstractInput extends AbstractLayout { @@ -44,7 +44,7 @@ public function setPlaceholder(string $placeholder): self public function setValue(mixed $value): self { - if (!is_string($value)) { + if (! is_string($value)) { $this->abortLogSetValueError('AbstractInput', 'string', $value); } $this->value = $value; diff --git a/src/NotFound/Layout/Inputs/LayoutInputCheckbox.php b/src/NotFound/Layout/Inputs/LayoutInputCheckbox.php index a5a85e9..cc9744a 100644 --- a/src/NotFound/Layout/Inputs/LayoutInputCheckbox.php +++ b/src/NotFound/Layout/Inputs/LayoutInputCheckbox.php @@ -10,7 +10,7 @@ class LayoutInputCheckbox extends AbstractInput public function setValue($value): self { - if (!is_bool($value)) { + if (! is_bool($value)) { $this->abortLogSetValueError('InputCheckbox', 'boolean', $value); } $this->value = $value; diff --git a/src/NotFound/Layout/Inputs/LayoutInputDropdown.php b/src/NotFound/Layout/Inputs/LayoutInputDropdown.php index 36f61b1..b087b0a 100644 --- a/src/NotFound/Layout/Inputs/LayoutInputDropdown.php +++ b/src/NotFound/Layout/Inputs/LayoutInputDropdown.php @@ -24,7 +24,7 @@ public function setSearchable(): self public function addItem($value, $readableValue = null): self { - trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED); + trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED); return $this->addOption($value, $readableValue); } diff --git a/src/NotFound/Layout/Inputs/LayoutInputFile.php b/src/NotFound/Layout/Inputs/LayoutInputFile.php index 444dac2..00b65b6 100644 --- a/src/NotFound/Layout/Inputs/LayoutInputFile.php +++ b/src/NotFound/Layout/Inputs/LayoutInputFile.php @@ -10,7 +10,7 @@ class LayoutInputFile extends AbstractInput public function setValue($value): self { - if (!is_object($value)) { + if (! is_object($value)) { $this->abortLogSetValueError('LayoutInputImage', 'object', $value); } $this->value = $value; diff --git a/src/NotFound/Layout/Inputs/LayoutInputImage.php b/src/NotFound/Layout/Inputs/LayoutInputImage.php index 2eb8f4f..6ac8375 100644 --- a/src/NotFound/Layout/Inputs/LayoutInputImage.php +++ b/src/NotFound/Layout/Inputs/LayoutInputImage.php @@ -10,7 +10,7 @@ class LayoutInputImage extends AbstractInput public function setValue($value): self { - if (!is_object($value)) { + if (! is_object($value)) { $this->abortLogSetValueError('LayoutInputImage', 'object', $value); } $this->value = $value; diff --git a/src/NotFound/Layout/Inputs/LayoutInputTags.php b/src/NotFound/Layout/Inputs/LayoutInputTags.php index 0727c49..088570a 100644 --- a/src/NotFound/Layout/Inputs/LayoutInputTags.php +++ b/src/NotFound/Layout/Inputs/LayoutInputTags.php @@ -19,7 +19,7 @@ class LayoutInputTags extends AbstractInput */ public function setValue(mixed $value): self { - if (!is_array($value)) { + if (! is_array($value)) { $this->abortLogSetValueError('InputTags', 'array', $value); } $this->value = $value; @@ -50,7 +50,7 @@ public function addOption($value, $readableValue = null): self public function addItem($value, $readableValue = null): self { - trigger_error('Method ' . __METHOD__ . ' is deprecated', E_USER_DEPRECATED); + trigger_error('Method '.__METHOD__.' is deprecated', E_USER_DEPRECATED); return $this->addOption($value, $readableValue); } diff --git a/src/NotFound/Layout/LayoutResponse.php b/src/NotFound/Layout/LayoutResponse.php index 0559be6..0131a5c 100644 --- a/src/NotFound/Layout/LayoutResponse.php +++ b/src/NotFound/Layout/LayoutResponse.php @@ -2,9 +2,9 @@ namespace NotFound\Layout; +use Illuminate\Support\Collection; use NotFound\Layout\Elements\AbstractLayout; use NotFound\Layout\Responses\Action; -use Illuminate\Support\Collection; class LayoutResponse { diff --git a/src/NotFound/Layout/Validations/IsText.php b/src/NotFound/Layout/Validations/IsText.php index 005729f..dd33d69 100644 --- a/src/NotFound/Layout/Validations/IsText.php +++ b/src/NotFound/Layout/Validations/IsText.php @@ -14,7 +14,7 @@ class IsText extends AbstractValidation { public function validate($newValue) { - if ($newValue != null && !is_string($newValue)) { + if ($newValue != null && ! is_string($newValue)) { abort(200, __('validation.string', ['attribute' => $this->input->internal])); }