Skip to content

Commit

Permalink
fix(characters): use ID instead of number sorting for MYO masterlist,…
Browse files Browse the repository at this point in the history
… clean up (corowne#825)

* fix(masterlist) - Removed redundant number sorting from MYO masterlist and other tiny fixes for consistency

* refactor: fix blade formatting

---------

Co-authored-by: SpeedyD <[email protected]>
  • Loading branch information
SpeedyD and SpeedyD authored Feb 7, 2024
1 parent e37a6ac commit cb7afdc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
13 changes: 9 additions & 4 deletions app/Http/Controllers/BrowseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ public function getCharacters(Request $request) {
}

switch ($request->get('sort')) {
default:
$query->orderBy('characters.number', 'DESC');
break;
case 'number_desc':
$query->orderBy('characters.number', 'DESC');
break;
Expand All @@ -300,8 +303,6 @@ public function getCharacters(Request $request) {
case 'sale_value_asc':
$query->orderBy('characters.sale_value', 'ASC');
break;
default:
$query->orderBy('characters.number', 'DESC');
}

if (!Auth::check() || !Auth::user()->hasPower('manage_characters')) {
Expand Down Expand Up @@ -418,6 +419,9 @@ public function getMyos(Request $request) {
$query->whereIn('id', $imageQuery->pluck('character_id')->toArray());

switch ($request->get('sort')) {
default:
$query->orderBy('characters.id', 'DESC');
break;
case 'id_desc':
$query->orderBy('characters.id', 'DESC');
break;
Expand Down Expand Up @@ -591,6 +595,9 @@ public function getSublist(Request $request, $key) {
$query->whereIn('id', $imageQuery->pluck('character_id')->toArray());

switch ($request->get('sort')) {
default:
$query->orderBy('characters.number', 'DESC');
break;
case 'number_desc':
$query->orderBy('characters.number', 'DESC');
break;
Expand All @@ -609,8 +616,6 @@ public function getSublist(Request $request, $key) {
case 'sale_value_asc':
$query->orderBy('characters.sale_value', 'ASC');
break;
default:
$query->orderBy('characters.number', 'DESC');
}

if (!Auth::check() || !Auth::user()->hasPower('manage_characters')) {
Expand Down
24 changes: 14 additions & 10 deletions resources/views/browse/_masterlist_content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
@if (!$isMyo)
<div class="masterlist-search-field">
{!! Form::label('character_category_id', 'Category: ') !!}
{!! Form::select('character_category_id', $categories, Request::get('character_category_id'), ['class' => 'form-control', 'style' => 'width: 250px']) !!}
{!! Form::select('character_category_id', $categories, Request::get('character_category_id'), ['class' => 'form-control mr-2', 'style' => 'width: 250px']) !!}
</div>
<div class="masterlist-search-field">
{!! Form::label('subtype_id', 'Species Subtype: ') !!}
{!! Form::select('subtype_id', $subtypes, Request::get('subtype_id'), ['class' => 'form-control', 'style' => 'width: 250px']) !!}
{!! Form::select('subtype_id', $subtypes, Request::get('subtype_id'), ['class' => 'form-control mr-2', 'style' => 'width: 250px']) !!}
</div>
<hr />
@endif
Expand Down Expand Up @@ -54,11 +54,11 @@
<hr />
<div class="masterlist-search-field">
{!! Form::label('sale_value_min', 'Resale Minimum ($): ') !!}
{!! Form::text('sale_value_min', Request::get('sale_value_min'), ['class' => 'form-control', 'style' => 'width: 250px']) !!}
{!! Form::text('sale_value_min', Request::get('sale_value_min'), ['class' => 'form-control mr-2', 'style' => 'width: 250px']) !!}
</div>
<div class="masterlist-search-field">
{!! Form::label('sale_value_max', 'Resale Maximum ($): ') !!}
{!! Form::text('sale_value_max', Request::get('sale_value_max'), ['class' => 'form-control', 'style' => 'width: 250px']) !!}
{!! Form::text('sale_value_max', Request::get('sale_value_max'), ['class' => 'form-control mr-2', 'style' => 'width: 250px']) !!}
</div>
@if (!$isMyo)
<div class="masterlist-search-field">
Expand Down Expand Up @@ -115,12 +115,16 @@
<div class="form-inline justify-content-end mb-3">
<div class="form-group mr-3">
{!! Form::label('sort', 'Sort: ', ['class' => 'mr-2']) !!}
{!! Form::select(
'sort',
['number_desc' => 'Number Descending', 'number_asc' => 'Number Ascending', 'id_desc' => 'Newest First', 'id_asc' => 'Oldest First', 'sale_value_desc' => 'Highest Sale Value', 'sale_value_asc' => 'Lowest Sale Value'],
Request::get('sort'),
['class' => 'form-control'],
) !!}
@if (!$isMyo)
{!! Form::select(
'sort',
['number_desc' => 'Number Descending', 'number_asc' => 'Number Ascending', 'id_desc' => 'Newest First', 'id_asc' => 'Oldest First', 'sale_value_desc' => 'Highest Sale Value', 'sale_value_asc' => 'Lowest Sale Value'],
Request::get('sort'),
['class' => 'form-control'],
) !!}
@else
{!! Form::select('sort', ['id_desc' => 'Newest First', 'id_asc' => 'Oldest First', 'sale_value_desc' => 'Highest Sale Value', 'sale_value_asc' => 'Lowest Sale Value'], Request::get('sort'), ['class' => 'form-control']) !!}
@endif
</div>
{!! Form::submit('Search', ['class' => 'btn btn-primary']) !!}
</div>
Expand Down

0 comments on commit cb7afdc

Please sign in to comment.