2018-12-07 19:33:32 +01:00
|
|
|
<?php
|
|
|
|
$selectedSort = (isset($sort) && array_key_exists($sort, $options)) ? $sort : array_keys($options)[0];
|
|
|
|
$order = (isset($order) && in_array($order, ['asc', 'desc'])) ? $order : 'asc';
|
|
|
|
?>
|
2022-10-30 21:24:08 +01:00
|
|
|
<div component="list-sort-control" class="list-sort-container">
|
2018-12-07 19:33:32 +01:00
|
|
|
<div class="list-sort-label">{{ trans('common.sort') }}</div>
|
2022-10-30 21:24:08 +01:00
|
|
|
<form refs="list-sort-control@form"
|
|
|
|
@if($useQuery ?? false)
|
|
|
|
action="{{ url()->current() }}"
|
|
|
|
method="get"
|
|
|
|
@else
|
2022-11-09 20:30:08 +01:00
|
|
|
action="{{ url("/preferences/change-sort/{$type}") }}"
|
2022-10-30 21:24:08 +01:00
|
|
|
method="post"
|
|
|
|
@endif
|
|
|
|
>
|
2023-12-10 13:37:21 +01:00
|
|
|
<input type="hidden" name="_return" value="{{ url()->current() }}">
|
2018-12-07 19:33:32 +01:00
|
|
|
|
2022-10-30 21:24:08 +01:00
|
|
|
@if($useQuery ?? false)
|
|
|
|
@foreach(array_filter(request()->except(['sort', 'order'])) as $key => $value)
|
|
|
|
<input type="hidden" name="{{ $key }}" value="{{ $value }}">
|
|
|
|
@endforeach
|
|
|
|
@else
|
|
|
|
{!! method_field('PATCH') !!}
|
|
|
|
{!! csrf_field() !!}
|
|
|
|
@endif
|
|
|
|
|
|
|
|
<input refs="list-sort-control@sort" type="hidden" value="{{ $selectedSort }}" name="sort">
|
|
|
|
<input refs="list-sort-control@order" type="hidden" value="{{ $order }}" name="order">
|
2018-12-07 19:33:32 +01:00
|
|
|
|
|
|
|
<div class="list-sort">
|
2020-06-24 21:38:08 +02:00
|
|
|
<div component="dropdown" class="list-sort-type dropdown-container">
|
|
|
|
<div refs="dropdown@toggle" aria-haspopup="true" aria-expanded="false" aria-label="{{ trans('common.sort_options') }}" tabindex="0">{{ $options[$selectedSort] }}</div>
|
2022-10-30 21:24:08 +01:00
|
|
|
<ul refs="dropdown@menu list-sort-control@menu" class="dropdown-menu">
|
2018-12-07 19:33:32 +01:00
|
|
|
@foreach($options as $key => $label)
|
2022-04-20 15:03:47 +02:00
|
|
|
<li @if($key === $selectedSort) class="active" @endif><a href="#" data-sort-value="{{$key}}" class="text-item">{{ $label }}</a></li>
|
2018-12-07 19:33:32 +01:00
|
|
|
@endforeach
|
|
|
|
</ul>
|
|
|
|
</div>
|
2022-10-30 21:24:08 +01:00
|
|
|
<button class="list-sort-dir" type="button" data-sort-dir
|
2019-08-24 19:26:28 +02:00
|
|
|
aria-label="{{ trans('common.sort_direction_toggle') }} - {{ $order === 'asc' ? trans('common.sort_ascending') : trans('common.sort_descending') }}" tabindex="0">
|
2019-05-05 15:43:26 +02:00
|
|
|
@icon($order === 'desc' ? 'sort-up' : 'sort-down')
|
2019-08-24 19:26:28 +02:00
|
|
|
</button>
|
2018-12-07 19:33:32 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|