Skip to content

Commit

Permalink
Added search and string value fields options.. ( #861mmjq77 )
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed May 23, 2023
1 parent b291d05 commit 0863da5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/View/Components/SearchString.php
Expand Up @@ -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'] ?? [],
];
}
}
Expand Down
6 changes: 5 additions & 1 deletion config/search-string.php
Expand Up @@ -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' => [
Expand Down
24 changes: 17 additions & 7 deletions resources/assets/js/components/AkauntingSearch.vue
Expand Up @@ -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);
Expand Down Expand Up @@ -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';
}
Expand All @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 0863da5

Please sign in to comment.