Search and filter set default filter..
This commit is contained in:
parent
2794ddc257
commit
b29ea1bba5
@ -12,6 +12,8 @@ class SearchString extends Component
|
||||
|
||||
public $filters;
|
||||
|
||||
public $filtered;
|
||||
|
||||
/** string */
|
||||
public $model;
|
||||
|
||||
@ -20,10 +22,11 @@ class SearchString extends Component
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $model = '', $filters = false)
|
||||
public function __construct(string $model = '', $filters = false, $filtered = false)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->filters = $filters;
|
||||
$this->filtered = $filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,6 +142,11 @@ export default {
|
||||
default: () => [],
|
||||
description: 'List of filters'
|
||||
},
|
||||
defaultFiltered: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
description: 'List of filters'
|
||||
},
|
||||
|
||||
dateConfig: null,
|
||||
},
|
||||
@ -195,7 +200,7 @@ export default {
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Focus :' + this.filter_last_step);
|
||||
//console.log('Focus :' + this.filter_last_step);
|
||||
},
|
||||
|
||||
onInputDateSelected(selectedDates, dateStr, instance) {
|
||||
@ -656,6 +661,57 @@ export default {
|
||||
this.filter_index++;
|
||||
}
|
||||
}, this);
|
||||
}else if (this.defaultFiltered) {
|
||||
this.defaultFiltered.forEach(function (filter) {
|
||||
let option = '';
|
||||
let operator = '=';
|
||||
let value = '';
|
||||
|
||||
this.filter_list.forEach(function (_filter, i) {
|
||||
let filter_values = this.convertOption(_filter.values);
|
||||
|
||||
if (_filter.key == filter.option) {
|
||||
console.log('Filter YES');
|
||||
|
||||
option = _filter.value;
|
||||
operator = filter.operator;
|
||||
|
||||
filter_values.forEach(function (_value) {
|
||||
if (_value.key == filter.value) {
|
||||
value = _value.value;
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.selected_options.push(this.filter_list[i]);
|
||||
|
||||
console.log(operator);
|
||||
|
||||
this.selected_operator.push({
|
||||
key: operator,
|
||||
});
|
||||
|
||||
this.filter_list.splice(i, 1);
|
||||
|
||||
this.option_values[_filter.key] = filter_values;
|
||||
|
||||
filter_values.forEach(function (value, j) {
|
||||
if (value.key == filter.value) {
|
||||
this.selected_values.push(value);
|
||||
|
||||
this.option_values[_filter.key].splice(j, 1);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.filtered.push({
|
||||
option: option,
|
||||
operator: operator,
|
||||
value: value
|
||||
});
|
||||
|
||||
this.filter_index++;
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
no-matching-data-text="{{ trans('general.no_matching_data') }}"
|
||||
value="{{ request()->get('search', null) }}"
|
||||
:filters="{{ json_encode($filters) }}"
|
||||
:default-filtered="{{ json_encode($filtered) }}"
|
||||
:date-config="{
|
||||
allowInput: true,
|
||||
altInput: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user