From 0863da593b4e5b6870bb2b834b0ccdc79eba0ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 23 May 2023 14:32:51 +0300 Subject: [PATCH] Added search and string value fields options.. ( #861mmjq77 ) --- app/View/Components/SearchString.php | 1 + config/search-string.php | 6 ++++- .../assets/js/components/AkauntingSearch.vue | 24 +++++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/View/Components/SearchString.php b/app/View/Components/SearchString.php index 667ff782d8d..50cca31d3f6 100644 --- a/app/View/Components/SearchString.php +++ b/app/View/Components/SearchString.php @@ -75,6 +75,7 @@ public function render() 'type' => $this->getFilterType($options), 'url' => $this->getFilterUrl($column, $options), 'values' => $this->getFilterValues($column, $options), + 'value_option_fields' => $options['fields'] ?? [], ]; } } diff --git a/config/search-string.php b/config/search-string.php index 8e92330ee41..97f5f5f7f56 100644 --- a/config/search-string.php +++ b/config/search-string.php @@ -372,7 +372,11 @@ 'contact_phone' => ['searchable' => true], 'contact_address' => ['searchable' => true], 'category_id' => [ - 'route' => ['categories.index', 'search=type:income enabled:1'] + 'route' => ['categories.index', 'search=type:income enabled:1'], + 'fields' => [ + 'key' => 'id', + 'value' => 'name', + ], ], 'parent_id', 'recurring' => [ diff --git a/resources/assets/js/components/AkauntingSearch.vue b/resources/assets/js/components/AkauntingSearch.vue index de05ae75c5f..90831159591 100644 --- a/resources/assets/js/components/AkauntingSearch.vue +++ b/resources/assets/js/components/AkauntingSearch.vue @@ -433,10 +433,12 @@ export default { let option = false; let option_url = false; + let option_fields = {}; for (let i = 0; i < this.filter_list.length; i++) { if (this.filter_list[i].key == value) { option = this.filter_list[i].value; + option_fields = (this.filter_list[i]['value_option_fields']) ? this.filter_list[i].value_option_fields : {}; if (this.filter_list[i].values !== 'undefined' && Object.keys(this.filter_list[i].values).length) { this.option_values[value] = this.convertOption(this.filter_list[i].values); @@ -485,7 +487,7 @@ export default { } } - if (!this.option_values[value] && option_url) { + if (! this.option_values[value] && option_url) { if (option_url.indexOf('limit') === -1) { option_url += ' limit:10'; } @@ -497,11 +499,19 @@ export default { this.values = []; data.forEach(function (item) { - this.values.push({ - key: (item.code) ? item.code : item.id, - value: (item.title) ? item.title : (item.display_name) ? item.display_name : item.name, - level: (item.level) ? item.level : null, - }); + if (Object.keys(option_fields).length) { + this.values.push({ + key: (option_fields['key']) ? item[option_fields['key']] : (item.code) ? item.code : item.id, + value: (option_fields['value']) ? item[option_fields['value']] : (item.title) ? item.title : (item.display_name) ? item.display_name : item.name, + level: (option_fields['level']) ? item[option_fields['level']] : (item.level) ? item.level : null, + }); + } else { + this.values.push({ + key: (item.code) ? item.code : item.id, + value: (item.title) ? item.title : (item.display_name) ? item.display_name : item.name, + level: (item.level) ? item.level : null, + }); + } }, this); this.option_values[value] = this.values; @@ -657,7 +667,7 @@ export default { let values = []; // Option set sort_option data - if (!Array.isArray(options)) { + if (! Array.isArray(options)) { for (const [key, value] of Object.entries(options)) { values.push({ key: (key).toString(),