Skip to content

Commit

Permalink
Integrate back-end for default value
Browse files Browse the repository at this point in the history
  • Loading branch information
benguozakinci@gmail.com authored and benguozakinci@gmail.com committed Jul 27, 2021
1 parent a28dd08 commit 1df7c8e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 3 deletions.
27 changes: 26 additions & 1 deletion app/Abstracts/View/Components/DocumentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ abstract class DocumentForm extends Base

/** @var bool */
public $isPurchasePrice;

/** @var int */
public $searchCharLimit;
/** Items Component End */

/**
Expand Down Expand Up @@ -240,7 +243,7 @@ public function __construct(
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;
Expand Down Expand Up @@ -325,6 +328,7 @@ public function __construct(
$this->hideEditItemColumns = $hideEditItemColumns;
$this->isSalePrice = $isSalePrice;
$this->isPurchasePrice = $isPurchasePrice;
$this->searchCharLimit = $this->getSearchCharLimit($type, $searchCharLimit);
/** Items Component End */
}

Expand Down Expand Up @@ -1020,4 +1024,25 @@ protected function getNotesSettingValue($notesSetting)

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);
}
}
6 changes: 5 additions & 1 deletion app/View/Components/SelectItemButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
'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-'),
Expand All @@ -133,6 +134,7 @@
'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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
text-amount="{{ $textAmount }}"
is-sale-price="{{ $isSalePrice }}"
is-purchase-price="{{ $isPurchasePrice }}"
search-char-limit="{{ $searchCharLimit }}"
notes-setting="{{ $notesSetting }}"
/>

Expand Down
1 change: 1 addition & 0 deletions resources/views/components/documents/form/items.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
type="{{ $type }}"
is-sale="{{ $isSalePrice }}"
is-purchase="{{ $isPurchasePrice }}"
search-char-limit="{{ $searchCharLimit }}"
/>
</td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions resources/views/components/documents/form/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
text-amount="{{ $textAmount }}"
is-sale-price="{{ $isSalePrice }}"
is-purchase-price="{{ $isPurchasePrice }}"
search-char-limit="{{ $searchCharLimit }}"
/>

<x-documents.form.totals
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/select-item-button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
price="{{ $price }}"
:dynamic-currency="currency"
:items="{{ json_encode($items) }}"
:search-char-limit="3"
:search-char-limit="{{ $searchCharLimit }}"
@item="onSelectedItem($event)"
add-item-text="{{ trans('general.form.add_an', ['field' => trans_choice('general.items', 1)]) }}"
create-new-item-text="{{ trans('general.title.create', ['type' => trans_choice('general.items', 1)]) }}"
Expand Down

0 comments on commit 1df7c8e

Please sign in to comment.