| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <div class="dropdown-menu" style="width: 170px;" aria-labelledby="{{$id}}">
- <div class="px-1">
- <form class="dropdown-filter_{{$id}}">
- @if($type === 'filters')
- @include('partials.select', [
- 'name' => 'filters[' . $id . ']',
- 'title' => false,
- 'options' => $data['values'] ?? [],
- 'value' => request()->filters[$id] ?? '',
- 'right' => true,
- ])
- @elseif($type === 'ranges')
- @include('partials.input', [
- 'name' => 'filters[' . $id . '_from]',
- 'type' => 'range',
- 'title' => 'с:',
- 'min' => $data['min'],
- 'max' => $data['max'],
- 'value' => request()->filters[$id . '_from'] ?? '', // $range['min']
- ])
- @include('partials.input', [
- 'name' => 'filters[' . $id . '_to]',
- 'type' => 'range',
- 'title' => 'по:',
- 'min' => $data['min'],
- 'max' => $data['max'],
- 'value' => request()->filters[$id . '_to'] ?? '', // $range['max']
- ])
- @elseif($type === 'dates')
- @include('partials.input', [
- 'name' => 'filters[' . $id . '_from]',
- 'type' => 'date',
- 'title' => 'с:',
- 'min' => $data['min'],
- 'max' => $data['max'],
- 'right' => true,
- 'value' => request()->filters[$id . '_from'] ?? '',
- ])
- @include('partials.input', [
- 'name' => 'filters[' . $id . '_to]',
- 'type' => 'date',
- 'title' => 'по:',
- 'min' => $data['min'],
- 'max' => $data['max'],
- 'right' => true,
- 'value' => request()->filters[$id . '_to'] ?? '',
- ])
- @endif
- </form>
- <div class="modal-footer d-flex justify-content-between">
- <button type="button" class="btn btn-primary accept-filter_{{$id}} btn-sm">Применить</button>
- <button type="button" class="btn btn-outline-secondary reset-filters_{{$id}} btn-sm">Сбросить</button>
- </div>
- </div>
- </div>
- @push('scripts')
- <script type="module">
- $('.accept-filter_{{$id}}').on('click', function () {
- let filters = $('.dropdown-filter_{{$id}}').serializeArray();
- let currentUrl = new URL(document.location.href);
- $.each(filters, function (id, filter) {
- if (filter.value !== '') {
- currentUrl.searchParams.set(filter.name, filter.value);
- } else {
- currentUrl.searchParams.delete(filter.name);
- }
- });
- currentUrl.searchParams.delete('page');
- document.location.href = currentUrl.href;
- });
- $('.reset-filters_{{$id}}').on('click', function () {
- let filters = $('.dropdown-filter_{{$id}}').serializeArray();
- let currentUrl = new URL(document.location.href);
- $.each(filters, function (id, filter) {
- currentUrl.searchParams.delete(filter.name);
- });
- currentUrl.searchParams.delete('page');
- document.location.href = currentUrl.href;
- });
- </script>
- @endpush
|