feat: Add type filter
This commit is contained in:
parent
4c4a18ac70
commit
aaf114fa30
5 changed files with 88 additions and 9 deletions
|
|
@ -8,12 +8,12 @@ enum TicketTypeEnum: int
|
|||
{
|
||||
use BaseEnum;
|
||||
|
||||
case bug = 0;
|
||||
case evolution = 1;
|
||||
case br = 2;
|
||||
case newsletter = 3;
|
||||
case qrcode = 4;
|
||||
case advice = 5;
|
||||
case bug = 1;
|
||||
case evolution = 2;
|
||||
case br = 3;
|
||||
case newsletter = 4;
|
||||
case qrcode = 5;
|
||||
case advice = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
|
|
|
|||
|
|
@ -102,8 +102,9 @@ class TicketController extends Controller
|
|||
|
||||
$sites = Site::select('id', 'name')->orderBy('name')->get();
|
||||
$status = TicketStatusEnum::cases();
|
||||
$types = TicketTypeEnum::cases();
|
||||
|
||||
return view('bo.pages.tickets.index', compact('tickets', 'sites', 'status'));
|
||||
return view('bo.pages.tickets.index', compact('tickets', 'sites', 'status', 'types'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -500,6 +501,7 @@ class TicketController extends Controller
|
|||
Session::remove('tickets.ass');
|
||||
Session::remove('tickets.st');
|
||||
Session::remove('tickets.pr');
|
||||
Session::remove('tickets.ty');
|
||||
Session::remove('tickets.sort_col');
|
||||
Session::remove('tickets.sort_way');
|
||||
Session::remove('tickets.search');
|
||||
|
|
@ -513,6 +515,9 @@ class TicketController extends Controller
|
|||
if ($request->sts) {
|
||||
Session::remove('tickets.st');
|
||||
}
|
||||
if ($request->tys) {
|
||||
Session::remove('tickets.ty');
|
||||
}
|
||||
if ($request->sort_col) {
|
||||
Session::put('tickets.sort_col', $request->sort_col);
|
||||
}
|
||||
|
|
@ -525,6 +530,9 @@ class TicketController extends Controller
|
|||
if ($request->st) {
|
||||
Session::put('tickets.st', $request->st);
|
||||
}
|
||||
if ($request->ty) {
|
||||
Session::put('tickets.ty', $request->ty);
|
||||
}
|
||||
if ($request->ass) {
|
||||
Session::put('tickets.ass', $request->ass);
|
||||
}
|
||||
|
|
@ -544,6 +552,11 @@ class TicketController extends Controller
|
|||
$tickets->where('status', Session::get('tickets.st'));
|
||||
}
|
||||
|
||||
if (Session::has('tickets.ty')) {
|
||||
$tickets->where('type', Session::get('tickets.ty'));
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
Session::has('tickets.sort_col') and
|
||||
Session::has('tickets.sort_way') and
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Ticket;
|
||||
use App\Models\Ticket\TicketType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Ticket::query()->get()->map(function (Ticket $model) {
|
||||
$model->type = $model->getRawOriginal('type') + 1;
|
||||
$model->saveQuietly();
|
||||
});
|
||||
TicketType::query()->orderBy('type', 'DESC')->get()->map(function (TicketType $model) {
|
||||
$model->type = $model->getRawOriginal('type') + 1;
|
||||
$model->saveQuietly();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Ticket::query()->get()->map(function (Ticket $model) {
|
||||
$model->type = $model->getRawOriginal('type') - 1;
|
||||
$model->saveQuietly();
|
||||
});
|
||||
TicketType::query()->orderBy('type', 'DESC')->get()->map(function (TicketType $model) {
|
||||
$model->type = $model->getRawOriginal('type') - 1;
|
||||
$model->saveQuietly();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -57,6 +57,7 @@ import {
|
|||
faSquarePlus,
|
||||
faSyncAlt,
|
||||
faTags,
|
||||
faTicket,
|
||||
faTimes,
|
||||
faTrash,
|
||||
faUndoAlt,
|
||||
|
|
@ -122,6 +123,7 @@ library.add(faBan);
|
|||
library.add(faCircleExclamation);
|
||||
library.add(faCircleInfo);
|
||||
library.add(faPaintRoller);
|
||||
library.add(faTicket);
|
||||
|
||||
// Front
|
||||
library.add(faChevronLeft);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<a class="btn btn-success" href="{{ route('bo.ticket.index', ['sts' => -1]) }}"><i
|
||||
class="fa-solid fa-inbox"></i></a>
|
||||
@else
|
||||
<a class="float-end btn btn-secondary"
|
||||
<a class="btn btn-secondary float-end"
|
||||
href="{{ route('bo.ticket.index', ['st' => \App\Enums\Tickets\TicketStatusEnum::archived]) }}"><i
|
||||
class="fa-solid fa-box-archive"></i></a>
|
||||
@endif
|
||||
|
|
@ -115,7 +115,29 @@
|
|||
</div>
|
||||
@endcan
|
||||
<div class="col">
|
||||
<form class="float-end w-75 mt-3" id="searchTicketForm"
|
||||
<div class="float-end me-2 mt-3">
|
||||
<div class="input-group">
|
||||
<label class="input-group-text" for="selectType"><i class="fa-solid fa-tagaaa"></i></label>
|
||||
<select class="form-select" id="selectType">
|
||||
<option value="-1">{{ __('Tous les types') }}</option>
|
||||
@foreach ($types as $type)
|
||||
<option value="{{ $type->value }}"
|
||||
@if (intval(session('tickets.ty')) == $type->value) selected="selected" @endif>{{ $type->label() }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.getElementById('selectType').addEventListener('change', function(e) {
|
||||
window.location = '{{ route('bo.ticket.index') }}?' + (this.value == -1 ? 'tys=-1' : 'ty=' + this.value);
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<form class="w-75 float-end mt-3" id="searchTicketForm"
|
||||
action="{{ request()->fullUrlWithQuery(['search' => '']) }}">
|
||||
<div class="input-group mb-3">
|
||||
<input class="form-control" id="searchTicket" name="search" type="text"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue