Skip to content

Commit

Permalink
fix: selected sort not updated first time selected
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmailAAmassi committed Jun 26, 2023
1 parent 43f4d0a commit 4d50a33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private function contacts(Request $request, bool $active)
->withHasArchived($nbArchived > 0)
->withArchivedContacts($nbArchived)
->withTags($tags)
->withSort($sort)
->withTagsCount($tagsCount)
->withUrl($url)
->withTagCount($count)
Expand Down
8 changes: 4 additions & 4 deletions app/Models/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@ public function scopeSortedBy(Builder $builder, string $criteria): Builder
{
switch ($criteria) {
case 'firstnameAZ':
return $builder->orderBy('first_name', 'asc');
return $builder->orderBy('first_name');
case 'firstnameZA':
return $builder->orderBy('first_name', 'desc');
return $builder->orderByDesc('first_name');
case 'lastnameAZ':
return $builder->orderBy('last_name', 'asc');
return $builder->orderBy('last_name');
case 'lastnameZA':
return $builder->orderBy('last_name', 'desc');
return $builder->orderByDesc('last_name');
case 'lastactivitydateNewtoOld':
return $this->sortedByLastActivity($builder, 'desc');
case 'lastactivitydateOldtoNew':
Expand Down
12 changes: 6 additions & 6 deletions resources/views/people/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,27 @@
<div class="options-dropdowns dropdown">
<a href="" class="dropdown-btn" data-toggle="dropdown" id="dropdownSort">{{ trans('people.people_list_sort') }}</a>
<div class="dropdown-menu" aria-labelledby="dropdownSort">
<a class="dropdown-item {{ (auth()->user()->contacts_sort_order == 'firstnameAZ')?'selected':'' }}" href="{{ route('people.index') }}?sort=firstnameAZ">
<a class="dropdown-item {{ ($sort == 'firstnameAZ')?'selected':'' }}" href="{{ route('people.index') }}?sort=firstnameAZ">
{{ trans('people.people_list_firstnameAZ') }}
</a>

<a class="dropdown-item {{ (auth()->user()->contacts_sort_order == 'firstnameZA')?'selected':'' }}" href="{{ route('people.index') }}?sort=firstnameZA">
<a class="dropdown-item {{ ($sort == 'firstnameZA')?'selected':'' }}" href="{{ route('people.index') }}?sort=firstnameZA">
{{ trans('people.people_list_firstnameZA') }}
</a>

<a class="dropdown-item {{ (auth()->user()->contacts_sort_order == 'lastnameAZ')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastnameAZ">
<a class="dropdown-item {{ ($sort == 'lastnameAZ')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastnameAZ">
{{ trans('people.people_list_lastnameAZ') }}
</a>

<a class="dropdown-item {{ (auth()->user()->contacts_sort_order == 'lastnameZA')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastnameZA">
<a class="dropdown-item {{ ($sort == 'lastnameZA')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastnameZA">
{{ trans('people.people_list_lastnameZA') }}
</a>

<a class="dropdown-item {{ (auth()->user()->contacts_sort_order == 'lastactivitydateNewtoOld')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastactivitydateNewtoOld">
<a class="dropdown-item {{ ($sort == 'lastactivitydateNewtoOld')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastactivitydateNewtoOld">
{{ trans('people.people_list_lastactivitydateNewtoOld') }}
</a>

<a class="dropdown-item {{ (auth()->user()->contacts_sort_order == 'lastactivitydateOldtoNew')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastactivitydateOldtoNew">
<a class="dropdown-item {{ ($sort == 'lastactivitydateOldtoNew')?'selected':'' }}" href="{{ route('people.index') }}?sort=lastactivitydateOldtoNew">
{{ trans('people.people_list_lastactivitydateOldtoNew') }}
</a>
</div>
Expand Down

0 comments on commit 4d50a33

Please sign in to comment.