From 1df7c8e87f8958f087ced2df4a6d15d5ac7799dd Mon Sep 17 00:00:00 2001 From: "benguozakinci@gmail.com" Date: Tue, 27 Jul 2021 17:56:35 +0300 Subject: [PATCH] Integrate back-end for default value --- .../View/Components/DocumentForm.php | 27 ++++++++++++++++++- app/View/Components/SelectItemButton.php | 6 ++++- config/setting.php | 2 ++ .../documents/form/content.blade.php | 1 + .../components/documents/form/items.blade.php | 1 + .../components/documents/form/main.blade.php | 1 + .../components/select-item-button.blade.php | 2 +- 7 files changed, 37 insertions(+), 3 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index fa1bfcd56..fb8337d6e 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -207,6 +207,9 @@ abstract class DocumentForm extends Base /** @var bool */ public $isPurchasePrice; + + /** @var int */ + public $searchCharLimit; /** Items Component End */ /** @@ -240,7 +243,7 @@ abstract class DocumentForm extends Base bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false, bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false, bool $hideEditItemColumns = false, - bool $isSalePrice = false, bool $isPurchasePrice = false + bool $isSalePrice = false, bool $isPurchasePrice = false, int $searchCharLimit = 0 /** Items Component End */ ) { $this->type = $type; @@ -325,6 +328,7 @@ abstract class DocumentForm extends Base $this->hideEditItemColumns = $hideEditItemColumns; $this->isSalePrice = $isSalePrice; $this->isPurchasePrice = $isPurchasePrice; + $this->searchCharLimit = $this->getSearchCharLimit($type, $searchCharLimit); /** Items Component End */ } @@ -1020,4 +1024,25 @@ abstract class DocumentForm extends Base return setting($this->getSettingKey($this->type, 'notes')); } + + protected function getSearchCharLimit($type, $searchCharLimit) + { + if (!empty($searchCharLimit)) { + return $searchCharLimit; + } + + // if you use settting translation + if ($settingCharLimit = setting($this->getSettingKey($type, 'item_search_chart_limit'), false)) { + return $settingCharLimit; + } + + $hide = $this->getHideFromConfig($type, 'item_search_char_limit'); + + if ($hide) { + return $hide; + } + + // @todo what return value invoice or always false?? + return setting('invoice.item_search_char_limit', $searchCharLimit); + } } diff --git a/app/View/Components/SelectItemButton.php b/app/View/Components/SelectItemButton.php index ae1008d96..720f54412 100644 --- a/app/View/Components/SelectItemButton.php +++ b/app/View/Components/SelectItemButton.php @@ -16,16 +16,20 @@ class SelectItemButton extends Component /** @var bool */ public $isPurchase; + /** @var int */ + public $searchCharLimit; + /** * Create a new component instance. * * @return void */ - public function __construct(string $type = 'sale', bool $isSale = false, bool $isPurchase = false) + public function __construct(string $type = 'sale', bool $isSale = false, bool $isPurchase = false, int $searchCharLimit = 3) { $this->type = $type; $this->isSale = $isSale; $this->isPurchase = $isPurchase; + $this->searchCharLimit = $searchCharLimit; } /** diff --git a/config/setting.php b/config/setting.php index 114be521d..937957947 100644 --- a/config/setting.php +++ b/config/setting.php @@ -122,6 +122,7 @@ return [ 'color' => env('SETTING_FALLBACK_INVOICE_COLOR', '#55588b'), 'logo_size_width' => env('SETTING_FALLBACK_INVOICE_LOGO_SIZE_WIDTH', 128), 'logo_size_height' => env('SETTING_FALLBACK_INVOICE_LOGO_SIZE_HEIGHT', 128), + 'item_search_char_limit' => env('SETTING_FALLBACK_INVOICE_ITEM_SEARCH_CHAR_LIMIT', 3), ], 'bill' => [ 'number_prefix' => env('SETTING_FALLBACK_BILL_NUMBER_PREFIX', 'BILL-'), @@ -133,6 +134,7 @@ return [ 'payment_terms' => env('SETTING_FALLBACK_BILL_PAYMENT_TERMS', '0'), 'template' => env('SETTING_FALLBACK_BILL_TEMPLATE', 'default'), 'color' => env('SETTING_FALLBACK_BILL_COLOR', '#55588b'), + 'item_search_char_limit' => env('SETTING_FALLBACK_BILL_ITEM_SEARCH_CHAR_LIMIT', 3), ], 'default' => [ 'currency' => env('SETTING_FALLBACK_DEFAULT_CURRENCY', 'USD'), diff --git a/resources/views/components/documents/form/content.blade.php b/resources/views/components/documents/form/content.blade.php index 1def1e9ec..207e8c2b0 100644 --- a/resources/views/components/documents/form/content.blade.php +++ b/resources/views/components/documents/form/content.blade.php @@ -68,6 +68,7 @@ text-amount="{{ $textAmount }}" is-sale-price="{{ $isSalePrice }}" is-purchase-price="{{ $isPurchasePrice }}" + search-char-limit="{{ $searchCharLimit }}" notes-setting="{{ $notesSetting }}" /> diff --git a/resources/views/components/documents/form/items.blade.php b/resources/views/components/documents/form/items.blade.php index 486b2db8f..955d3a81d 100644 --- a/resources/views/components/documents/form/items.blade.php +++ b/resources/views/components/documents/form/items.blade.php @@ -77,6 +77,7 @@ type="{{ $type }}" is-sale="{{ $isSalePrice }}" is-purchase="{{ $isPurchasePrice }}" + search-char-limit="{{ $searchCharLimit }}" /> diff --git a/resources/views/components/documents/form/main.blade.php b/resources/views/components/documents/form/main.blade.php index 684722cc9..919ff877e 100644 --- a/resources/views/components/documents/form/main.blade.php +++ b/resources/views/components/documents/form/main.blade.php @@ -44,6 +44,7 @@ text-amount="{{ $textAmount }}" is-sale-price="{{ $isSalePrice }}" is-purchase-price="{{ $isPurchasePrice }}" + search-char-limit="{{ $searchCharLimit }}" />