feat: ✨ add claims bo interface
This commit is contained in:
parent
187b96fbaf
commit
ced124b60e
148 changed files with 5893 additions and 2106 deletions
|
|
@ -173,12 +173,12 @@ class UserCreate extends Command
|
|||
$tmp = $this->choice(
|
||||
'Select his role',
|
||||
[
|
||||
RoleEnum::conceptor->name,
|
||||
RoleEnum::admin->name,
|
||||
RoleEnum::visitor->name,
|
||||
RoleEnum::marketing->name,
|
||||
Str::ucFirst(RoleEnum::conceptor->label()),
|
||||
Str::ucFirst(RoleEnum::admin->label()),
|
||||
Str::ucFirst(RoleEnum::visitor->label()),
|
||||
Str::ucFirst(RoleEnum::marketing->label())
|
||||
],
|
||||
RoleEnum::visitor->name,
|
||||
Str::ucFirst(RoleEnum::marketing->label()),
|
||||
);
|
||||
if ($tmp === Str::ucFirst(RoleEnum::conceptor->label())) {
|
||||
$tmp = RoleEnum::conceptor;
|
||||
|
|
@ -189,7 +189,7 @@ class UserCreate extends Command
|
|||
if ($tmp === Str::ucFirst(RoleEnum::visitor->label())) {
|
||||
$tmp = RoleEnum::visitor;
|
||||
}
|
||||
if ($tmp === RoleEnum::marketing->name) {
|
||||
if ($tmp === Str::ucFirst(RoleEnum::marketing->label())) {
|
||||
$tmp = RoleEnum::marketing;
|
||||
}
|
||||
$validator = Validator::make(['role' => $tmp], [
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ enum ClaimMessageType: int
|
|||
{
|
||||
use BaseEnum;
|
||||
|
||||
case auto = 1;
|
||||
case human = 2;
|
||||
case system = 1;
|
||||
case human = 2;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::auto->name => 'Automatique',
|
||||
self::human->name => 'Humain',
|
||||
self::system->name => 'Système',
|
||||
self::human->name => 'Humain',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
51
app/Enums/Claims/ClaimResponseType.php
Normal file
51
app/Enums/Claims/ClaimResponseType.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Claims;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum ClaimResponseType: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case none = 1;
|
||||
case manual = 2;
|
||||
case mail = 3;
|
||||
case email = 4;
|
||||
case phone = 5;
|
||||
case other = 99;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::none->name => 'Non défini',
|
||||
self::manual->name => 'Manuelle',
|
||||
self::mail->name => 'Courrier',
|
||||
self::email->name => 'E-mail',
|
||||
self::phone->name => 'Téléphone',
|
||||
self::other->name => 'Autre',
|
||||
];
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const COLORS = [
|
||||
self::none->name => '#b8b8b8',
|
||||
self::manual->name => '#a7a7a7',
|
||||
self::mail->name => '#757575',
|
||||
self::email->name => '#5e5e5e',
|
||||
self::phone->name => '#414141',
|
||||
self::other->name => '#2b2b2b',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function color(): string
|
||||
{
|
||||
return self::COLORS[$this->name];
|
||||
}
|
||||
}
|
||||
|
|
@ -9,17 +9,37 @@ enum ClaimStatus: int
|
|||
use BaseEnum;
|
||||
|
||||
case untreated = 1;
|
||||
case treated = 2;
|
||||
case sentDigital = 3;
|
||||
case sentMarketing = 4;
|
||||
case sentDigital = 2;
|
||||
case sentMarketing = 3;
|
||||
case treated = 4;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::untreated->name => 'Non traitée',
|
||||
self::treated->name => 'Traitée',
|
||||
self::sentDigital->name => 'Transférée au service Digital',
|
||||
self::sentMarketing->name => 'Retournée au Marketing',
|
||||
self::treated->name => 'Traitée',
|
||||
];
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const COLORS = [
|
||||
self::untreated->name => '#5a5a5a',
|
||||
self::sentDigital->name => '#0033c0',
|
||||
self::sentMarketing->name => '#69077c',
|
||||
self::treated->name => '#188618',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function color(): string
|
||||
{
|
||||
return self::COLORS[$this->name];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,4 +20,23 @@ enum ClaimType: int
|
|||
self::br->name => 'BR',
|
||||
self::rgpd->name => 'RGPD',
|
||||
];
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
*/
|
||||
private const COLORS = [
|
||||
self::classic->name => '#08818a',
|
||||
self::br->name => '#9021f8',
|
||||
self::rgpd->name => '#c2237a',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function color(): string
|
||||
{
|
||||
return self::COLORS[$this->name];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ enum RoleEnum: int
|
|||
|
||||
case conceptor = 1;
|
||||
case admin = 2;
|
||||
case visitor = 3;
|
||||
case marketing = 4;
|
||||
case marketing = 3;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition.
|
||||
|
|
@ -19,7 +18,6 @@ enum RoleEnum: int
|
|||
private const LABELS = [
|
||||
self::conceptor->name => 'Concepteur',
|
||||
self::admin->name => 'Administrateur',
|
||||
self::visitor->name => 'Visiteur',
|
||||
self::marketing->name => 'Marketing',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
55
app/Events/ClaimModelChanged.php
Normal file
55
app/Events/ClaimModelChanged.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Claim;
|
||||
use App\Models\User;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ClaimModelChanged
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithSockets;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var \App\Models\Claim $claim Current claim modified. */
|
||||
public $claim;
|
||||
|
||||
/** @var string $field Modified field. */
|
||||
public $field;
|
||||
|
||||
/** @var string $label Label of the modified field. */
|
||||
public $label;
|
||||
|
||||
/** @var \App\Models\User|null $user Current authenticated user. */
|
||||
public $user;
|
||||
|
||||
/** @var string|null $content Custom content message. */
|
||||
public $content;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \App\Models\Claim $claim
|
||||
* @param string $field
|
||||
* @param string $label
|
||||
* @param \App\Models\User|null $user
|
||||
* @param string|null $content
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Claim $claim,
|
||||
string $field,
|
||||
string $label,
|
||||
User|null $user = null,
|
||||
string|null $content = null,
|
||||
) {
|
||||
$this->claim = $claim;
|
||||
$this->field = $field;
|
||||
$this->label = $label;
|
||||
$this->user = $user;
|
||||
$this->content = $content;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,14 @@ class ActivityLogsController extends Controller
|
|||
use ChangesModelOrder;
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(ActivityLog::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -13,6 +13,14 @@ use Illuminate\Support\Str;
|
|||
|
||||
class AnswerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Answer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -13,6 +13,14 @@ use Illuminate\Support\Str;
|
|||
|
||||
class BrandController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Brand::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
@ -126,18 +134,4 @@ class BrandController extends Controller
|
|||
));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function jsonPaginate(): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
return DB::transaction(function () {
|
||||
/** @var \App\Models\Brand */
|
||||
$brandModels = Brand::paginate(12);
|
||||
return \response()->json($brandModels ?? 500);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
189
app/Http/Controllers/Bo/ClaimController.php
Normal file
189
app/Http/Controllers/Bo/ClaimController.php
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Enums\Claims\ClaimResponseType;
|
||||
use App\Enums\Claims\ClaimStatus;
|
||||
use App\Events\ClaimModelChanged;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\Claims\SendClaimAnswerRequest;
|
||||
use App\Http\Requests\Bo\Claims\UpdateClaimRequest;
|
||||
use App\Http\Requests\Bo\PaginateModelsRequest;
|
||||
use App\Mail\ClaimAnswerMail;
|
||||
use App\Models\Brand;
|
||||
use App\Models\Claim;
|
||||
use App\Models\ClaimMailTemplate;
|
||||
use App\Models\ClaimMessage;
|
||||
use App\Models\ClaimSubject;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Claim::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $claimModels */
|
||||
$claimModels = Claim::query()->when(
|
||||
$request->filled('brand'),
|
||||
fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
|
||||
);
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
$this->searchQuery(
|
||||
$claimModels,
|
||||
$search,
|
||||
null,
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
);
|
||||
}
|
||||
$searchFields = \implode(', ', [
|
||||
trans('validation.attributes.first_name'),
|
||||
trans('validation.attributes.last_name'),
|
||||
trans('validation.attributes.email'),
|
||||
]);
|
||||
|
||||
/** Sort columns with a query */
|
||||
$this->sortQuery($claimModels);
|
||||
|
||||
/** Custom pagination */
|
||||
$claimModels = $this->paginate($claimModels);
|
||||
|
||||
return view('bo.pages.claims.index', compact('claimModels', 'search', 'searchFields'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param App\Models\Claim $claim
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function edit(Claim $claim): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$customerClaimModels = !is_null($claim->customer) ? $this->paginate(Claim::query()
|
||||
->whereNotNull('customer_id')
|
||||
->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
|
||||
->whereHas('customer', fn($q) => $q->whereKey($claim->customer->getKey()))
|
||||
->whereNot('id', $claim->getKey())
|
||||
->whereNot('status', ClaimStatus::treated)) : collect();
|
||||
$brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
|
||||
$claimSubjectModels = ClaimSubject::query()
|
||||
->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
|
||||
->orderBy('label', 'ASC')
|
||||
->paginate($this->jsonItemPerPagination);
|
||||
$claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey());
|
||||
$claimTemplateModels = ClaimMailTemplate::query()
|
||||
->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
|
||||
->orderBy('label', 'ASC')
|
||||
->paginate($this->jsonItemPerPagination);
|
||||
|
||||
return view('bo.pages.claims.edit', [
|
||||
'claimModel' => $claim->load(['brand', 'claimSubject']),
|
||||
'customerClaimModels' => $customerClaimModels,
|
||||
'brandModels' => $brandModels,
|
||||
'claimSubjectModels' => $claimSubjectModels,
|
||||
'claimMessageModels' => $claimMessageModels,
|
||||
'claimTemplateModels' => $claimTemplateModels,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Claims\UpdateClaimRequest $request
|
||||
* @param \App\Models\Claim $claim
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(UpdateClaimRequest $request, Claim $claim): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $claim) {
|
||||
$claim->fill($request->validated());
|
||||
|
||||
if ($claim->saveOrFail()) {
|
||||
$claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey());
|
||||
return response()->json($claimMessageModels);
|
||||
}
|
||||
return response()->json([], 500);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a paginate resource.
|
||||
* Needed to overheight the controller method and add a brand condition.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\PaginateModelsRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function jsonClaimPaginateModels(PaginateModelsRequest $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Model $models */
|
||||
$models = $request->targetModel::query()
|
||||
->whereHas('brand', fn($q) => $q->whereKey($request->route()->parameter('brand')))
|
||||
->where($request->input('fieldName') ?? 'name', 'like', "%{$request->input('search')}%")
|
||||
->orderBy($request->input('fieldName') ?? 'name', 'ASC')
|
||||
->paginate($request->input('paginate') ?? 10);
|
||||
return \response()->json($models);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the claim answer.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\Claims\SendClaimAnswerRequest $request
|
||||
* @param \App\Models\Claim $claim
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function answer(SendClaimAnswerRequest $request, Claim $claim): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
return DB::transaction(function () use ($request, $claim) {
|
||||
/** @var \App\Models\User $userModel */
|
||||
$userModel = auth()->user();
|
||||
$enum = ClaimResponseType::manual;
|
||||
$claim->response_type = $enum;
|
||||
$claim->status = ClaimStatus::treated;
|
||||
|
||||
if ($claim->saveOrFail()) {
|
||||
// Send the response to the claim author.
|
||||
Mail::to($claim->email)->send(new ClaimAnswerMail($claim, $request->validated()['content']));
|
||||
|
||||
// Create custom event with content message.
|
||||
// @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
$content = sprintf(
|
||||
"<b>%s %s</b> %s <i class='badge' style='background-color:{$enum->color()}'>%s</i><hr class='my-2'>%s",
|
||||
$userModel->first_name,
|
||||
$userModel->last_name,
|
||||
trans('a modifié le :field en', ['field' => trans('validation.custom.response_type')]),
|
||||
$claim->response_type->label(),
|
||||
clean($request->validated()['content']),
|
||||
);
|
||||
event(new ClaimModelChanged($claim, '', '', null, $content));
|
||||
// @phpcs:enable
|
||||
|
||||
// Return conversation.
|
||||
$claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey());
|
||||
return response()->json($claimMessageModels);
|
||||
} //end if
|
||||
return response()->json([], 500);
|
||||
});
|
||||
}
|
||||
}
|
||||
54
app/Http/Controllers/Bo/ClaimMessageController.php
Normal file
54
app/Http/Controllers/Bo/ClaimMessageController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\ClaimMessages\StoreMessageRequest;
|
||||
use App\Http\Requests\Bo\ClaimMessages\UpdateMessageRequest;
|
||||
use App\Models\ClaimMessage;
|
||||
use App\Traits\Controllers\UpdateModelPublished;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ClaimMessageController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
|
||||
/**
|
||||
* Store a new specific resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\ClaimMessages\StoreMessageRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(StoreMessageRequest $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$this->authorize('store', ClaimMessage::class);
|
||||
|
||||
return DB::transaction(function () use ($request) {
|
||||
$claimMessage = new ClaimMessage();
|
||||
$claimMessage->fill($request->validated());
|
||||
if ($claimMessage->saveOrFail()) {
|
||||
$claimMessageModels = ClaimMessage::getAllClaimMessages($claimMessage->claim->getKey());
|
||||
return response()->json($claimMessageModels);
|
||||
}
|
||||
return response()->json([], 500);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a specified resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\ClaimMessages\UpdateMessageRequest $request
|
||||
* @param \App\Models\ClaimMessage $claim_message
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(UpdateMessageRequest $request, ClaimMessage $claim_message): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$this->authorize('update', ClaimMessage::class);
|
||||
|
||||
$model = ClaimMessage::findOrFail($claim_message->getKey());
|
||||
$model->content = $request->validated()['content'];
|
||||
$model->saveOrFail();
|
||||
|
||||
return response()->json();
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
|||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Customer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* View all customers.
|
||||
*
|
||||
|
|
@ -195,6 +203,7 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function export(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$this->authorize('export', Customer::class);
|
||||
$brands = Brand::all();
|
||||
return view('bo.pages.customers.export', compact(
|
||||
'brands'
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
|||
|
||||
class QuestionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Question::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
@ -27,11 +35,11 @@ class QuestionController extends Controller
|
|||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = Question::query();
|
||||
$query = Question::query()->when(
|
||||
$request->filled('brand'),
|
||||
fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
|
||||
);
|
||||
|
||||
if ($request->brand) {
|
||||
$query = $query->where('brand_id', '=', $request->brand);
|
||||
}
|
||||
if ($request->search) {
|
||||
$this->searchQuery(
|
||||
$query,
|
||||
|
|
@ -60,11 +68,10 @@ class QuestionController extends Controller
|
|||
*/
|
||||
public function create(Question $question): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$brandModels = Brand::all();
|
||||
|
||||
$brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
|
||||
return view('bo.pages.questions.create', [
|
||||
'questionModel' => $question,
|
||||
'brandModels' => $brandModels
|
||||
'brandModels' => $brandModels
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -104,9 +111,8 @@ class QuestionController extends Controller
|
|||
*/
|
||||
public function edit(Question $question): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$brandModels = Brand::all();
|
||||
$brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
|
||||
$question->load('brand');
|
||||
|
||||
return view('bo.pages.questions.edit', [
|
||||
'questionModel' => $question,
|
||||
'brandModels' => $brandModels
|
||||
|
|
@ -183,6 +189,7 @@ class QuestionController extends Controller
|
|||
*/
|
||||
public function export(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$this->authorize('export', Question::class);
|
||||
$brands = Brand::all();
|
||||
return view('bo.pages.questions.export', compact('brands'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,14 @@ use Illuminate\Support\Str;
|
|||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
@ -26,11 +34,11 @@ class ServiceController extends Controller
|
|||
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = Service::query();
|
||||
$query = Service::query()->when(
|
||||
$request->filled('brand'),
|
||||
fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
|
||||
);
|
||||
|
||||
if ($request->brand) {
|
||||
$query = $query->where('brand_id', '=', $request->brand);
|
||||
}
|
||||
if ($request->search) {
|
||||
$this->searchQuery(
|
||||
$query,
|
||||
|
|
@ -58,8 +66,7 @@ class ServiceController extends Controller
|
|||
*/
|
||||
public function create(Service $service): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$brandModels = Brand::all();
|
||||
|
||||
$brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
|
||||
return view('bo.pages.services.create', [
|
||||
'serviceModel' => $service,
|
||||
'brandModels' => $brandModels
|
||||
|
|
@ -104,8 +111,7 @@ class ServiceController extends Controller
|
|||
*/
|
||||
public function edit(Service $service): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$brandModels = Brand::all();
|
||||
|
||||
$brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
|
||||
return view('bo.pages.services.edit', [
|
||||
'serviceModel' => $service,
|
||||
'brandModels' => $brandModels
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@ use Illuminate\Support\Str;
|
|||
|
||||
class SingleOptinController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create the controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->authorizeResource(SingleOptin::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ use App\Http\Requests\Bo\StatsByBrandRequest;
|
|||
use App\Http\Requests\Bo\StatsByQuestionRequest;
|
||||
use App\Models\Brand;
|
||||
use App\Models\BrandStat;
|
||||
use App\Models\CustomerAnswer;
|
||||
use App\Models\ModelAnswer;
|
||||
use App\Models\Question;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use League\Csv\Writer;
|
||||
|
||||
|
|
@ -24,6 +25,7 @@ class StatsController extends Controller
|
|||
*/
|
||||
public function viewStatsByBrand(StatsByBrandRequest $request)
|
||||
{
|
||||
Gate::authorize('viewStatsByBrand');
|
||||
$stats = null;
|
||||
if ($request->post()) {
|
||||
$stats = BrandStat::query()->whereDate('created_at', '>=', $request->start)
|
||||
|
|
@ -85,6 +87,7 @@ class StatsController extends Controller
|
|||
*/
|
||||
public function viewByQuestion(StatsByQuestionRequest $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
Gate::authorize('viewByQuestion');
|
||||
$question = null;
|
||||
$answers = null;
|
||||
$answersByDays = null;
|
||||
|
|
@ -152,8 +155,10 @@ class StatsController extends Controller
|
|||
*/
|
||||
private function answersByDays(Collection $answers, Carbon $start, Carbon $end): \Illuminate\Support\Collection
|
||||
{
|
||||
Gate::authorize('answersByDays');
|
||||
// * Totalize by date all answers.
|
||||
$answersByDays = CustomerAnswer::query()->whereDate('created_at', '>=', $start)
|
||||
$answersByDays = ModelAnswer::query()
|
||||
->whereDate('created_at', '>=', $start)
|
||||
->whereDate('created_at', '<=', $end)
|
||||
->whereIn('answer_id', $answers->pluck('id'))
|
||||
->get()->map(function ($custAnswer) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UsersController extends Controller
|
||||
class UserController extends Controller
|
||||
{
|
||||
use UpdateModelPublished;
|
||||
|
||||
|
|
@ -4,11 +4,12 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Enums\Pagination\ItemsPerPaginationEnum;
|
||||
use App\Enums\Theme\BootstrapThemeEnum;
|
||||
use App\Http\Requests\Bo\PaginateModelsRequest;
|
||||
use App\Http\Requests\Bo\ThemeRequest;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
|
@ -20,6 +21,9 @@ class Controller extends BaseController
|
|||
use AuthorizesRequests;
|
||||
use ValidatesRequests;
|
||||
|
||||
/** @var integer $itemPerPagination */
|
||||
public $jsonItemPerPagination = 5;
|
||||
|
||||
/**
|
||||
* Build Search query on specified fields
|
||||
* splitting search into words or using whole sentence
|
||||
|
|
@ -210,16 +214,32 @@ class Controller extends BaseController
|
|||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a paginate resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\PaginateModelsRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function jsonPaginateModels(PaginateModelsRequest $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Model $models */
|
||||
$models = $request->targetModel::query()
|
||||
->where($request->input('fieldName') ?? 'name', 'like', "%{$request->input('search')}%")
|
||||
->orderBy($request->input('fieldName') ?? 'name', 'ASC')
|
||||
->paginate($request->input('paginate') ?? 10);
|
||||
return \response()->json($models);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bootstrap theme or light (default).
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Http\Requests\Bo\ThemeRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function setTheme(Request $request): \Illuminate\Http\RedirectResponse
|
||||
protected function setTheme(ThemeRequest $request): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$theme = ToolboxHelper::getValidatedEnum(
|
||||
$request->theme ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
|
||||
$request->validated('theme') ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
|
||||
'theme',
|
||||
'\App\Http\Controllers\BootstrapThemeEnum',
|
||||
);
|
||||
|
|
|
|||
66
app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php
Normal file
66
app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\ClaimMessages;
|
||||
|
||||
use App\Enums\Claims\ClaimMessageType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreMessageRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
/** @var \App\Models\User $userModel */
|
||||
$userModel = auth('backend')->user();
|
||||
|
||||
$this->merge([
|
||||
'user_id' => $userModel->getKey(),
|
||||
'type' => ClaimMessageType::human->value(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'claim_id' => 'required|numeric|exists:claims,id',
|
||||
'user_id' => 'required|numeric|exists:users,id',
|
||||
'content' => 'required|string|between:3,255',
|
||||
'type' => ['required', new Enum(ClaimMessageType::class)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Translation\Translator|string|array<mixed>|null>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'claim_id' => trans('models.classes.claims'),
|
||||
'user_id' => trans('models.classes.users'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
'type' => trans('validation.custom.type'),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php
Normal file
44
app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\ClaimMessages;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateMessageRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'claim_message_id' => 'required|numeric|exists:claim_messages,id',
|
||||
'content' => 'required|string|between:3,255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Translation\Translator|string|array<mixed>|null>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'claim_message_id' => trans('models.classes.claim_messages'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php
Normal file
44
app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Claims;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SendClaimAnswerRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'claim_id' => 'required|numeric|exists:claims,id',
|
||||
'content' => 'required|string|between:3,500',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Translation\Translator|string|array<mixed>|null>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'claim_id' => trans('models.classes.claims'),
|
||||
'content' => trans('validation.attributes.content'),
|
||||
];
|
||||
}
|
||||
}
|
||||
54
app/Http/Requests/Bo/Claims/UpdateClaimRequest.php
Normal file
54
app/Http/Requests/Bo/Claims/UpdateClaimRequest.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo\Claims;
|
||||
|
||||
use App\Enums\Claims\ClaimResponseType;
|
||||
use App\Enums\Claims\ClaimStatus;
|
||||
use App\Enums\Claims\ClaimType;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class UpdateClaimRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'brand_id' => 'required|numeric|exists:brands,id',
|
||||
'subject_id' => 'required|numeric|exists:claim_subjects,id',
|
||||
'type' => ['required', new Enum(ClaimType::class)],
|
||||
'status' => ['required', new Enum(ClaimStatus::class)],
|
||||
'response_type' => ['present', 'nullable', new Enum(ClaimResponseType::class)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Translation\Translator|string|array<mixed>|null>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'brand_id' => trans('models.classes.brands'),
|
||||
'subject_id' => trans('models.classes.claim_subjects'),
|
||||
'type' => trans('validation.custom.type'),
|
||||
'status' => trans('validation.custom.status'),
|
||||
'response_type' => trans('validation.custom.response_type'),
|
||||
];
|
||||
}
|
||||
}
|
||||
52
app/Http/Requests/Bo/PaginateModelsRequest.php
Normal file
52
app/Http/Requests/Bo/PaginateModelsRequest.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PaginateModelsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'targetModel' => [
|
||||
'required',
|
||||
'string',
|
||||
'starts_with:App\\Models\\',
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
if (!class_exists($value)) {
|
||||
$fail("Le modèle spécifié n'existe pas.");
|
||||
return;
|
||||
}
|
||||
if (!is_subclass_of($value, \Illuminate\Database\Eloquent\Model::class)) {
|
||||
$fail("Le modèle spécifié n'est pas un modèle Eloquent.");
|
||||
}
|
||||
},
|
||||
],
|
||||
'page' => 'required|integer|min:1',
|
||||
'paginate' => 'required|integer|min:1',
|
||||
'fieldName' => 'required|string|alpha_dash|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Translation\Translator|string|array<mixed>|null>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'targetModel' => trans('validation.custom.targetModel'),
|
||||
'page' => trans('validation.custom.page'),
|
||||
'paginate' => trans('validation.custom.paginate'),
|
||||
'fieldName' => trans('validation.custom.fieldName'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -18,18 +18,6 @@ class StoreQuestionRequest extends FormRequest
|
|||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'brand_id' => collect($this->brand)->pluck('id')->first()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,18 +16,6 @@ class StoreServiceRequest extends FormRequest
|
|||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'brand_id' => collect($this->brand)->pluck('id')->first()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
|
|
|||
34
app/Http/Requests/Bo/ThemeRequest.php
Normal file
34
app/Http/Requests/Bo/ThemeRequest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use App\Enums\Theme\BootstrapThemeEnum;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class ThemeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'theme' => ['required', new Enum(BootstrapThemeEnum::class)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array<string,\Illuminate\Contracts\Translation\Translator|string|array<mixed>|null>
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'theme' => trans('validation.custom.theme'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,11 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'published' => $this->published ? true : false,
|
||||
'password' => $this->password ? $this->password : $this->route('user')->password,
|
||||
'published' => $this->published ? true : false,
|
||||
'password' => $this->password ? $this->password : $this->route('user')->password,
|
||||
'password_confirmation' => $this->password_confirmation ?
|
||||
$this->password_confirmation :
|
||||
$this->route('user')->password
|
||||
|
|
@ -30,7 +30,7 @@ class UpdateUserRequest extends StoreUserRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return array_merge(parent::rules(), [
|
||||
'email' => [
|
||||
'email' => [
|
||||
'required',
|
||||
'email:rfc,strict,dns,spoof,filter',
|
||||
'unique:users,email,' . $this->route('user')->id . ',id',
|
||||
|
|
|
|||
123
app/Listeners/AddClaimMessageSystem.php
Normal file
123
app/Listeners/AddClaimMessageSystem.php
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Enums\Claims\ClaimMessageType;
|
||||
use App\Events\ClaimModelChanged;
|
||||
use App\Models\ClaimMessage;
|
||||
|
||||
class AddClaimMessageSystem
|
||||
{
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \App\Events\ClaimModelChanged $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(ClaimModelChanged $event): void
|
||||
{
|
||||
$message = $this->createClaimMessage($event);
|
||||
|
||||
// Assign content based on whether there is a custom message or default handling.
|
||||
$message->content = $event->content ? $event->content : $this->generateMessageContent($event);
|
||||
|
||||
$message->saveOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ClaimMessage instance.
|
||||
*
|
||||
* @param \App\Events\ClaimModelChanged $event
|
||||
* @return \App\Models\ClaimMessage
|
||||
*/
|
||||
private function createClaimMessage(ClaimModelChanged $event): ClaimMessage
|
||||
{
|
||||
return new ClaimMessage([
|
||||
'claim_id' => $event->claim->getKey(),
|
||||
'user_id' => null,
|
||||
'type' => ClaimMessageType::system,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the message content based on the event data.
|
||||
*
|
||||
* @param \App\Events\ClaimModelChanged $event
|
||||
* @return string
|
||||
*/
|
||||
private function generateMessageContent(ClaimModelChanged $event): string
|
||||
{
|
||||
// Check for Enum type and generate content accordingly.
|
||||
$castType = $event->claim->getCasts()[$event->field] ?? null;
|
||||
if ($castType && enum_exists($castType) && str_starts_with($castType, "App\\Enums\\Claims\\")) {
|
||||
return $this->generateEnumMessageContent($event);
|
||||
}
|
||||
|
||||
// Default field message content.
|
||||
return $this->generateDefaultFieldMessageContent($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate message content for Enum type fields.
|
||||
*
|
||||
* @param \App\Events\ClaimModelChanged $event
|
||||
* @return string
|
||||
*/
|
||||
private function generateEnumMessageContent(ClaimModelChanged $event): string
|
||||
{
|
||||
$enumLabel = $event->claim->{$event->field}->label();
|
||||
$enumColor = $event->claim->{$event->field}->color();
|
||||
$baseMessage = trans(':field est passé à', ['field' => $event->label]);
|
||||
|
||||
// If the user is available, include user details in the message.
|
||||
if ($event->user) {
|
||||
return sprintf(
|
||||
"<b>%s %s</b> %s <i class='badge' style='background-color:%s'>%s</i>",
|
||||
$event->user->first_name,
|
||||
$event->user->last_name,
|
||||
trans('a modifié le :field en', ['field' => $event->label]),
|
||||
$enumColor,
|
||||
$enumLabel,
|
||||
);
|
||||
}
|
||||
|
||||
// User is not available, return a simple enum change message.
|
||||
return sprintf(
|
||||
"%s : <i class='badge' style='background-color:%s'>%s</i>",
|
||||
$baseMessage,
|
||||
$enumColor,
|
||||
$enumLabel,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate message content for default field types.
|
||||
*
|
||||
* @param \App\Events\ClaimModelChanged $event
|
||||
* @return string
|
||||
*/
|
||||
private function generateDefaultFieldMessageContent(ClaimModelChanged $event): string
|
||||
{
|
||||
$field = $event->claim->{$event->field};
|
||||
$baseMessage = trans(':field est passé à', ['field' => $event->label]);
|
||||
$fieldLabel = $field->label ?? $field->name;
|
||||
|
||||
// If the user is available, include user details in the message.
|
||||
if ($event->user) {
|
||||
return sprintf(
|
||||
"<b>%s %s</b> %s <b>%s</b>",
|
||||
$event->user->first_name,
|
||||
$event->user->last_name,
|
||||
trans('a modifié le :field en', ['field' => $event->label]),
|
||||
$fieldLabel,
|
||||
);
|
||||
}
|
||||
|
||||
// User is not available, return a simple field change message.
|
||||
return sprintf(
|
||||
"%s : <b>%s</b>",
|
||||
$baseMessage,
|
||||
$fieldLabel,
|
||||
);
|
||||
}
|
||||
}
|
||||
70
app/Mail/ClaimAnswerMail.php
Normal file
70
app/Mail/ClaimAnswerMail.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Claim;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ClaimAnswerMail extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The current claim.
|
||||
*
|
||||
* @var \App\Models\Claim
|
||||
*/
|
||||
protected $claimModel;
|
||||
|
||||
/**
|
||||
* The answer of the current claim.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $answer;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\Claim $claimModel
|
||||
* @param string $answer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Claim $claimModel, string $answer)
|
||||
{
|
||||
$this->claimModel = $claimModel;
|
||||
$this->answer = $answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this
|
||||
->from("no-reply@{$this->claimModel->brand->domain}")
|
||||
->subject(sprintf(
|
||||
'Réponse réclamation %s - %s',
|
||||
$this->claimModel->reference,
|
||||
$this->claimModel->brand->name
|
||||
))
|
||||
->markdown('mail.send-claim-answer')
|
||||
->text('mail.send-claim-answer-plain')
|
||||
->with([
|
||||
'customHeader' => view('vendor.mail.html.header-claim-answer', [
|
||||
'brandModel' => $this->claimModel->brand,
|
||||
])->render(),
|
||||
'customFooter' => view('vendor.mail.html.footer-claim-answer', [
|
||||
'brandModel' => $this->claimModel->brand,
|
||||
])->render(),
|
||||
'claimModel' => $this->claimModel,
|
||||
'answer' => $this->answer,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,29 +2,33 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Claims\ClaimResponseType;
|
||||
use App\Enums\Claims\ClaimStatus;
|
||||
use App\Enums\Claims\ClaimType;
|
||||
use App\Events\ClaimModelChanged;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property integer $id Claim id.
|
||||
* @property string $reference Claim reference.
|
||||
* @property string $first_name Claimant\'s first name.
|
||||
* @property string $last_name Claimant\'s last name.
|
||||
* @property string $email Claimant\'s email.
|
||||
* @property string|null $address Claimant\'s address.
|
||||
* @property string|null $city Claimant\'s city.
|
||||
* @property string|null $postcode Claimant\'s postcode.
|
||||
* @property string|null $file Claimant\'s file.
|
||||
* @property string $message Claimant\'s message.
|
||||
* @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum).
|
||||
* @property \App\Enums\Claims\ClaimStatus $status Claim status (ClaimStatus enum).
|
||||
* @property \App\Models\Brand $brand_id Claim associated Brand.
|
||||
* @property \App\Models\ClaimSubject $subject_id Claim associated Subject.
|
||||
* @property \App\Models\Customer|null $customer_id Claim associated Customer.
|
||||
* @property-read \Illuminate\Support\Carbon $created_at Claim created date.
|
||||
* @property-read \Illuminate\Support\Carbon $updated_at Claim updated date.
|
||||
* @property integer $id Claim id.
|
||||
* @property string $reference Claim reference.
|
||||
* @property string $first_name Claimant\'s first name.
|
||||
* @property string $last_name Claimant\'s last name.
|
||||
* @property string $email Claimant\'s email.
|
||||
* @property string|null $address Claimant\'s address.
|
||||
* @property string|null $city Claimant\'s city.
|
||||
* @property string|null $postcode Claimant\'s postcode.
|
||||
* @property string|null $file Claimant\'s file.
|
||||
* @property string $message Claimant\'s message.
|
||||
* @property \App\Enums\Claims\ClaimResponseType $response_type Claim type (ClaimResponseType enum).
|
||||
* @property \App\Enums\Claims\ClaimStatus $status Claim status (ClaimStatus enum).
|
||||
* @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum).
|
||||
* @property \App\Models\Brand $brand_id Claim associated Brand.
|
||||
* @property \App\Models\ClaimSubject $subject_id Claim associated Subject.
|
||||
* @property \App\Models\Customer|null $customer_id Claim associated Customer.
|
||||
* @property-read \Illuminate\Support\Carbon $created_at Claim created date.
|
||||
* @property-read \Illuminate\Support\Carbon $updated_at Claim updated date.
|
||||
*/
|
||||
class Claim extends Model
|
||||
{
|
||||
|
|
@ -45,8 +49,9 @@ class Claim extends Model
|
|||
'postcode',
|
||||
'file',
|
||||
'message',
|
||||
'type',
|
||||
'response_type',
|
||||
'status',
|
||||
'type',
|
||||
'brand_id',
|
||||
'subject_id',
|
||||
'customer_id',
|
||||
|
|
@ -58,8 +63,9 @@ class Claim extends Model
|
|||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $casts = [
|
||||
'type' => ClaimType::class,
|
||||
'status' => ClaimStatus::class,
|
||||
'response_type' => ClaimResponseType::class,
|
||||
'status' => ClaimStatus::class,
|
||||
'type' => ClaimType::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -73,6 +79,56 @@ class Claim extends Model
|
|||
$model->reference = self::encodeIntegerToBase36($model->getKey());
|
||||
$model->saveOrFail();
|
||||
});
|
||||
static::updated(function (self $model) {
|
||||
$user = auth()->user();
|
||||
if (!$user instanceof \App\Models\User) {
|
||||
$user = null;
|
||||
}
|
||||
|
||||
if (isset($model->getChanges()['brand_id'])) {
|
||||
event(new ClaimModelChanged(
|
||||
$model->load('brand'),
|
||||
'brand',
|
||||
Str::singular(trans('models.classes.brands')),
|
||||
$user,
|
||||
));
|
||||
}
|
||||
if (isset($model->getChanges()['subject_id'])) {
|
||||
event(new ClaimModelChanged(
|
||||
$model->load('claimSubject'),
|
||||
'claimSubject',
|
||||
trans('models.classes.claim_subjects'),
|
||||
$user,
|
||||
));
|
||||
}
|
||||
if (isset($model->getChanges()['status'])) {
|
||||
event(new ClaimModelChanged(
|
||||
$model,
|
||||
'status',
|
||||
trans('validation.custom.status'),
|
||||
$user,
|
||||
));
|
||||
}
|
||||
if (isset($model->getChanges()['type'])) {
|
||||
event(new ClaimModelChanged(
|
||||
$model,
|
||||
'type',
|
||||
trans('validation.custom.type'),
|
||||
$user,
|
||||
));
|
||||
}
|
||||
if (
|
||||
isset($model->getChanges()['response_type'])
|
||||
&& !$model->response_type->equals(ClaimResponseType::manual)
|
||||
) {
|
||||
event(new ClaimModelChanged(
|
||||
$model,
|
||||
'response_type',
|
||||
trans('validation.custom.response_type'),
|
||||
$user,
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// * RELATIONS
|
||||
|
|
@ -94,7 +150,7 @@ class Claim extends Model
|
|||
*/
|
||||
public function claimSubject(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ClaimSubject::class);
|
||||
return $this->belongsTo(ClaimSubject::class, 'subject_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,4 +196,17 @@ class Claim extends Model
|
|||
{
|
||||
return base_convert(strtolower($str), 36, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get formated address.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatedAddress(): string
|
||||
{
|
||||
return implode(', ', array_filter([
|
||||
$this->address,
|
||||
trim(implode(' ', array_filter([$this->postcode, $this->city])))
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,22 @@ class ClaimMessage extends Model
|
|||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Get all messages from a specific claim.
|
||||
*
|
||||
* @param integer $claimModelKey
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public static function getAllClaimMessages(int $claimModelKey): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return self::query()
|
||||
->with('user')
|
||||
->whereHas('claim', fn($q) => $q->whereKey($claimModelKey))
|
||||
->orderby('created_at', 'ASC')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
32
app/Policies/ActivityLogPolicy.php
Normal file
32
app/Policies/ActivityLogPolicy.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class ActivityLogPolicy
|
||||
{
|
||||
/**
|
||||
* View a Log.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewAny a Log.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class AnswerPolicy
|
||||
{
|
||||
|
|
@ -13,46 +15,50 @@ class AnswerPolicy
|
|||
*/
|
||||
public function view(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewAny an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(): bool
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(): bool
|
||||
public function update(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(): bool
|
||||
public function delete(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class BrandPolicy
|
||||
{
|
||||
|
|
@ -13,37 +15,40 @@ class BrandPolicy
|
|||
*/
|
||||
public function view(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewAny a Brand.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Brand.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(): bool
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Brand.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(): bool
|
||||
public function update(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -53,6 +58,6 @@ class BrandPolicy
|
|||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
51
app/Policies/ClaimMessagePolicy.php
Normal file
51
app/Policies/ClaimMessagePolicy.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
|
||||
class ClaimMessagePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* View a Claim Message.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* View any a Claim Message.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a Claim Message.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function store(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Claim Message.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
}
|
||||
105
app/Policies/ClaimPolicy.php
Normal file
105
app/Policies/ClaimPolicy.php
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class ClaimPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* View a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* View any a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function preview(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the associated brand of the model.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateBrand(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the associated subject of the model.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateSubject(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateType(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateStatus(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Claim.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateResponseType(): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\Customer;
|
||||
use App\Models\Service;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class CustomerPolicy
|
||||
{
|
||||
|
|
@ -14,21 +16,23 @@ class CustomerPolicy
|
|||
/**
|
||||
* View a Customer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(): bool
|
||||
public function view(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* View any a Customer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +42,7 @@ class CustomerPolicy
|
|||
*/
|
||||
public function create(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -48,17 +52,18 @@ class CustomerPolicy
|
|||
*/
|
||||
public function update(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Customer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(): bool
|
||||
public function delete(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -72,4 +77,15 @@ class CustomerPolicy
|
|||
{
|
||||
return !\is_null($customer->login($service->brand));
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Customers.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function export(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,60 +2,67 @@
|
|||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\Question;
|
||||
use App\Models\Service;
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class QuestionPolicy
|
||||
{
|
||||
/**
|
||||
* View a Question.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(): bool
|
||||
public function view(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewAny a Question.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Question.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(): bool
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Question.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(): bool
|
||||
public function update(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Question.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(): bool
|
||||
public function delete(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,4 +76,15 @@ class QuestionPolicy
|
|||
{
|
||||
return $service->brand->id === $question->brand_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export Customers.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function export(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,48 +2,54 @@
|
|||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class ServicePolicy
|
||||
{
|
||||
/**
|
||||
* View an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function view(): bool
|
||||
public function view(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewAny an Service.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Service.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function create(): bool
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an Service.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function update(): bool
|
||||
public function update(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -53,6 +59,6 @@ class ServicePolicy
|
|||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Policies\Rules\UserStaticRules as USR;
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class SingleOptinPolicy
|
||||
{
|
||||
|
|
@ -13,17 +15,18 @@ class SingleOptinPolicy
|
|||
*/
|
||||
public function view(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewAny an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -33,7 +36,7 @@ class SingleOptinPolicy
|
|||
*/
|
||||
public function create(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -43,16 +46,17 @@ class SingleOptinPolicy
|
|||
*/
|
||||
public function update(): bool
|
||||
{
|
||||
return USR::noOne();
|
||||
return UserStaticRules::noOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an Answer.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(): bool
|
||||
public function delete(User $authUser): bool
|
||||
{
|
||||
return USR::everyOne();
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
43
app/Policies/StatisticPolicy.php
Normal file
43
app/Policies/StatisticPolicy.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Users\RoleEnum;
|
||||
use App\Models\User;
|
||||
use App\Policies\Rules\UserStaticRules;
|
||||
|
||||
class StatisticPolicy
|
||||
{
|
||||
/**
|
||||
* View stats by brand.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewStatsByBrand(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* View by question.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewByQuestion(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Answers by days.
|
||||
*
|
||||
* @param \App\Models\User $authUser
|
||||
* @return boolean
|
||||
*/
|
||||
public function answersByDays(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ class UserPolicy
|
|||
*/
|
||||
public function viewAny(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -28,7 +28,7 @@ class UserPolicy
|
|||
*/
|
||||
public function view(User $authUser, User $user): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role);
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ class UserPolicy
|
|||
*/
|
||||
public function create(User $authUser): bool
|
||||
{
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
||||
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -53,7 +53,7 @@ class UserPolicy
|
|||
public function update(User $authUser, User $user): bool
|
||||
{
|
||||
return $authUser->getRouteKey() === $user->getRouteKey() or
|
||||
(UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
(UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role));
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class UserPolicy
|
|||
public function delete(User $authUser, User $user): bool
|
||||
{
|
||||
return $authUser->getRouteKey() !== $user->getRouteKey() and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role);
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class UserPolicy
|
|||
public function restore(User $authUser, User $user): bool
|
||||
{
|
||||
return $authUser->getRouteKey() !== $user->getRouteKey() and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ class UserPolicy
|
|||
public function forceDelete(User $authUser, User $user): bool
|
||||
{
|
||||
return $authUser->getRouteKey() !== $user->getRouteKey() and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role);
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ class UserPolicy
|
|||
public function duplicate(User $authUser, User $user): bool
|
||||
{
|
||||
return $authUser->getRouteKey() !== $user->getRouteKey() and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role);
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ class UserPolicy
|
|||
public function changePublished(User $authUser, User $user): bool
|
||||
{
|
||||
return $authUser->getRouteKey() !== $user->getRouteKey() and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
|
||||
UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
|
||||
UserStaticRules::atLeastRole($authUser, $user->role);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Enums\Users\RoleEnum;
|
|||
use App\Lib\Helper;
|
||||
use App\Models\Service;
|
||||
use App\Models\User;
|
||||
use App\Policies\StatisticPolicy;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -35,6 +36,10 @@ class AuthServiceProvider extends ServiceProvider
|
|||
return $user->role === RoleEnum::conceptor;
|
||||
});
|
||||
|
||||
Gate::define('viewStatsByBrand', [StatisticPolicy::class, 'viewStatsByBrand']);
|
||||
Gate::define('viewByQuestion', [StatisticPolicy::class, 'viewByQuestion']);
|
||||
Gate::define('answersByDays', [StatisticPolicy::class, 'answersByDays']);
|
||||
|
||||
Auth::viaRequest('api-hmac', function (Request $request) {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Events\ClaimModelChanged;
|
||||
use App\Listeners\AddClaimMessageSystem;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
|
|
@ -20,9 +22,8 @@ class EventServiceProvider extends ServiceProvider
|
|||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
Registered::class => [SendEmailVerificationNotification::class],
|
||||
ClaimModelChanged::class => [AddClaimMessageSystem::class],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\Claims\ClaimResponseType;
|
||||
use App\Enums\Claims\ClaimStatus;
|
||||
use App\Enums\Claims\ClaimType;
|
||||
use App\Models\Brand;
|
||||
|
|
@ -27,18 +28,19 @@ class ClaimFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => $this->faker->firstName(),
|
||||
'last_name' => $this->faker->lastName(),
|
||||
'email' => $this->faker->email(),
|
||||
'address' => $this->faker->optional()->address(),
|
||||
'city' => $this->faker->optional()->city(),
|
||||
'postcode' => $this->faker->optional()->postcode(),
|
||||
'message' => $this->faker->sentence(10),
|
||||
'type' => collect(ClaimType::toArray())->random()->value,
|
||||
'status' => collect(ClaimStatus::toArray())->random()->value,
|
||||
'brand_id' => $this->faker->randomElement(Brand::pluck('id')),
|
||||
'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')),
|
||||
'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null,
|
||||
'first_name' => $this->faker->firstName(),
|
||||
'last_name' => $this->faker->lastName(),
|
||||
'email' => $this->faker->email(),
|
||||
'address' => $this->faker->optional()->address(),
|
||||
'city' => $this->faker->optional()->city(),
|
||||
'postcode' => $this->faker->optional()->postcode(),
|
||||
'message' => $this->faker->sentence(10),
|
||||
'response_type' => ClaimResponseType::none,
|
||||
'type' => collect(ClaimType::toArray())->random()->value,
|
||||
'status' => collect(ClaimStatus::toArray())->random()->value,
|
||||
'brand_id' => $this->faker->randomElement(Brand::pluck('id')),
|
||||
'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')),
|
||||
'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,24 +20,11 @@ class UserFactory extends Factory
|
|||
'first_name' => $this->faker->firstname(),
|
||||
'last_name' => $this->faker->lastname(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
|
||||
'remember_token' => Str::random(10),
|
||||
'role' => \collect(RoleEnum::toArray())->random()->value,
|
||||
'published' => $published,
|
||||
'published_at' => ($published) ? now() : null,
|
||||
'last_connection' => ($published) ? now() : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn() => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Claims\ClaimResponseType;
|
||||
use App\Enums\Claims\ClaimStatus;
|
||||
use App\Enums\Claims\ClaimType;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
|
@ -26,10 +27,12 @@ return new class extends Migration
|
|||
$table->string('postcode')->nullable()->comment('Claimant\'s postcode.');
|
||||
$table->string('file')->nullable()->comment('Claimant\'s file.');
|
||||
$table->text('message')->comment('Claimant\'s message.');
|
||||
$table->unsignedTinyInteger('type')->default(ClaimType::classic)
|
||||
->comment('Claim type (ClaimType enum).');
|
||||
$table->unsignedTinyInteger('response_type')->default(ClaimResponseType::none)
|
||||
->comment('Claim response type (ClaimResponseType enum).');
|
||||
$table->unsignedTinyInteger('status')->default(ClaimStatus::untreated)
|
||||
->comment('Claim status (ClaimStatus enum).');
|
||||
$table->unsignedTinyInteger('type')->default(ClaimType::classic)
|
||||
->comment('Claim type (ClaimType enum).');
|
||||
$table->foreignId('brand_id')->comment('Claim associated Brand.')->constrained('brands')
|
||||
->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreignId('subject_id')->comment('Claim associated Subject.')->constrained('claim_subjects')
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ return new class extends Migration
|
|||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('email_verified_at');
|
||||
$table->dropColumn('password');
|
||||
$table->date('last_connection')->nullable()->after('published_at');
|
||||
$table->timestamp('last_connection')->nullable()->after('published_at');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
117
package-lock.json
generated
117
package-lock.json
generated
|
|
@ -14,6 +14,7 @@
|
|||
"@types/bootstrap": "^5.2.7",
|
||||
"@types/node": "^20.8.2",
|
||||
"@types/toastify-js": "^1.12.1",
|
||||
"@types/vue-select": "^3.16.5",
|
||||
"@vitejs/plugin-legacy": "latest",
|
||||
"@vitejs/plugin-vue": "latest",
|
||||
"@vue/compiler-sfc": "latest",
|
||||
|
|
@ -42,6 +43,7 @@
|
|||
"vite-plugin-eslint": "latest",
|
||||
"vite-plugin-stylelint": "latest",
|
||||
"vue": "latest",
|
||||
"vue-select": "^4.0.0-beta.6",
|
||||
"vue-tsc": "1.6.0"
|
||||
}
|
||||
},
|
||||
|
|
@ -399,19 +401,21 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@babel/helper-string-parser": {
|
||||
"version": "7.22.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
|
||||
"integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
|
||||
"integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-validator-identifier": {
|
||||
"version": "7.22.20",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
|
||||
"integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
|
||||
"version": "7.27.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
|
||||
"integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
|
|
@ -468,10 +472,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@babel/parser": {
|
||||
"version": "7.23.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
|
||||
"integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
|
||||
"version": "7.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.0.tgz",
|
||||
"integrity": "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.28.0"
|
||||
},
|
||||
"bin": {
|
||||
"parser": "bin/babel-parser.js"
|
||||
},
|
||||
|
|
@ -1698,14 +1706,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@babel/types": {
|
||||
"version": "7.23.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
|
||||
"integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
|
||||
"version": "7.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.2.tgz",
|
||||
"integrity": "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/helper-string-parser": "^7.22.5",
|
||||
"@babel/helper-validator-identifier": "^7.22.20",
|
||||
"to-fast-properties": "^2.0.0"
|
||||
"@babel/helper-string-parser": "^7.27.1",
|
||||
"@babel/helper-validator-identifier": "^7.27.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
|
|
@ -2560,6 +2568,59 @@
|
|||
"integrity": "sha512-9CTM+LKFmS0+Ii+RH55XPKcmNxCjLticj8kxeCxa7PnSVCZPQurb9XtKQtoMl/fv7WaqUpRezDcFuY8n92CtUg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/vue-select": {
|
||||
"version": "3.16.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/vue-select/-/vue-select-3.16.8.tgz",
|
||||
"integrity": "sha512-ZBovlBrWf/wnPqCmMw24ryIC7ghQLfIBmkl1qssqBGONdx7yOmi/GLwtPxll/6UwXWGNWMeokleOgVAZPis+Ag==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"vue": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/vue-select/node_modules/@vue/compiler-sfc": {
|
||||
"version": "2.7.16",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz",
|
||||
"integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.23.5",
|
||||
"postcss": "^8.4.14",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"prettier": "^1.18.2 || ^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/vue-select/node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/vue-select/node_modules/vue": {
|
||||
"version": "2.7.16",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.7.16.tgz",
|
||||
"integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==",
|
||||
"deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-sfc": "2.7.16",
|
||||
"csstype": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "6.7.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz",
|
||||
|
|
@ -3312,9 +3373,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/bootstrap": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.2.tgz",
|
||||
"integrity": "sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g==",
|
||||
"version": "5.3.7",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.7.tgz",
|
||||
"integrity": "sha512-7KgiD8UHjfcPBHEpDNg+zGz8L3LqR3GVwqZiBRFX04a1BCArZOz1r2kjly2HQ0WokqTO0v1nF+QAt8dsW4lKlw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -3326,6 +3387,7 @@
|
|||
"url": "https://opencollective.com/bootstrap"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@popperjs/core": "^2.11.8"
|
||||
}
|
||||
|
|
@ -6780,15 +6842,6 @@
|
|||
"integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/to-fast-properties": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||
"integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
|
|
@ -7468,6 +7521,16 @@
|
|||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/vue-select": {
|
||||
"version": "4.0.0-beta.6",
|
||||
"resolved": "https://registry.npmjs.org/vue-select/-/vue-select-4.0.0-beta.6.tgz",
|
||||
"integrity": "sha512-K+zrNBSpwMPhAxYLTCl56gaMrWZGgayoWCLqe5rWwkB8aUbAUh7u6sXjIR7v4ckp2WKC7zEEUY27g6h1MRsIHw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"vue": "3.x"
|
||||
}
|
||||
},
|
||||
"node_modules/vue-template-compiler": {
|
||||
"version": "2.7.14",
|
||||
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
"@types/bootstrap": "^5.2.7",
|
||||
"@types/node": "^20.8.2",
|
||||
"@types/toastify-js": "^1.12.1",
|
||||
"@types/vue-select": "^3.16.5",
|
||||
"@vitejs/plugin-legacy": "latest",
|
||||
"@vitejs/plugin-vue": "latest",
|
||||
"@vue/compiler-sfc": "latest",
|
||||
|
|
@ -49,6 +50,7 @@
|
|||
"vite-plugin-eslint": "latest",
|
||||
"vite-plugin-stylelint": "latest",
|
||||
"vue": "latest",
|
||||
"vue-select": "^4.0.0-beta.6",
|
||||
"vue-tsc": "1.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
resources/assets/images/logo_ldc.jpg
Normal file
BIN
resources/assets/images/logo_ldc.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB |
|
|
@ -2,28 +2,30 @@
|
|||
|
||||
return [
|
||||
'classes' => [
|
||||
'user' => 'user',
|
||||
'activity_log' => 'activity log|activity logs',
|
||||
'services' => 'Services',
|
||||
'brands' => 'Brands',
|
||||
'brand' => 'Brand',
|
||||
'customers' => 'Customers',
|
||||
'questions' => 'Questions',
|
||||
'answers' => 'Answers',
|
||||
'singleoptins' => 'Single Opt-ins'
|
||||
'user' => 'user',
|
||||
'activity_log' => 'activity log|activity logs',
|
||||
'services' => 'Services',
|
||||
'brands' => 'Brands',
|
||||
'customers' => 'Customers',
|
||||
'questions' => 'Questions',
|
||||
'answers' => 'Answers',
|
||||
'singleoptins' => 'Single Opt-ins',
|
||||
'claims' => 'Claims',
|
||||
'claim_subjects' => 'Subjects',
|
||||
'claim_mail_templates' => 'Templates',
|
||||
],
|
||||
'common' => [
|
||||
'title' => 'Title',
|
||||
'name' => 'Name',
|
||||
'email' => 'Email',
|
||||
'content' => 'Content',
|
||||
'title' => 'Title',
|
||||
'name' => 'Name',
|
||||
'email' => 'Email',
|
||||
'content' => 'Content',
|
||||
'visibility' => 'Visibility',
|
||||
'published' => 'Published',
|
||||
'group' => 'Group',
|
||||
'default' => 'Default',
|
||||
'optinDate' => 'Date opt-in',
|
||||
'question' => 'Question',
|
||||
'answer' => 'Answer',
|
||||
'type' => 'Type'
|
||||
'published' => 'Published',
|
||||
'group' => 'Group',
|
||||
'default' => 'Default',
|
||||
'optinDate' => 'Date opt-in',
|
||||
'question' => 'Question',
|
||||
'answer' => 'Answer',
|
||||
'type' => 'Type',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -222,11 +222,15 @@ return [
|
|||
'year' => 'year',
|
||||
],
|
||||
'custom' => [
|
||||
'event' => 'event',
|
||||
'model' => 'target element',
|
||||
'order' => 'order',
|
||||
'publication' => 'publication',
|
||||
'activated' => 'activated',
|
||||
'target' => 'target',
|
||||
'event' => 'event',
|
||||
'model' => 'target element',
|
||||
'order' => 'order',
|
||||
'publication' => 'publication',
|
||||
'activated' => 'activated',
|
||||
'target' => 'target',
|
||||
'response_type' => 'response type',
|
||||
'reference' => 'reference',
|
||||
'type' => 'type',
|
||||
'status' => 'status',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,28 +2,30 @@
|
|||
|
||||
return [
|
||||
'classes' => [
|
||||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'services' => 'Services',
|
||||
'brands' => 'Marques',
|
||||
'brand' => 'Marque',
|
||||
'questions' => 'Questions',
|
||||
'answers' => 'Réponses',
|
||||
'customers' => 'Clients',
|
||||
'singleoptins' => 'Opt-ins uniques'
|
||||
'user' => 'utilisateur',
|
||||
'activity_log' => 'journal d\'activité|journaux d\'activité',
|
||||
'services' => 'Services',
|
||||
'brands' => 'Marques',
|
||||
'questions' => 'Questions',
|
||||
'answers' => 'Réponses',
|
||||
'customers' => 'Clients',
|
||||
'singleoptins' => 'Opt-ins uniques',
|
||||
'claims' => 'Réclamations',
|
||||
'claim_subjects' => 'Sujets',
|
||||
'claim_mail_templates' => 'Modèles',
|
||||
],
|
||||
'common' => [
|
||||
'title' => 'Titre',
|
||||
'name' => 'Nom',
|
||||
'email' => 'E-mail',
|
||||
'content' => 'Contenu',
|
||||
'title' => 'Titre',
|
||||
'name' => 'Nom',
|
||||
'email' => 'E-mail',
|
||||
'content' => 'Contenu',
|
||||
'visibility' => 'Visibilitée',
|
||||
'published' => 'Publié',
|
||||
'group' => 'Groupe',
|
||||
'default' => 'Par défaut',
|
||||
'optinDate' => 'Date opt-in',
|
||||
'question' => 'Question',
|
||||
'type' => 'Type',
|
||||
'answer' => 'Réponse'
|
||||
'published' => 'Publié',
|
||||
'group' => 'Groupe',
|
||||
'default' => 'Par défaut',
|
||||
'optinDate' => 'Date opt-in',
|
||||
'question' => 'Question',
|
||||
'type' => 'Type',
|
||||
'answer' => 'Réponse',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -222,11 +222,15 @@ return [
|
|||
'year' => 'année',
|
||||
],
|
||||
'custom' => [
|
||||
'event' => 'évènement',
|
||||
'model' => 'élément ciblé',
|
||||
'order' => 'order',
|
||||
'publication' => 'publication',
|
||||
'activated' => 'activé',
|
||||
'target' => 'cible',
|
||||
'event' => 'évènement',
|
||||
'model' => 'élément ciblé',
|
||||
'order' => 'order',
|
||||
'publication' => 'publication',
|
||||
'activated' => 'activé',
|
||||
'target' => 'cible',
|
||||
'response_type' => 'type de réponse',
|
||||
'reference' => 'référence',
|
||||
'type' => 'type',
|
||||
'status' => 'status',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -64,3 +64,11 @@ main {
|
|||
border-radius: 0 0 0.375rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
#sidebar-menu > .sticky-top {
|
||||
top: 4rem !important;
|
||||
}
|
||||
|
||||
.claim-modal-content {
|
||||
max-height: 20rem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,3 @@
|
|||
@import "./base/bootstrap-overload";
|
||||
@import "./base/fonts";
|
||||
@import "./base/common";
|
||||
|
||||
#sidebar-menu > .sticky-top {
|
||||
top: 4rem !important;
|
||||
}
|
||||
|
|
|
|||
1
resources/sass/bo/vendor/_bootstrap.scss
vendored
1
resources/sass/bo/vendor/_bootstrap.scss
vendored
|
|
@ -37,6 +37,7 @@
|
|||
@import "~/bootstrap/scss/card";
|
||||
@import "~/bootstrap/scss/breadcrumb";
|
||||
@import "~/bootstrap/scss/badge";
|
||||
@import "~/bootstrap/scss/modal";
|
||||
|
||||
// 6. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
|
||||
@import "~/bootstrap/scss/utilities/api";
|
||||
|
|
|
|||
|
|
@ -1,255 +0,0 @@
|
|||
<template>
|
||||
<div class="belongs-to-many-dropdown">
|
||||
<Transition name="fade">
|
||||
<p
|
||||
v-if="message"
|
||||
class="message"
|
||||
>
|
||||
{{ message }}
|
||||
</p>
|
||||
</Transition>
|
||||
<div class="d-inline-block tagInput w-100">
|
||||
<VueTagsInputCls
|
||||
v-model="item"
|
||||
:tags="selectedItems"
|
||||
:autocomplete-items="filteredItems"
|
||||
:autocomplete-min-length="0"
|
||||
@before-adding-tag="beforeTagSave"
|
||||
@tags-changed="changedTags"
|
||||
:max-tags="max ?? 9999"
|
||||
:placeholder="placeholder"
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
v-if="!selectedItems.length"
|
||||
:name="name"
|
||||
type="hidden"
|
||||
value=""
|
||||
>
|
||||
<template
|
||||
v-for="(sItem, index) in selectedItems"
|
||||
:key="index"
|
||||
>
|
||||
<p class="text-danger m-0">
|
||||
{{ parseValidationInput(`${name}[${String(index)}][name]`, allErrors) }}
|
||||
</p>
|
||||
<input
|
||||
:name="`${name}[${String(index)}][id]`"
|
||||
type="hidden"
|
||||
:value="sItem.id"
|
||||
>
|
||||
<input
|
||||
:name="`${name}[${String(index)}][value]`"
|
||||
type="hidden"
|
||||
:value="sItem.id"
|
||||
>
|
||||
<input
|
||||
:name="`${name}[${String(index)}][name]`"
|
||||
type="hidden"
|
||||
:value="sItem.text"
|
||||
>
|
||||
<input
|
||||
:name="`${name}[${String(index)}][label]`"
|
||||
type="hidden"
|
||||
:value="sItem.text"
|
||||
>
|
||||
<input
|
||||
:name="`${name}[${String(index)}][title]`"
|
||||
type="hidden"
|
||||
:value="sItem.text"
|
||||
>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import type VueTagsInput from "@sipec/vue3-tags-input";
|
||||
import { VueTagsInput as VueTagsInputCls } from "@sipec/vue3-tags-input";
|
||||
import slugify from "slugify";
|
||||
import { defineComponent } from "vue";
|
||||
import parseLaravelErrorMessages from "../../modules/parseLaravelErrorMessages";
|
||||
import route from "../../modules/route";
|
||||
import trans from "../../modules/trans";
|
||||
|
||||
export default defineComponent({
|
||||
name: "BelongsToManyDropdownComponent",
|
||||
mixins: [route, trans, parseLaravelErrorMessages],
|
||||
components: {
|
||||
VueTagsInputCls,
|
||||
},
|
||||
beforeMount() {
|
||||
if (!this.$attrs.json) {
|
||||
throw new Error("this component requires json");
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const json = String(this.$attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
this.name = data.name;
|
||||
this.selectedItems = this.parseTags(data.value);
|
||||
this.allItems = this.parseTags(data.itemsList);
|
||||
this.placeholder = data.placeholder;
|
||||
// * Min and max calc.
|
||||
this.min = Number.parseInt((data?.itemLimit ?? [])[0] ?? 0);
|
||||
this.min = this.min < 0 ? 0 : this.min;
|
||||
this.max = Number.parseInt((data?.itemLimit ?? [])[1] ?? 0);
|
||||
this.max = this.max <= this.min ? null : this.max;
|
||||
// * Error parsing
|
||||
this.allErrors = data.errors;
|
||||
},
|
||||
data(): {
|
||||
name: string;
|
||||
item: string;
|
||||
selectedItems: Array<CustomTag>;
|
||||
allItems: Array<CustomTag>;
|
||||
placeholder: string;
|
||||
min: number;
|
||||
max: number | null;
|
||||
fieldName: string;
|
||||
waitingListObjects: Array<VueTagsInput.IAddArgs>;
|
||||
allErrors: Record<string, Array<string>>;
|
||||
message: string | null;
|
||||
} {
|
||||
return {
|
||||
name: "",
|
||||
item: "",
|
||||
selectedItems: [],
|
||||
allItems: [],
|
||||
placeholder: "",
|
||||
min: 0,
|
||||
max: null,
|
||||
fieldName: "",
|
||||
waitingListObjects: [],
|
||||
allErrors: {},
|
||||
message: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
parseTags(selectedItems: Array<CustomTag>): Array<CustomTag> {
|
||||
return selectedItems.map((item: CustomTag) => {
|
||||
item.text = String(item.label ?? item.name ?? item.title);
|
||||
item.slug = String(item.slug ?? slugify(item.text));
|
||||
return item;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Add item
|
||||
* @param obj
|
||||
*/
|
||||
beforeTagSave(obj: VueTagsInput.IAddArgs): void {
|
||||
if (!this.max || this.selectedItems.length < this.max) {
|
||||
let customTag = this.tagExists(this.allItems, obj.tag);
|
||||
if (customTag) {
|
||||
obj.tag = customTag;
|
||||
this.selectedItems.push(customTag);
|
||||
this.item = "";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.message = this.__("Nombre d'élements maximal atteint.");
|
||||
setTimeout(() => (this.message = null), 1500);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Delete item.
|
||||
* @param newItems
|
||||
*/
|
||||
changedTags(newItems: Array<CustomTag>): void {
|
||||
// * Si on enleve un élement
|
||||
if (this.selectedItems.length > newItems.length) {
|
||||
// * On respecte la validation minimale
|
||||
if (newItems.length >= this.min) {
|
||||
this.selectedItems = newItems as Array<CustomTag>;
|
||||
} else {
|
||||
// * Non respect de la validation minimale
|
||||
this.message = this.__("Nombre d'élements minimal atteint.");
|
||||
setTimeout(() => (this.message = null), 1500);
|
||||
// * Réassignation pour forcer la valeur minimale.
|
||||
this.selectedItems = Object.assign([], this.selectedItems);
|
||||
}
|
||||
}
|
||||
},
|
||||
tagExists(
|
||||
items: Array<CustomTag>,
|
||||
tagToCheck: VueTagsInput.ITag
|
||||
): CustomTag | null {
|
||||
let customTag: CustomTag | null = null;
|
||||
items.filter((item: CustomTag) => {
|
||||
if (
|
||||
item.id === (tagToCheck as CustomTag).id ||
|
||||
item.slug === slugify(tagToCheck.text)
|
||||
) {
|
||||
customTag = item;
|
||||
}
|
||||
});
|
||||
return customTag;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
filteredItems() {
|
||||
return this.allItems.filter((i) => {
|
||||
return i.text.toLowerCase().indexOf(this.item.toLowerCase()) !== -1;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.belongs-to-many-dropdown {
|
||||
&, .vue-tags-input {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
.ti- {
|
||||
&autocomplete {
|
||||
max-height: 10rem !important;
|
||||
border-radius: 0.375rem;
|
||||
box-shadow: 0 0 4px var(--bs-gray-400);
|
||||
overflow-y: auto !important;
|
||||
ul {
|
||||
padding: 0.25rem 0 !important;
|
||||
}
|
||||
}
|
||||
&input {
|
||||
padding: 0.375rem !important;
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
&tags {
|
||||
line-height: inherit !important;
|
||||
}
|
||||
&tag,
|
||||
&new-tag-input-wrapper {
|
||||
padding: 0.1rem !important;
|
||||
margin: 0.1rem !important;
|
||||
}
|
||||
&new-tag-input-wrapper {
|
||||
font-size: 1em !important;
|
||||
input {
|
||||
min-width: 165px !important;
|
||||
}
|
||||
}
|
||||
&tag {
|
||||
padding: 0.1rem 0.3rem !important;
|
||||
background-color: var(--bs-blue) !important;
|
||||
border-radius: 0.375rem !important;
|
||||
}
|
||||
&selected-item {
|
||||
background-color: var(--bs-gray-300) !important;
|
||||
color: var(--bs-gray-900) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.message {
|
||||
color: #ff0000;
|
||||
}
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
494
resources/ts/bo/components/ClaimActionsComponent.vue
Normal file
494
resources/ts/bo/components/ClaimActionsComponent.vue
Normal file
|
|
@ -0,0 +1,494 @@
|
|||
<template>
|
||||
<table
|
||||
ref="claimActions"
|
||||
class="table table-hover m-0"
|
||||
>
|
||||
<tbody>
|
||||
<!-- Brand -->
|
||||
<tr class="border-bottom list-item">
|
||||
<td
|
||||
class="align-middle pb-3"
|
||||
colspan="2"
|
||||
v-if="canParameters.updateBrand"
|
||||
>
|
||||
<label
|
||||
for="brand"
|
||||
class="col-form-label"
|
||||
>
|
||||
<b>{{ trans.methods.__('Modifier la :model', { model: brandLabel }) }} *</b>
|
||||
</label>
|
||||
<SearchBelongsToDropdown
|
||||
id="brand"
|
||||
name="brand_id"
|
||||
:label="trans.methods.__('Modifier la :model', { model: brandLabel })"
|
||||
:model="claimModel"
|
||||
targetclass="App\Models\Brand"
|
||||
:modellistpaginate="brandModels"
|
||||
:modelselected="(selectParameters.brand as VselectOption)"
|
||||
:constructedroute="route.methods.getRoute('bo.brands.json-paginate')"
|
||||
fieldname="name"
|
||||
:multiple="false"
|
||||
:required="true"
|
||||
:disabled="loading || isTreatedClaim"
|
||||
:placeholder="trans.methods.__('Rechercher une :model', { model: brandLabel })"
|
||||
@selected-value-changed="setSelectedBrand"
|
||||
/>
|
||||
<small class="text-danger m-0">
|
||||
{{ errors.methods.parseValidationInput('brand_id', allErrors) }}
|
||||
</small>
|
||||
</td>
|
||||
<template v-else>
|
||||
<td class="align-middle fw-bold">
|
||||
{{ brandLabel }}
|
||||
</td>
|
||||
<td
|
||||
v-if="claimModel.brand"
|
||||
class="align-middle"
|
||||
>
|
||||
{{ selectParameters.brand.name }}
|
||||
</td>
|
||||
</template>
|
||||
</tr>
|
||||
<!-- Subject -->
|
||||
<tr class="border-bottom list-item">
|
||||
<td
|
||||
class="align-middle pb-3"
|
||||
colspan="2"
|
||||
v-if="canParameters.updateSubject"
|
||||
>
|
||||
<label
|
||||
for="brand"
|
||||
class="col-form-label"
|
||||
>
|
||||
<b>{{ trans.methods.__('Modifier la :model', { model: trans.methods.__("models.classes.claim_subjects") }) }} *</b>
|
||||
</label>
|
||||
<SearchBelongsToDropdown
|
||||
id="subject"
|
||||
name="subject_id"
|
||||
:label="trans.methods.__('Modifier la :model', { model: trans.methods.__('models.classes.claim_subjects') })"
|
||||
:model="claimModel"
|
||||
targetclass="App\Models\ClaimSubject"
|
||||
:modellistpaginate="claimSubjectModels"
|
||||
:modelselected="(selectParameters.subject as VselectOption)"
|
||||
:constructedroute="getClaimSubjectPaginateRoute()"
|
||||
fieldname="label"
|
||||
:nodeclass="allErrors.subject_id ? 'form-control is-invalid' : ''"
|
||||
:multiple="false"
|
||||
:required="true"
|
||||
:disabled="loading || isTreatedClaim"
|
||||
:placeholder="trans.methods.__('Rechercher une :model', { model: trans.methods.__('models.classes.claim_subjects') })"
|
||||
@selected-value-changed="setSelectedSubject"
|
||||
/>
|
||||
<small class="text-danger m-0">
|
||||
{{ errors.methods.parseValidationInput('subject_id', allErrors) }}
|
||||
</small>
|
||||
</td>
|
||||
<template v-else>
|
||||
<td class="align-middle fw-bold">
|
||||
{{ trans.methods.__("models.classes.claim_subjects") }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ selectParameters.subject?.label }}
|
||||
</td>
|
||||
</template>
|
||||
</tr>
|
||||
<!-- Enums (Type, Status, ResponseType) -->
|
||||
<tr
|
||||
v-for="(enumField, enumFieldIndex) in enumFields"
|
||||
:key="enumFieldIndex"
|
||||
class="list-item"
|
||||
:class="{'border-0': enumFieldIndex === Object.keys(enumFields).length - 1}"
|
||||
>
|
||||
<td
|
||||
class="align-middle pb-3"
|
||||
:class="{'border-0': enumFieldIndex === Object.keys(enumFields).length - 1}"
|
||||
colspan="2"
|
||||
v-if="enumField.can"
|
||||
>
|
||||
<label
|
||||
:for="enumField.name"
|
||||
class="col-form-label"
|
||||
>
|
||||
<b>{{ trans.methods.__('Modifier le :label', { label: trans.methods.__(`validation.custom.${enumField.name}`) }) }} *</b>
|
||||
</label>
|
||||
<div class="d-flex justify-content-center align-items-center">
|
||||
<select
|
||||
:id="enumField.name"
|
||||
class="form-select"
|
||||
:class="{'is-invalid': errors.methods.parseValidationInput(`${enumField.name}`, allErrors)}"
|
||||
:name="enumField.name"
|
||||
:aria-describedby="`${enumField.name}Help`"
|
||||
required="true"
|
||||
role="button"
|
||||
:disabled="loading || (enumField.name !== 'status') ? isTreatedClaim : false"
|
||||
@change="setSelectedEnum($event, enumField.name)"
|
||||
>
|
||||
<option
|
||||
v-for="(model, modelIndex) in enumField.associatedEnum"
|
||||
:key="modelIndex"
|
||||
:value="model.value"
|
||||
:selected="claimModel[enumField.name] === model.value"
|
||||
>
|
||||
{{ model.label }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
v-if="checkIsManualResponseType(enumField.name) && !isTreatedClaim"
|
||||
type="button"
|
||||
class="btn btn-primary ms-1"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#manualResponseModal"
|
||||
>
|
||||
<FontAwesomeIcon icon="fa-solid fa-comment-dots" />
|
||||
</button>
|
||||
</div>
|
||||
<small class="text-danger m-0">
|
||||
{{ errors.methods.parseValidationInput(`${enumField.name}`, allErrors) }}
|
||||
</small>
|
||||
</td>
|
||||
<template v-else>
|
||||
<td
|
||||
class="align-middle fw-bold"
|
||||
:class="{'border-0': enumFieldIndex === Object.keys(enumFields).length - 1}"
|
||||
>
|
||||
{{ ucfirst(trans.methods.__(`validation.custom.${enumField.name}`)) }}
|
||||
</td>
|
||||
<td
|
||||
class="align-middle"
|
||||
:class="{'border-0': enumFieldIndex === Object.keys(enumFields).length - 1}"
|
||||
>
|
||||
{{ Object.values(enumField.associatedEnum).find(item => item.value == selectParameters.enums[enumField.name])?.label }}
|
||||
</td>
|
||||
</template>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ClaimManualResponse
|
||||
v-if="!isTreatedClaim"
|
||||
:claim-model="claimModel"
|
||||
:is-manual-response-type="isManualResponseType"
|
||||
:claim-template-models="claimTemplateModels"
|
||||
@answer-sent="updateMessages"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, useAttrs, onMounted, ref, reactive } from "vue";
|
||||
import type { PropType } from "vue";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import errors from "./../../modules/errors";
|
||||
import trans from "./../../modules/trans";
|
||||
import route from "./../../modules/route";
|
||||
import { Tooltips } from "./../../modules/tooltips";
|
||||
import SearchBelongsToDropdown from "./SearchBelongsToDropdownComponent.vue";
|
||||
import ClaimManualResponse from "./ClaimManualResponseComponent.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "ClaimActionsComponent",
|
||||
});
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * EMITS
|
||||
const emits = defineEmits<{
|
||||
(e: "updateMessages", value: Array<LaravelModel & LaravelModelUserRelation>): void;
|
||||
}>();
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
authUserId: {
|
||||
type: Number,
|
||||
default: Math.pow(10, 16) / Math.random(),
|
||||
},
|
||||
claimModel: {
|
||||
type: Object as PropType<LaravelModel & LaravelModelClaimRelations>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
brandModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
claimSubjectModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
claimTemplateModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
enums: {
|
||||
type: Object as PropType<Record<string, Array<Enum>>>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
can: {
|
||||
type: Object as PropType<Record<string, boolean>>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isManualResponseType: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
allErrors: {
|
||||
type: Object as PropType<LaravelValidationErrors>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
});
|
||||
|
||||
// * REFS
|
||||
const claimActions = ref<HTMLDivElement|null>(null);
|
||||
|
||||
// * DATA
|
||||
const authUserId = ref<number>(props.authUserId);
|
||||
const claimModel = ref<LaravelModel & LaravelModelClaimRelations>(props.claimModel);
|
||||
const brandModels = ref<LaravelPaginator>(props.brandModels);
|
||||
const claimSubjectModels = ref<LaravelPaginator>(props.claimSubjectModels);
|
||||
const claimTemplateModels = ref<LaravelPaginator>(props.claimTemplateModels);
|
||||
const loading = ref<boolean>(props.loading);
|
||||
const isManualResponseType = ref<boolean>(props.isManualResponseType);
|
||||
const tooltips = ref<Tooltips|null>(null);
|
||||
const enumFields = ref<Record<number, {
|
||||
can: boolean,
|
||||
name: string,
|
||||
associatedEnum: Array<Enum>,
|
||||
}>>({});
|
||||
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
|
||||
|
||||
/** Enum parameters. */
|
||||
const enumParameters = reactive<{
|
||||
claimType: Array<Enum>,
|
||||
claimStatus: Array<Enum>,
|
||||
claimResponseType: Array<Enum>,
|
||||
}>({
|
||||
claimType: props.enums.claimType,
|
||||
claimStatus: props.enums.claimStatus,
|
||||
claimResponseType: props.enums.claimResponseType,
|
||||
});
|
||||
|
||||
/** Can parameters. */
|
||||
const canParameters = reactive<{
|
||||
updateBrand: boolean,
|
||||
updateSubject: boolean,
|
||||
updateType: boolean,
|
||||
updateStatus: boolean,
|
||||
updateResponseType: boolean,
|
||||
}>({
|
||||
updateBrand: props.can.updateBrand,
|
||||
updateSubject: props.can.updateSubject,
|
||||
updateType: props.can.updateType,
|
||||
updateStatus: props.can.updateStatus,
|
||||
updateResponseType: props.can.updateResponseType,
|
||||
});
|
||||
|
||||
/** Select parameters. */
|
||||
const selectParameters = reactive<{
|
||||
brand: LaravelModel,
|
||||
subject: LaravelModel|null,
|
||||
enums: Record<string,string>,
|
||||
}>({
|
||||
brand: props.claimModel.brand,
|
||||
subject: props.claimModel.claim_subject,
|
||||
enums: {
|
||||
type: String(props.claimModel.type),
|
||||
status: String(props.claimModel.status),
|
||||
response_type: String(props.claimModel.response_type),
|
||||
},
|
||||
});
|
||||
|
||||
// * COMPUTED
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
const brandLabel = computed(() => trans.methods.__("models.classes.brands").toString().replace(/s$/, ""));
|
||||
const isTreatedClaim = computed(() => Object.values(enumParameters.claimStatus).find(e => e.name === "treated")?.value == selectParameters.enums["status"]);
|
||||
|
||||
// * LIFECYCLE
|
||||
onMounted((): void => {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
if (!isUsedWithProps.value) {
|
||||
authUserId.value = data.authUserId;
|
||||
claimModel.value = data.claimModel;
|
||||
claimSubjectModels.value = data.claimSubjectModels;
|
||||
claimTemplateModels.value = data.claimTemplateModels;
|
||||
brandModels.value = data.brandModels;
|
||||
allErrors.value = data.allErrors;
|
||||
|
||||
/** Enum parameters. */
|
||||
enumParameters.claimType = data.enums.claimType;
|
||||
enumParameters.claimStatus = data.enums.claimStatus;
|
||||
enumParameters.claimResponseType = data.enums.claimResponseType;
|
||||
|
||||
/** Can parameters. */
|
||||
canParameters.updateBrand = data.can.updateBrand;
|
||||
canParameters.updateSubject = data.can.updateSubject;
|
||||
canParameters.updateType = data.can.updateType;
|
||||
canParameters.updateStatus = data.can.updateStatus;
|
||||
canParameters.updateResponseType = data.can.updateResponseType;
|
||||
|
||||
/** Select parameters. */
|
||||
selectParameters.brand = claimModel.value.brand;
|
||||
selectParameters.subject = claimModel.value.claim_subject;
|
||||
selectParameters.enums.type = String(claimModel.value.type);
|
||||
selectParameters.enums.status = String(claimModel.value.status);
|
||||
selectParameters.enums.response_type = String(claimModel.value.response_type);
|
||||
}
|
||||
/** Set enum fields. */
|
||||
enumFields.value = [
|
||||
{
|
||||
can: canParameters.updateType,
|
||||
name: "type",
|
||||
associatedEnum: enumParameters.claimType,
|
||||
},
|
||||
{
|
||||
can: canParameters.updateStatus,
|
||||
name: "status",
|
||||
associatedEnum: enumParameters.claimStatus,
|
||||
},
|
||||
{
|
||||
can: canParameters.updateResponseType,
|
||||
name: "response_type",
|
||||
associatedEnum: enumParameters.claimResponseType,
|
||||
},
|
||||
];
|
||||
initTooltips();
|
||||
});
|
||||
|
||||
/**
|
||||
* Set the selected brand.
|
||||
* @return void
|
||||
*/
|
||||
function setSelectedBrand(brandModel: VselectOption|VselectOption[]|null): void {
|
||||
selectParameters.brand = brandModel as LaravelModel;
|
||||
selectParameters.subject = null;
|
||||
fetchClaimSubjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the selected subject.
|
||||
* @return void
|
||||
*/
|
||||
function setSelectedSubject(subjectModel: VselectOption|VselectOption[]|null): void {
|
||||
selectParameters.subject = subjectModel as LaravelModel;
|
||||
delete allErrors.value.subject_id;
|
||||
updateClaimData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the selected subject.
|
||||
* @return void
|
||||
*/
|
||||
function setSelectedEnum(event: Event, field: string): void {
|
||||
const selectEnum = event.target as HTMLSelectElement|null;
|
||||
selectParameters.enums[field] = selectEnum?.value ?? "";
|
||||
delete allErrors.value[field];
|
||||
if (checkIsManualResponseType(field)) {
|
||||
isManualResponseType.value = true;
|
||||
} else {
|
||||
updateClaimData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all claim subjects from specific brand.
|
||||
* @return void
|
||||
*/
|
||||
function fetchClaimSubjects(): void {
|
||||
loading.value = true;
|
||||
window.axios
|
||||
.get(getClaimSubjectPaginateRoute())
|
||||
.then((reponse) => {
|
||||
claimSubjectModels.value = reponse.data;
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
allErrors.value = e.response?.data?.errors ?? {};
|
||||
errors.methods.ajaxErrorHandler(e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all claim subjects from specific brand.
|
||||
* @return void
|
||||
*/
|
||||
function updateClaimData(): void {
|
||||
loading.value = true;
|
||||
window.axios
|
||||
.patch(route.methods.getRoute("bo.claims.update", {
|
||||
CLAIMID: String(claimModel.value.id),
|
||||
}), {
|
||||
brand_id: selectParameters.brand.id,
|
||||
subject_id: selectParameters.subject?.id,
|
||||
type: selectParameters.enums["type"],
|
||||
status: selectParameters.enums["status"],
|
||||
response_type: selectParameters.enums["response_type"],
|
||||
})
|
||||
.then((reponse) => {
|
||||
loading.value = false;
|
||||
emits("updateMessages", reponse.data);
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
allErrors.value = e.response?.data?.errors ?? {};
|
||||
errors.methods.ajaxErrorHandler(e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the claim subject route.
|
||||
* @return string
|
||||
*/
|
||||
function getClaimSubjectPaginateRoute(): string {
|
||||
const targetRoute = "bo.claim_subjects.json-paginate";
|
||||
const fetchMessageRoute = route.methods.route(targetRoute, {
|
||||
BRANDID: String(selectParameters.brand.id),
|
||||
});
|
||||
if (!fetchMessageRoute) {
|
||||
throw new Error(`Undefined ${targetRoute}`);
|
||||
}
|
||||
return fetchMessageRoute + "?targetModel=App\\Models\\ClaimSubject&page=1&paginate=5&fieldName=label";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it's manual response when the response_type select changed.
|
||||
* @param boolean fieldName
|
||||
* @return string
|
||||
*/
|
||||
function checkIsManualResponseType(fieldName: string): boolean {
|
||||
return selectParameters.enums["response_type"] === "2" && fieldName === "response_type";
|
||||
}
|
||||
|
||||
/**
|
||||
* Event propagation to update all messages in the conversation.
|
||||
* @param Array value
|
||||
* @return void
|
||||
*/
|
||||
function updateMessages(value: Array<LaravelModel & LaravelModelUserRelation>): void {
|
||||
selectParameters.enums["status"] = "4";
|
||||
emits("updateMessages", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise all tooltips in the component.
|
||||
* @return void
|
||||
*/
|
||||
function initTooltips(): void {
|
||||
setTimeout(() => {
|
||||
tooltips.value = Tooltips.make({
|
||||
type: "dom",
|
||||
elements: claimActions.value!.querySelectorAll("[data-bs-tooltip=\"tooltip\"]")
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
*Capitalize the first letter.
|
||||
* @return string
|
||||
*/
|
||||
function ucfirst(str: string): string {
|
||||
if (!str) return "";
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
</script>
|
||||
263
resources/ts/bo/components/ClaimConversationComponent.vue
Normal file
263
resources/ts/bo/components/ClaimConversationComponent.vue
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
<template>
|
||||
<div
|
||||
class="d-flex flex-column justify-content-between align-items-center border shadow-sm rounded-3 p-3 h-100"
|
||||
ref="claimConversation"
|
||||
>
|
||||
<div
|
||||
ref="messagesWrapper"
|
||||
class="col-12 claim-messages-wrapper overflow-scroll pe-3"
|
||||
>
|
||||
<template v-if="claimMessageModels.length">
|
||||
<template
|
||||
v-for="(claimMessageModel, claimMessageModelIndex) in claimMessageModels"
|
||||
:key="claimMessageModelIndex"
|
||||
>
|
||||
<span
|
||||
v-if="shouldDisplayDate(claimMessageModelIndex)"
|
||||
:class="`date-separator d-flex flex-row justify-content-between align-items-center text-secondary fst-italic w-100 ${claimMessageModelIndex === 0 ? 'mb-4' : 'my-4'}`"
|
||||
>
|
||||
{{ formatDate(String(claimMessageModel.created_at)) }}
|
||||
</span>
|
||||
<ClaimMessageComponent
|
||||
:claim-message-model="claimMessageModel"
|
||||
:auth-user-id="authUserId"
|
||||
:loading="loading"
|
||||
@set-loading-message="setLoadingMessage"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
<div
|
||||
v-else
|
||||
class="d-flex flex-column justify-content-center align-items-center text-muted fst-italic h-100"
|
||||
>
|
||||
<FontAwesomeIcon
|
||||
icon="fa-solid fa-comment-slash"
|
||||
size="2xl"
|
||||
/>
|
||||
<p class="my-3">
|
||||
{{ trans.methods.__('Aucune activité enregistré à ce jour') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 mt-3">
|
||||
<div class="d-flex justify-content-center align-items-start">
|
||||
<textarea
|
||||
class="form-control"
|
||||
:class="{'is-invalid': errors.methods.parseValidationInput('content', allErrors)}"
|
||||
:placeholder="trans.methods.__('Votre message...')"
|
||||
name="content"
|
||||
v-model="content"
|
||||
:disabled="loading || loadingMessage"
|
||||
/>
|
||||
<button
|
||||
class="btn btn-primary ms-1"
|
||||
data-bs-tooltip="tooltip"
|
||||
type="button"
|
||||
:title="trans.methods.__('Envoyer votre message')"
|
||||
@click="storeMessage()"
|
||||
:disabled="loading || loadingMessage"
|
||||
>
|
||||
<div
|
||||
v-show="loading"
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
>
|
||||
<span class="visually-hidden">{{ trans.methods.__('Chargement...') }}</span>
|
||||
</div>
|
||||
<div v-show="!loading">
|
||||
<FontAwesomeIcon icon="fa-solid fa-paper-plane" />
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<small class="text-danger m-0">
|
||||
{{ errors.methods.parseValidationInput('content', allErrors) }}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref, nextTick, useAttrs, watch } from "vue";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import type { PropType } from "vue";
|
||||
import trans from "./../../modules/trans";
|
||||
import route from "./../../modules/route";
|
||||
import { Tooltips } from "./../../modules/tooltips";
|
||||
import errors from "./../../modules/errors";
|
||||
import ClaimMessageComponent from "./ClaimMessageComponent.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "ClaimConversationComponent"
|
||||
});
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
authUserId: {
|
||||
type: Number,
|
||||
default: Math.pow(10, 16) / Math.random(),
|
||||
},
|
||||
claimModel: {
|
||||
type: Object as PropType<LaravelModel & LaravelModelClaimRelations>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
claimMessageModels: {
|
||||
type: Object as PropType<Array<LaravelModel & LaravelModelUserRelation>>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
loadingMessage: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
allErrors: {
|
||||
type: Object as PropType<LaravelValidationErrors>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
});
|
||||
|
||||
// * REFS
|
||||
const claimConversation = ref<HTMLDivElement|null>(null);
|
||||
const messagesWrapper = ref<HTMLDivElement|null>(null);
|
||||
|
||||
// * DATA
|
||||
const authUserId = ref<number>(props.authUserId);
|
||||
const claimModel = ref<LaravelModel>(props.claimModel);
|
||||
const claimMessageModels = ref<Array<LaravelModel & LaravelModelUserRelation>>(props.claimMessageModels);
|
||||
const content = ref<string>("");
|
||||
const loading = ref<boolean>(props.loading);
|
||||
const loadingMessage = ref<boolean>(props.loadingMessage);
|
||||
const tooltips = ref<Tooltips|null>(null);
|
||||
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
|
||||
|
||||
// * COMPUTED
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
|
||||
// * LIFECYCLE
|
||||
onMounted((): void => {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
if (!isUsedWithProps.value) {
|
||||
authUserId.value = data.authUserId;
|
||||
claimModel.value = data.claimModel;
|
||||
claimMessageModels.value = data.claimMessageModels;
|
||||
allErrors.value = data.allErrors;
|
||||
}
|
||||
initTooltips();
|
||||
nextTick(() => {
|
||||
scrollToBottom();
|
||||
});
|
||||
});
|
||||
|
||||
// * WATCHERS
|
||||
watch(props, () => {
|
||||
claimMessageModels.value = props.claimMessageModels;
|
||||
nextTick(() => {
|
||||
scrollToBottom();
|
||||
});
|
||||
});
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Store a new message.
|
||||
* @return void
|
||||
*/
|
||||
function storeMessage(): void {
|
||||
loading.value = true;
|
||||
allErrors.value = {};
|
||||
window.axios
|
||||
.post(route.methods.getRoute("bo.claim_messages.store"), {
|
||||
claim_id: claimModel.value.id,
|
||||
content: content.value,
|
||||
})
|
||||
.then((reponse) => {
|
||||
loading.value = false;
|
||||
claimMessageModels.value = reponse.data;
|
||||
content.value = "";
|
||||
nextTick(() => {
|
||||
scrollToBottom();
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
allErrors.value = e.response?.data?.errors ?? {};
|
||||
errors.methods.ajaxErrorHandler(e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll the wrapper message to the bottom.
|
||||
* @return void
|
||||
*/
|
||||
function scrollToBottom(): void {
|
||||
if (messagesWrapper.value)
|
||||
messagesWrapper.value.scrollTop = messagesWrapper.value?.scrollHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the loading value component correlated to the loading message component.
|
||||
* @param boolean eventLoadingMessage
|
||||
* @return void
|
||||
*/
|
||||
function setLoadingMessage(eventLoadingMessage: boolean): void {
|
||||
loadingMessage.value = eventLoadingMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formated date.
|
||||
* @param string unformatedDate
|
||||
* @return void
|
||||
*/
|
||||
function formatDate(unformatedDate: string): string {
|
||||
const date = new Date(unformatedDate);
|
||||
return date.toLocaleDateString("fr-FR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visibility of the date separator.
|
||||
* @param number index
|
||||
*/
|
||||
function shouldDisplayDate(index: number): boolean {
|
||||
if (index === 0) return true;
|
||||
const current = new Date(String(claimMessageModels.value[index].created_at)).toDateString();
|
||||
const previous = new Date(String(claimMessageModels.value[index - 1].created_at)).toDateString();
|
||||
return current !== previous;
|
||||
}
|
||||
|
||||
/** Initialise all tooltips in the component. */
|
||||
function initTooltips(): void {
|
||||
setTimeout(() => {
|
||||
tooltips.value = Tooltips.make({
|
||||
type: "dom",
|
||||
elements: claimConversation.value!.querySelectorAll("[data-bs-tooltip=\"tooltip\"]")
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scopped>
|
||||
.claim-messages-wrapper {
|
||||
height: 24.6rem;
|
||||
}
|
||||
.date-separator {
|
||||
&::before,
|
||||
&::after {
|
||||
content: "";
|
||||
flex: 1;
|
||||
border-bottom: 1px solid #dee2e6;
|
||||
margin: 0 0.5rem;
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
271
resources/ts/bo/components/ClaimManualResponseComponent.vue
Normal file
271
resources/ts/bo/components/ClaimManualResponseComponent.vue
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
<template>
|
||||
<div
|
||||
class="modal fade"
|
||||
id="manualResponseModal"
|
||||
ref="manualResponseModal"
|
||||
tabindex="-1"
|
||||
aria-labelledby="manualResponseModalLabel"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<p
|
||||
class="modal-title fs-5"
|
||||
id="manualResponseModalLabel"
|
||||
>
|
||||
{{ trans.methods.__('Votre réponse') }}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
data-bs-dismiss="modal"
|
||||
aria-label="Close"
|
||||
/>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col-12">
|
||||
<label
|
||||
for="template"
|
||||
class="col-form-label pt-0"
|
||||
>
|
||||
<b>{{ trans.methods.__('Choisir un template') }}</b>
|
||||
</label>
|
||||
<SearchBelongsToDropdown
|
||||
id="template"
|
||||
name="template_id"
|
||||
:label="trans.methods.__('Choisir un template')"
|
||||
:model="claimModel"
|
||||
:modelselected="selectedTemplate as VselectOption"
|
||||
targetclass="App\Models\ClaimMailTemplate"
|
||||
:modellistpaginate="claimTemplateModels"
|
||||
:constructedroute="getClaimTemplatePaginateRoute()"
|
||||
fieldname="label"
|
||||
:multiple="false"
|
||||
:required="true"
|
||||
:disabled="loading"
|
||||
:placeholder="trans.methods.__('Rechercher un template', { model: trans.methods.__('models.classes.claim_mail_templates') })"
|
||||
@selected-value-changed="changeTemplate"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label
|
||||
for="message"
|
||||
class="col-form-label"
|
||||
>
|
||||
<b>{{ trans.methods.__('Votre message') }} *</b>
|
||||
</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
:class="{'is-invalid': errors.methods.parseValidationInput('content', allErrors)}"
|
||||
:placeholder="trans.methods.__('Votre message...')"
|
||||
name="content"
|
||||
v-model="message"
|
||||
:disabled="loading"
|
||||
rows="10"
|
||||
/>
|
||||
<small class="text-danger m-0">
|
||||
{{ errors.methods.parseValidationInput('content', allErrors) }}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary"
|
||||
data-bs-dismiss="modal"
|
||||
>
|
||||
{{ trans.methods.__('Fermer') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
data-bs-tooltip="tooltip"
|
||||
:title="trans.methods.__('Envoyer votre réponse')"
|
||||
@click="sendResponse()"
|
||||
:disabled="loading"
|
||||
>
|
||||
<div
|
||||
v-show="loading"
|
||||
class="spinner-border spinner-border-sm"
|
||||
role="status"
|
||||
>
|
||||
<span class="visually-hidden">{{ trans.methods.__('Chargement...') }}</span>
|
||||
</div>
|
||||
<div v-show="!loading">
|
||||
{{ trans.methods.__('Envoyer votre réponse') }}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, useAttrs, onMounted, ref, watch } from "vue";
|
||||
import type { PropType } from "vue";
|
||||
import { Modal } from "bootstrap";
|
||||
import errors from "./../../modules/errors";
|
||||
import trans from "./../../modules/trans";
|
||||
import route from "./../../modules/route";
|
||||
import { Tooltips } from "./../../modules/tooltips";
|
||||
import SearchBelongsToDropdown from "./SearchBelongsToDropdownComponent.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "ClaimWrapperComponent",
|
||||
});
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * EMITS
|
||||
const emits = defineEmits<{
|
||||
(e: "answerSent", value: Array<LaravelModel & LaravelModelUserRelation>): void;
|
||||
}>();
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
claimModel: {
|
||||
type: Object as PropType<LaravelModel & LaravelModelClaimRelations>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
claimTemplateModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
message: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
selectedTemplate: {
|
||||
type: Object as PropType<LaravelModel|null>,
|
||||
default: null,
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isManualResponseType: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
allErrors: {
|
||||
type: Object as PropType<LaravelValidationErrors>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
});
|
||||
|
||||
// * REFS
|
||||
const manualResponseModal = ref<HTMLDivElement|null>(null);
|
||||
|
||||
// * DATA
|
||||
const claimModel = ref<LaravelModel & LaravelModelClaimRelations>(props.claimModel);
|
||||
const claimTemplateModels = ref<LaravelPaginator>(props.claimTemplateModels);
|
||||
const bootstrapModal = ref<Modal|null>(null);
|
||||
const message = ref<string>(props.message);
|
||||
const selectedTemplate = ref<LaravelModel|null>(props.selectedTemplate);
|
||||
const loading = ref<boolean>(props.loading);
|
||||
const isManualResponseType = ref<boolean>(props.isManualResponseType);
|
||||
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
|
||||
const tooltips = ref<Tooltips|null>(null);
|
||||
|
||||
// * COMPUTED
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
|
||||
// * LIFECYCLE
|
||||
onMounted((): void => {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
if (!isUsedWithProps.value) {
|
||||
claimModel.value = data.claimModel;
|
||||
claimTemplateModels.value = data.claimTemplateModels;
|
||||
message.value = data.message;
|
||||
selectedTemplate.value = data.selectedTemplate;
|
||||
loading.value = data.loading;
|
||||
isManualResponseType.value = data.isManualResponseType;
|
||||
allErrors.value = data.allErrors;
|
||||
}
|
||||
bootstrapModal.value = new Modal("#manualResponseModal", {});
|
||||
initTooltips();
|
||||
});
|
||||
|
||||
// * WATCHERS
|
||||
watch(props, () => {
|
||||
isManualResponseType.value = props.isManualResponseType;
|
||||
if (isManualResponseType.value) {
|
||||
bootstrapModal.value?.show();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Change the template of the content.
|
||||
* @param VselectOption|VselectOption[]|null templateModel
|
||||
* @return void
|
||||
*/
|
||||
function changeTemplate(templateModel: VselectOption|VselectOption[]|null): void {
|
||||
if (templateModel !== null) {
|
||||
selectedTemplate.value = templateModel as LaravelModel;
|
||||
message.value = String(selectedTemplate.value.content);
|
||||
allErrors.value = {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the manual response.
|
||||
* @return void
|
||||
*/
|
||||
function sendResponse(): void {
|
||||
loading.value = true;
|
||||
window.axios
|
||||
.post(route.methods.getRoute("bo.claims.answer", {
|
||||
CLAIMID: String(claimModel.value.id),
|
||||
}), {
|
||||
claim_id: claimModel.value.id,
|
||||
content: message.value,
|
||||
})
|
||||
.then((reponse) => {
|
||||
message.value = "";
|
||||
selectedTemplate.value = null;
|
||||
allErrors.value = {};
|
||||
loading.value = false;
|
||||
emits("answerSent", reponse.data);
|
||||
bootstrapModal.value?.hide();
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
allErrors.value = e.response?.data?.errors ?? {};
|
||||
errors.methods.ajaxErrorHandler(e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the claim template route.
|
||||
* @return string
|
||||
*/
|
||||
function getClaimTemplatePaginateRoute(): string {
|
||||
const targetRoute = "bo.claim_mail_templates.json-paginate";
|
||||
const fetchMessageRoute = route.methods.route(targetRoute, {
|
||||
BRANDID: String(claimModel.value.brand.id),
|
||||
});
|
||||
if (!fetchMessageRoute) {
|
||||
throw new Error(`Undefined ${targetRoute}`);
|
||||
}
|
||||
return fetchMessageRoute + "?targetModel=App\\Models\\ClaimMailTemplate&page=1&paginate=5&fieldName=label";
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise all tooltips in the component.
|
||||
* @return void
|
||||
*/
|
||||
function initTooltips(): void {
|
||||
setTimeout(() => {
|
||||
tooltips.value = Tooltips.make({
|
||||
type: "dom",
|
||||
elements: manualResponseModal.value!.querySelectorAll("[data-bs-tooltip=\"tooltip\"]")
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
98
resources/ts/bo/components/ClaimMessageCollapseComponent.vue
Normal file
98
resources/ts/bo/components/ClaimMessageCollapseComponent.vue
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<template>
|
||||
<div class="expandable-text">
|
||||
<div
|
||||
ref="textRef"
|
||||
class="text-content"
|
||||
:class="{ 'expanded overflow-scroll': expanded, 'overflow-hidden': !expanded }"
|
||||
:style="expanded ? {} : { maxHeight: collapsedHeight + 'px' }"
|
||||
>
|
||||
{{ text }}
|
||||
</div>
|
||||
<button
|
||||
v-if="needsToggle"
|
||||
class="btn btn-sm btn-link toggle-button p-0"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
{{ expanded ? trans.methods.__('Voir moins') : trans.methods.__('Voir plus') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted, useAttrs, watch, computed, nextTick } from "vue";
|
||||
import trans from "./../../modules/trans";
|
||||
|
||||
defineOptions({
|
||||
name: "ClaimMessageCollapseComponent",
|
||||
});
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
message: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
lineHeight: {
|
||||
type: Number,
|
||||
default: 24,
|
||||
},
|
||||
collapsedLines: {
|
||||
type: Number,
|
||||
default: 2,
|
||||
},
|
||||
});
|
||||
|
||||
// * REFS
|
||||
const textRef = ref<HTMLElement | null>(null);
|
||||
|
||||
// * DATA
|
||||
const text = ref<string>(props.message);
|
||||
const lineHeight = ref<number>(props.lineHeight);
|
||||
const collapsedLines = ref<number>(props.collapsedLines);
|
||||
const expanded = ref(false);
|
||||
const needsToggle = ref(false);
|
||||
|
||||
// * COMPUTED
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
const collapsedHeight = computed(() => lineHeight.value * collapsedLines.value);
|
||||
|
||||
const checkOverflow = () => {
|
||||
if (textRef.value) {
|
||||
needsToggle.value = textRef.value.scrollHeight > collapsedHeight.value;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
if (!isUsedWithProps.value) {
|
||||
text.value = data.message;
|
||||
}
|
||||
nextTick(() => {
|
||||
checkOverflow();
|
||||
});
|
||||
});
|
||||
|
||||
watch(() => text, () => {
|
||||
nextTick(() => {
|
||||
checkOverflow();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.expandable-text {
|
||||
.text-content {
|
||||
transition: max-height 0.3s ease-out;
|
||||
white-space: pre-wrap;
|
||||
max-height: 0;
|
||||
}
|
||||
|
||||
.text-content.expanded {
|
||||
max-height: 20rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
346
resources/ts/bo/components/ClaimMessageComponent.vue
Normal file
346
resources/ts/bo/components/ClaimMessageComponent.vue
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
<template>
|
||||
<div
|
||||
ref="claimMessage"
|
||||
:class="`${!isSystemMessage ? isAuthenticableUser ? 'auth-user-message' : 'other-message' : 'automatic-message'} d-flex flex-column justify-content-center mb-2`"
|
||||
>
|
||||
<div class="message-wrapper d-flex align-items-center w-100">
|
||||
<!-- BTN VALID UPDATING -->
|
||||
<div v-if="loading">
|
||||
<div
|
||||
class="spinner-border spinner-border-sm me-2"
|
||||
role="status"
|
||||
>
|
||||
<span class="visually-hidden">{{ trans.methods.__('Chargement...') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="!loading && isAuthenticableUser"
|
||||
class="d-flex flex-column justify-content-center align-items-center me-1"
|
||||
>
|
||||
<!-- SET UPDATING MODE -->
|
||||
<button
|
||||
v-if="!updating"
|
||||
class="btn btn-sm btn-outline-primary border-0 d-flex align-items-center justify-content-center"
|
||||
data-bs-tooltip="tooltip"
|
||||
type="button"
|
||||
:title="trans.methods.__('Modifier votre message')"
|
||||
@click="setUpdatingMode(true)"
|
||||
:disabled="loading"
|
||||
>
|
||||
<FontAwesomeIcon icon="fa-solid fa-pencil" />
|
||||
</button>
|
||||
<button
|
||||
v-if="updating"
|
||||
class="btn btn-sm btn-success border-0 d-flex align-items-center justify-content-center mb-1"
|
||||
data-bs-tooltip="tooltip"
|
||||
type="button"
|
||||
:title="trans.methods.__('Valider la modification')"
|
||||
@click="updateMessage"
|
||||
:disabled="loading"
|
||||
>
|
||||
<FontAwesomeIcon icon="fa-solid fa-check" />
|
||||
</button>
|
||||
<!-- BTN CANCEL UPDATING -->
|
||||
<button
|
||||
v-if="updating"
|
||||
class="btn btn-sm btn-danger border-0 d-flex align-items-center justify-content-center"
|
||||
data-bs-tooltip="tooltip"
|
||||
type="button"
|
||||
:title="trans.methods.__('Annuler la modification')"
|
||||
@click="setUpdatingMode(false)"
|
||||
:disabled="loading"
|
||||
>
|
||||
<FontAwesomeIcon icon="fa-solid fa-xmark" />
|
||||
</button>
|
||||
</div>
|
||||
<!-- MESSAGE CONTENT -->
|
||||
<div :class="`message-content text-${isAuthenticableUser ? 'white' : 'dark'} text-break shadow-sm rounded-2 p-2 ${updating ? 'w-100' : 'w-fit'}`">
|
||||
<template v-if="!updating">
|
||||
<p
|
||||
class="m-0"
|
||||
:class="{ 'px-4': isSystemMessage }"
|
||||
v-html="claimMessageModelContent"
|
||||
/>
|
||||
</template>
|
||||
<textarea
|
||||
v-if="updating && !isSystemMessage"
|
||||
ref="messageTextarea"
|
||||
class="form-control"
|
||||
:class="{'is-invalid': errors.methods.parseValidationInput('content', allErrors)}"
|
||||
v-model="claimMessageModelContent"
|
||||
:disabled="loading"
|
||||
/>
|
||||
<small
|
||||
v-if="Object.keys(allErrors).length"
|
||||
class="text-danger bg-white rounded-2 px-1 m-0"
|
||||
>
|
||||
{{ errors.methods.parseValidationInput('content', allErrors) }}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<small class="message-details d-flex flex-column flex-lg-row text-secondary fst-italic">
|
||||
<span v-if="isSystemMessage">
|
||||
{{ trans.methods.__('Message système à :date', {
|
||||
date: getFormatedTime(String(claimMessageModel.created_at)),
|
||||
}) }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ trans.methods.__(':user à :date', {
|
||||
user: claimMessageModel.user ? `${claimMessageModel.user?.first_name} ${claimMessageModel.user?.last_name}` : trans.methods.__('Utilisateur supprimé'),
|
||||
date: getFormatedTime(String(claimMessageModel.created_at)),
|
||||
}) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="isAuthenticableUser && (showDates || claimMessageModel.created_at !== claimMessageModel.updated_at)"
|
||||
class="ms-1"
|
||||
>
|
||||
{{ trans.methods.__('- Mis à jour le :date', {
|
||||
date: getFormatedDate(String(showDates ? new Date() : claimMessageModel.updated_at)),
|
||||
}) }}
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, ref, nextTick, useAttrs } from "vue";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import type { PropType } from "vue";
|
||||
import errors from "./../../modules/errors";
|
||||
import route from "./../../modules/route";
|
||||
import trans from "./../../modules/trans";
|
||||
import { Tooltips } from "./../../modules/tooltips";
|
||||
|
||||
defineOptions({
|
||||
name: "ClaimMessageComponent"
|
||||
});
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * EMITS
|
||||
const emits = defineEmits<{
|
||||
(e: "setLoadingMessage", value: boolean): void;
|
||||
}>();
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
authUserId: {
|
||||
type: Number,
|
||||
default: Math.pow(10, 16) / Math.random(),
|
||||
},
|
||||
claimMessageModel: {
|
||||
type: Object as PropType<LaravelModel & LaravelModelUserRelation>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
updating: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
showDates: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
allErrors: {
|
||||
type: Object as PropType<LaravelValidationErrors>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
});
|
||||
|
||||
// * REFS
|
||||
const claimMessage = ref<HTMLDivElement|null>(null);
|
||||
const messageTextarea = ref<HTMLElement|null>(null);
|
||||
|
||||
// * DATA
|
||||
const authUserId = ref<number>(props.authUserId);
|
||||
const claimMessageModel = ref<LaravelModel & LaravelModelUserRelation>(props.claimMessageModel);
|
||||
const claimMessageModelContent = ref<string>(String(props.claimMessageModel.content ?? ""));
|
||||
const loading = ref<boolean>(props.loading);
|
||||
const updating = ref<boolean>(props.updating);
|
||||
const showDates = ref<boolean>(props.showDates);
|
||||
const tooltips = ref<Tooltips|null>(null);
|
||||
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
|
||||
const MessageType = {
|
||||
auto: 1,
|
||||
human: 2,
|
||||
};
|
||||
|
||||
// * COMPUTED
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
const isAuthenticableUser = computed<boolean>(() => claimMessageModel.value.user !== null && claimMessageModel.value.user.id === authUserId.value);
|
||||
const isSystemMessage = computed<boolean>(() => claimMessageModel.value.type === MessageType.auto);
|
||||
|
||||
// * LIFECYCLE
|
||||
onMounted((): void => {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
if (!isUsedWithProps.value) {
|
||||
authUserId.value = data.authUserId;
|
||||
claimMessageModel.value = data.claimMessageModel;
|
||||
claimMessageModelContent.value = String(claimMessageModel.value.content ?? "");
|
||||
loading.value = data.loading;
|
||||
updating.value = data.updating;
|
||||
allErrors.value = data.allErrors;
|
||||
}
|
||||
initTooltips();
|
||||
});
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Update the message.
|
||||
* @return void
|
||||
*/
|
||||
function updateMessage(): void {
|
||||
// Check if there is no changes.
|
||||
if (claimMessageModelContent.value.trim() === claimMessageModel.value.content) {
|
||||
claimMessageModelContent.value = claimMessageModelContent.value.trim();
|
||||
updating.value = false;
|
||||
nextTick(() => {
|
||||
tooltips.value?.closeBootstrapTooltip();
|
||||
initTooltips();
|
||||
});
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
allErrors.value = {};
|
||||
emits("setLoadingMessage", loading.value);
|
||||
window.axios
|
||||
.patch(route.methods.getRoute("bo.claim_messages.update", {
|
||||
CLAIMMESSAGEID: String(claimMessageModel.value.id),
|
||||
}), {
|
||||
claim_message_id: claimMessageModel.value.id,
|
||||
content: claimMessageModelContent.value,
|
||||
})
|
||||
.then(() => {
|
||||
updating.value = false;
|
||||
loading.value = false;
|
||||
showDates.value = true;
|
||||
nextTick(() => {
|
||||
messageTextarea.value?.focus();
|
||||
tooltips.value?.closeBootstrapTooltip();
|
||||
initTooltips();
|
||||
});
|
||||
emits("setLoadingMessage", loading.value);
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
emits("setLoadingMessage", loading.value);
|
||||
allErrors.value = e.response?.data?.errors ?? {};
|
||||
errors.methods.ajaxErrorHandler(e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the updating mode.
|
||||
* @return void
|
||||
*/
|
||||
function setUpdatingMode(value: boolean): void {
|
||||
updating.value = value;
|
||||
claimMessageModelContent.value = String(claimMessageModel.value.content);
|
||||
if (!updating.value) {
|
||||
allErrors.value = {};
|
||||
}
|
||||
nextTick(() => {
|
||||
messageTextarea.value?.focus();
|
||||
tooltips.value?.closeBootstrapTooltip();
|
||||
initTooltips();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formated date.
|
||||
* @return string
|
||||
*/
|
||||
function getFormatedDate(unformatedDate: string): string {
|
||||
const date = new Date(unformatedDate);
|
||||
|
||||
return new Intl.DateTimeFormat("fr-FR", {
|
||||
weekday: "long",
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formated date.
|
||||
* @return string
|
||||
*/
|
||||
function getFormatedTime(unformatedTime: string): string {
|
||||
const date = new Date(unformatedTime);
|
||||
|
||||
return new Intl.DateTimeFormat("fr-FR", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
/** Initialise all tooltips in the component. */
|
||||
function initTooltips(): void {
|
||||
setTimeout(() => {
|
||||
tooltips.value = Tooltips.make({
|
||||
type: "dom",
|
||||
elements: claimMessage.value!.querySelectorAll("[data-bs-tooltip=\"tooltip\"]")
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.message-content {
|
||||
max-width: 70%;
|
||||
p {
|
||||
white-space: pre-line;
|
||||
}
|
||||
}
|
||||
.other-message {
|
||||
align-items: flex-start;
|
||||
.message-wrapper, {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.message-details {
|
||||
align-items: flex-start;
|
||||
}
|
||||
.message-content {
|
||||
background-color: #e6e6e6;
|
||||
border-bottom-left-radius: 0 !important;
|
||||
}
|
||||
}
|
||||
.auth-user-message {
|
||||
align-items: flex-end;
|
||||
.message-wrapper {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.message-details {
|
||||
align-items: flex-end;
|
||||
}
|
||||
.message-content {
|
||||
background-color: #3f3f3f;
|
||||
border-bottom-right-radius: 0 !important;
|
||||
}
|
||||
}
|
||||
.automatic-message {
|
||||
align-items: center;
|
||||
.message-wrapper {
|
||||
justify-content: center;
|
||||
}
|
||||
.message-details {
|
||||
align-items: center;
|
||||
}
|
||||
.message-content {
|
||||
background-color: #ffcb00;
|
||||
width: 70%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
.btn-sm {
|
||||
width: 30px !important;
|
||||
}
|
||||
</style>
|
||||
123
resources/ts/bo/components/ClaimWrapperComponent.vue
Normal file
123
resources/ts/bo/components/ClaimWrapperComponent.vue
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<template>
|
||||
<div
|
||||
class="row w-100 mx-auto"
|
||||
v-if="dataReady"
|
||||
>
|
||||
<div class="col-12 col-xl-4 mb-3 mb-md-0">
|
||||
<ClaimActions
|
||||
:auth-user-id="authUserId"
|
||||
:claim-model="claimModel"
|
||||
:brand-models="brandModels"
|
||||
:claim-subject-models="claimSubjectModels"
|
||||
:claim-template-models="claimTemplateModels"
|
||||
:enums="enums"
|
||||
:can="can"
|
||||
:all-errors="allErrors"
|
||||
@update-messages="udpateMessages"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-12 col-xl-8">
|
||||
<ClaimConversation
|
||||
:auth-user-id="authUserId"
|
||||
:claim-model="claimModel"
|
||||
:claim-message-models="claimMessageModels"
|
||||
:all-errors="allErrors"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, useAttrs, onMounted, ref } from "vue";
|
||||
import type { PropType } from "vue";
|
||||
import ClaimActions from "./ClaimActionsComponent.vue";
|
||||
import ClaimConversation from "./ClaimConversationComponent.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "ClaimWrapperComponent",
|
||||
});
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
authUserId: {
|
||||
type: Number,
|
||||
default: Math.pow(10, 16) / Math.random(),
|
||||
},
|
||||
claimModel: {
|
||||
type: Object as PropType<LaravelModel & LaravelModelClaimRelations>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
brandModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
claimSubjectModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
claimTemplateModels: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
claimMessageModels: {
|
||||
type: Object as PropType<Array<LaravelModel & LaravelModelUserRelation>>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
enums: {
|
||||
type: Object as PropType<Record<string, Array<Enum>>>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
can: {
|
||||
type: Object as PropType<Record<string, boolean>>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
allErrors: {
|
||||
type: Object as PropType<LaravelValidationErrors>,
|
||||
default: () => { return {}; },
|
||||
},
|
||||
});
|
||||
|
||||
// * DATA
|
||||
const dataReady = ref(false);
|
||||
const authUserId = ref<number>(props.authUserId);
|
||||
const claimModel = ref<LaravelModel & LaravelModelClaimRelations>(props.claimModel);
|
||||
const brandModels = ref<LaravelPaginator>(props.brandModels);
|
||||
const claimSubjectModels = ref<LaravelPaginator>(props.claimSubjectModels);
|
||||
const claimTemplateModels = ref<LaravelPaginator>(props.claimTemplateModels);
|
||||
const claimMessageModels = ref<Array<LaravelModel & LaravelModelUserRelation>>(props.claimMessageModels);
|
||||
const enums = ref<Record<string,Array<Enum>>>(props.enums);
|
||||
const can = ref<Record<string,boolean>>(props.can);
|
||||
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
|
||||
|
||||
// * COMPUTED
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
|
||||
// * LIFECYCLE
|
||||
onMounted((): void => {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
if (!isUsedWithProps.value) {
|
||||
authUserId.value = data.authUserId;
|
||||
claimModel.value = data.claimModel;
|
||||
claimSubjectModels.value = data.claimSubjectModels;
|
||||
claimTemplateModels.value = data.claimTemplateModels;
|
||||
claimMessageModels.value = data.claimMessageModels;
|
||||
brandModels.value = data.brandModels;
|
||||
enums.value = data.enums;
|
||||
can.value = data.can;
|
||||
allErrors.value = data.allErrors;
|
||||
}
|
||||
dataReady.value = true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Updae conversation messages.
|
||||
* @return void
|
||||
*/
|
||||
function udpateMessages(messagesList: typeof claimMessageModels.value): void {
|
||||
claimMessageModels.value = messagesList;
|
||||
}
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load diff
504
resources/ts/bo/components/SearchBelongsToDropdownComponent.vue
Normal file
504
resources/ts/bo/components/SearchBelongsToDropdownComponent.vue
Normal file
|
|
@ -0,0 +1,504 @@
|
|||
<template>
|
||||
<div
|
||||
ref="searchBelongsToDropdown"
|
||||
class="position-relative"
|
||||
>
|
||||
<!-- VUE SELECT -->
|
||||
<VueSelect
|
||||
:id="id"
|
||||
:loading="loading"
|
||||
v-model="modelSelected"
|
||||
:multiple="selectParameters.multiple"
|
||||
:clearable="!selectParameters.required"
|
||||
:label="selectParameters.fieldName"
|
||||
@search="search"
|
||||
:options="modelParameters.list"
|
||||
:selectable="(option: VselectOption) =>
|
||||
(modelSelected !== null)
|
||||
? (Array.isArray(modelSelected))
|
||||
? (selectParameters.limits !== null && modelSelected.length >= selectParameters.limits[1])
|
||||
? false
|
||||
: !modelSelected.includes(option)
|
||||
: modelSelected.id !== option.id
|
||||
: true"
|
||||
:filterable="true"
|
||||
:required="selectParameters.required"
|
||||
:disabled="selectParameters.disabled"
|
||||
:searchable="true"
|
||||
:placeholder="selectParameters.placeholder"
|
||||
:close-on-select="!selectParameters.multiple"
|
||||
>
|
||||
<template #no-options>
|
||||
<p class="vs__no-options m-0">
|
||||
{{ trans.methods.__('Aucun éléments trouvés') }}
|
||||
</p>
|
||||
</template>
|
||||
<template #list-footer>
|
||||
<ul
|
||||
class="pagination d-flex p-2"
|
||||
v-if="pageParameters.totalPage > 1"
|
||||
>
|
||||
<li class="page-item">
|
||||
<button
|
||||
type="button"
|
||||
@click="updatePage(pageParameters.page - 1)"
|
||||
:disabled="!pageParameters.hasPrevPage"
|
||||
class="page-link"
|
||||
:class="{'disabled': pageParameters.page === 1}"
|
||||
>
|
||||
<FontAwesomeIcon icon="fa-solid fa-chevron-left fa-2xs" />
|
||||
</button>
|
||||
</li>
|
||||
<li
|
||||
class="page-item"
|
||||
v-for="(page, pageIndex) in pageParameters.totalPage"
|
||||
:key="pageIndex"
|
||||
>
|
||||
<button
|
||||
@click="updatePage(page)"
|
||||
class="page-link btn rounded-0"
|
||||
:class="{'bg-primary text-white border-primary': pageParameters.page === page}"
|
||||
type="button"
|
||||
>
|
||||
{{ page }}
|
||||
</button>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<button
|
||||
type="button"
|
||||
@click="updatePage(pageParameters.page + 1)"
|
||||
:disabled="!pageParameters.hasNextPage"
|
||||
class="page-link"
|
||||
:class="{'disabled': pageParameters.page === pageParameters.totalPage}"
|
||||
>
|
||||
<FontAwesomeIcon icon="fa-solid fa-chevron-right fa-2xs" />
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template #open-indicator>
|
||||
<span class="dropdown-toggle" />
|
||||
</template>
|
||||
<template #spinner>
|
||||
<div
|
||||
v-if="loading"
|
||||
class="spinner-border text-secondary ms-1"
|
||||
role="status"
|
||||
>
|
||||
<span class="visually-hidden">{{ trans.methods.__('Chargement...') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</VueSelect>
|
||||
<!-- OUTPUT HTML INPUT -->
|
||||
<template
|
||||
v-if="Array.isArray(modelSelected) && modelSelected !== null"
|
||||
>
|
||||
<input
|
||||
v-for="(selectedId, selectedIndex) in modelSelected"
|
||||
:key="selectedIndex"
|
||||
:value="selectedId.id"
|
||||
:name="name + '[][id]'"
|
||||
type="hidden"
|
||||
>
|
||||
</template>
|
||||
<input
|
||||
v-else
|
||||
:value="modelSelected?.id"
|
||||
:name="name"
|
||||
type="hidden"
|
||||
>
|
||||
<!-- MESSAGES -->
|
||||
<Transition name="fade">
|
||||
<p
|
||||
v-show="message"
|
||||
class="message text-danger mb-1"
|
||||
>
|
||||
{{ message }}
|
||||
</p>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import type { PropType } from "vue";
|
||||
import { computed, nextTick, onMounted, reactive, ref, useAttrs, watch } from "vue";
|
||||
import VueSelect from "vue-select";
|
||||
import trans from "./../../modules/trans";
|
||||
import errors from "./../../modules/errors";
|
||||
|
||||
defineOptions({
|
||||
name: "SearchBelongsToDropdown",
|
||||
});
|
||||
|
||||
// * EMITS
|
||||
const emits = defineEmits<{
|
||||
"selected-value-changed": [VselectOption|VselectOption[]|null],
|
||||
}>();
|
||||
|
||||
// * ATTRIBUTES
|
||||
const attrs = useAttrs();
|
||||
|
||||
// * REFS
|
||||
const searchBelongsToDropdown = ref<HTMLDivElement|null>(null);
|
||||
|
||||
// * PROPS
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
default: String(Math.pow(10, 16) / Math.random()),
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
fieldname: {
|
||||
type: String,
|
||||
default: "name",
|
||||
},
|
||||
targetclass: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
modellistpaginate: {
|
||||
type: Object as PropType<LaravelPaginator>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
modelselected: {
|
||||
type: Object as PropType<VselectOption|VselectOption[]|null>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
limits: {
|
||||
type: Object as PropType<Array<number>|null>,
|
||||
default: null,
|
||||
},
|
||||
required: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
nodeclass: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
constructedroute: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
allErrors: {
|
||||
type: Object as PropType<LaravelValidationErrors>,
|
||||
default: () => { return []; },
|
||||
},
|
||||
});
|
||||
|
||||
// * DATA
|
||||
const id = ref<string>(props.id);
|
||||
const name = ref<string>(props.name);
|
||||
const message = ref<string>("");
|
||||
const loading = ref<boolean>(false);
|
||||
const nodeClass = ref<string>(props.nodeclass);
|
||||
const searchText = ref<string|null>(null);
|
||||
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
|
||||
|
||||
/** Model parameters. */
|
||||
const modelParameters = reactive<{
|
||||
targetClass: string,
|
||||
list: LaravelModelList,
|
||||
}>({
|
||||
targetClass: props.targetclass,
|
||||
list: props.modellistpaginate.data,
|
||||
});
|
||||
/** Exclude from modelParameters to emit an event on update */
|
||||
const modelSelected = ref<VselectOption|VselectOption[]|null>(props.modelselected);
|
||||
|
||||
/** Select parameters. */
|
||||
const selectParameters = reactive<{
|
||||
limits: Array<number>|null,
|
||||
multiple: boolean,
|
||||
required: boolean,
|
||||
disabled: boolean,
|
||||
placeholder: string,
|
||||
fieldName: string,
|
||||
}>({
|
||||
limits: props.limits,
|
||||
multiple: props.multiple,
|
||||
required: props.required,
|
||||
disabled: props.disabled,
|
||||
placeholder: props.placeholder,
|
||||
fieldName: props.fieldname,
|
||||
});
|
||||
|
||||
/** Page parameters. */
|
||||
const pageParameters = reactive<{
|
||||
page: number,
|
||||
totalPage: number,
|
||||
itemPerPage: number,
|
||||
hasNextPage: boolean,
|
||||
hasPrevPage: boolean,
|
||||
constructedRoute: string,
|
||||
}>({
|
||||
page: props.modellistpaginate.current_page,
|
||||
totalPage: props.modellistpaginate.last_page,
|
||||
itemPerPage: props.modellistpaginate.per_page,
|
||||
hasPrevPage: false,
|
||||
hasNextPage: false,
|
||||
constructedRoute: props.constructedroute,
|
||||
});
|
||||
|
||||
const isUsedWithProps = computed<boolean>(() => attrs.json === undefined);
|
||||
|
||||
// * LIFECYCLE
|
||||
onMounted(() => {
|
||||
if (!isUsedWithProps.value) {
|
||||
const json = String(attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
/** Model parameters. */
|
||||
modelParameters.targetClass = data.targetClass;
|
||||
modelParameters.list = data.modelListPaginate.data;
|
||||
nextTick(() => {
|
||||
modelSelected.value = data.modelSelected;
|
||||
});
|
||||
/** Select parameters. */
|
||||
selectParameters.limits = data.limits;
|
||||
selectParameters.multiple = Boolean(data.multiple);
|
||||
selectParameters.required = Boolean(data.required);
|
||||
selectParameters.disabled = Boolean(data.disabled);
|
||||
selectParameters.placeholder = String(data.placeholder);
|
||||
selectParameters.fieldName = String(data.fieldName);
|
||||
/** Page parameters. */
|
||||
pageParameters.page = data.modelListPaginate.current_page;
|
||||
pageParameters.totalPage = data.modelListPaginate.last_page;
|
||||
pageParameters.itemPerPage = data.modelListPaginate.per_page;
|
||||
pageParameters.hasPrevPage = false,
|
||||
pageParameters.hasNextPage = false,
|
||||
pageParameters.constructedRoute = String(data.constructedRoute);
|
||||
/** Other parameters. */
|
||||
id.value = String(data.id);
|
||||
name.value = String(data.name);
|
||||
allErrors.value = data.allErrors;
|
||||
}
|
||||
customNodes();
|
||||
updateButtonStatus();
|
||||
});
|
||||
|
||||
// * WATCHERS
|
||||
|
||||
watch(props, () => {
|
||||
/** Model parameters. */
|
||||
modelParameters.list = props.modellistpaginate.data;
|
||||
modelSelected.value = props.modelselected;
|
||||
|
||||
/** Select parameters. */
|
||||
selectParameters.disabled = props.disabled;
|
||||
selectParameters.placeholder = props.placeholder;
|
||||
|
||||
/** Page parameters. */
|
||||
pageParameters.page = props.modellistpaginate.current_page;
|
||||
pageParameters.totalPage = props.modellistpaginate.last_page;
|
||||
pageParameters.itemPerPage = props.modellistpaginate.per_page;
|
||||
pageParameters.constructedRoute = props.constructedroute;
|
||||
|
||||
/** Need this to apply node class changes. */
|
||||
nodeClass.value = props.nodeclass;
|
||||
customNodes();
|
||||
});
|
||||
|
||||
watch(modelSelected, () => {
|
||||
emits("selected-value-changed", modelSelected.value);
|
||||
if (
|
||||
modelSelected.value !== null &&
|
||||
selectParameters.limits !== null &&
|
||||
Array.isArray(modelSelected.value)
|
||||
) {
|
||||
message.value = (modelSelected.value.length < selectParameters.limits[0]) ?
|
||||
trans.methods.__(`Minimum ${selectParameters.limits[0]} requis`) :
|
||||
"";
|
||||
message.value = (modelSelected.value.length > selectParameters.limits[1]) ?
|
||||
trans.methods.__(`Maxmimum ${selectParameters.limits[1]} requis`) :
|
||||
"";
|
||||
}
|
||||
});
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Update the page and search items on it.
|
||||
* @return void
|
||||
*/
|
||||
function updatePage(number: number): void {
|
||||
pageParameters.page = number;
|
||||
search();
|
||||
}
|
||||
|
||||
/**
|
||||
* Customize clear button.
|
||||
* @return void
|
||||
*/
|
||||
function customNodes(): void {
|
||||
const btnClear = searchBelongsToDropdown.value?.querySelector(".vs__clear") as HTMLButtonElement|null;
|
||||
btnClear?.setAttribute("title", trans.methods.__("Supprimer la sélection"));
|
||||
btnClear?.setAttribute("aria-label", trans.methods.__("Supprimer la sélection"));
|
||||
btnClear?.setAttribute("data-bs-tooltip", "tooltip");
|
||||
const inputSearchWrapper = searchBelongsToDropdown.value?.querySelector(".vs__dropdown-toggle") as HTMLInputElement|null;
|
||||
inputSearchWrapper!.className = `vs__dropdown-toggle ${nodeClass.value}`;
|
||||
if (getErrorMessage() !== null) {
|
||||
inputSearchWrapper!.className = `vs__dropdown-toggle form-control is-invalid ${nodeClass.value}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update pagination buttons status.
|
||||
* @return void
|
||||
*/
|
||||
function updateButtonStatus(): void {
|
||||
pageParameters.hasPrevPage = (pageParameters.page > 1) ? true : false;
|
||||
pageParameters.hasNextPage = (pageParameters.page < pageParameters.totalPage) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get items from a specific page and actualize pagination.
|
||||
* @return void
|
||||
*/
|
||||
function search(search: string|false|null = null): void {
|
||||
loading.value = true;
|
||||
if (search !== false && search !== null) {
|
||||
if (search !== searchText.value)
|
||||
pageParameters.page = 1;
|
||||
searchText.value = search;
|
||||
}
|
||||
window.axios
|
||||
.get(getJsonRouteUrl())
|
||||
.then((response) => {
|
||||
modelParameters.list = response.data.data;
|
||||
pageParameters.totalPage = response.data.last_page;
|
||||
pageParameters.page = response.data.current_page;
|
||||
pageParameters.itemPerPage = response.data.per_page;
|
||||
updateButtonStatus();
|
||||
})
|
||||
.then(() => { loading.value = false; })
|
||||
.catch(errors.methods.ajaxErrorHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return json route to get paginate models.
|
||||
* @return string
|
||||
*/
|
||||
function getJsonRouteUrl(): string {
|
||||
return pageParameters.constructedRoute + "?targetModel=" + modelParameters.targetClass +
|
||||
"&page=" + pageParameters.page +
|
||||
"&paginate=" + pageParameters.itemPerPage +
|
||||
"&fieldName=" + selectParameters.fieldName +
|
||||
((searchText.value !== null) ? "&search=" + searchText.value : "");
|
||||
}
|
||||
|
||||
/** Return error message or null. */
|
||||
function getErrorMessage(): string|null {
|
||||
return errors.methods.parseValidationInput(
|
||||
`${name.value}`,
|
||||
allErrors.value
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scopped>
|
||||
@import "vue-select/dist/vue-select.css";
|
||||
@import "bootstrap/scss/functions";
|
||||
@import "bootstrap/scss/variables";
|
||||
@import "bootstrap/scss/mixins";
|
||||
@import "bootstrap/scss/helpers";
|
||||
@import "bootstrap/scss/close";
|
||||
@import "bootstrap/scss/spinners";
|
||||
@import "bootstrap/scss/badge";
|
||||
|
||||
:root {
|
||||
--vs-dropdown-max-height: 30rem;
|
||||
--vs-dropdown-option--active-bg: var(--bs-primary);
|
||||
}
|
||||
.vs--disabled .vs__dropdown-toggle, .vs--disabled .vs__clear, .vs--disabled .vs__search, .vs--disabled .vs__selected, .vs--disabled .vs__open-indicator {
|
||||
background-color: var(--bs-secondary-bg) !important;
|
||||
}
|
||||
.vs__dropdown-toggle, .vs__dropdown-option, .vs__no-options {
|
||||
padding: .375rem .75rem;
|
||||
}
|
||||
.vs__dropdown-toggle {
|
||||
border: var(--bs-border-width) solid var(--bs-border-color);
|
||||
border-radius: 0.375rem;
|
||||
padding-top: 0 !important;
|
||||
background-color: var(--bs-body-bg);
|
||||
}
|
||||
.vs__selected-options, .vs__search, .vs--single .vs__selected {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
.vs__open-indicator {
|
||||
display: none;
|
||||
}
|
||||
.vs__actions, .vs__dropdown-menu {
|
||||
padding: 0;
|
||||
}
|
||||
.vs__actions, .vs__search, .vs--single .vs__selected {
|
||||
margin: .375rem 0 0 0 !important;
|
||||
}
|
||||
.vs__dropdown-menu, .vs__search, .vs--single .vs__selected {
|
||||
color: var(--bs-body-color);
|
||||
}
|
||||
.vs__search {
|
||||
border: 0 !important;
|
||||
}
|
||||
.vs__dropdown-menu {
|
||||
border-color: var(--bs-primary-border-subtle);
|
||||
background-color: var(--bs-body-bg);
|
||||
}
|
||||
.vs__dropdown-toggle:has(.vs__search:focus) {
|
||||
border-color: var(--bs-primary-border-subtle) !important;
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), var(--bs-focus-ring-opacity));
|
||||
transition: .15s;
|
||||
}
|
||||
.vs__dropdown-option--selected, .vs__dropdown-option--disabled {
|
||||
background-color: var(--bs-tertiary-bg);
|
||||
color: var(--bs-secondary);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.vs--multiple .vs__selected {
|
||||
@extend .badge;
|
||||
@extend .text-bg-secondary;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 1em !important;
|
||||
font-weight: initial;
|
||||
margin: .375rem .5rem 0 0 !important;
|
||||
padding: .19rem .25rem !important;
|
||||
}
|
||||
.vs__clear, .vs--multiple .vs__selected .vs__deselect {
|
||||
@extend .btn-close;
|
||||
padding: 0;
|
||||
}
|
||||
.vs__clear svg, .vs--multiple .vs__selected .vs__deselect svg {
|
||||
display: none;
|
||||
}
|
||||
.spinner-border {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
}
|
||||
.vs__fade-enter-active,
|
||||
.vs__fade-leave-active {
|
||||
transition: none;
|
||||
}
|
||||
.vs--open .vs__dropdown-toggle {
|
||||
border-bottom-left-radius: 0 !important;
|
||||
border-bottom-right-radius: 0 !important;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import axios from "axios";
|
||||
import * as bootstrap from "bootstrap";
|
||||
import bsTooltips from "./../../modules/bsTooltips";
|
||||
import { Tooltips } from "./../../modules/tooltips";
|
||||
|
||||
/**
|
||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||
|
|
@ -18,4 +18,4 @@ axios.defaults.headers.common = {
|
|||
window.axios = axios;
|
||||
window.bootstrap = bootstrap;
|
||||
|
||||
bsTooltips.methods.initTooltips();
|
||||
Tooltips.make();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
faArrowRight,
|
||||
faArrowRightFromBracket,
|
||||
faArrowUp,
|
||||
faArrowUpRightFromSquare,
|
||||
faArrowsAltH,
|
||||
faArrowsAltV,
|
||||
faBackspace,
|
||||
|
|
@ -20,6 +21,8 @@ import {
|
|||
faCircleInfo,
|
||||
faCircleNotch,
|
||||
faCircleXmark,
|
||||
faCommentDots,
|
||||
faCommentSlash,
|
||||
faComments,
|
||||
faCopy,
|
||||
faCrop,
|
||||
|
|
@ -29,6 +32,7 @@ import {
|
|||
faFolderOpen,
|
||||
faListUl,
|
||||
faPaintRoller,
|
||||
faPaperPlane,
|
||||
faPencil,
|
||||
faPlus,
|
||||
faQuestionCircle,
|
||||
|
|
@ -41,54 +45,62 @@ import {
|
|||
faTimes,
|
||||
faTrash,
|
||||
faUndoAlt,
|
||||
faWandMagic
|
||||
faWandMagic,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
config.autoReplaceSvg = false;
|
||||
library.add(faEraser);
|
||||
library.add(faArrowLeftLong);
|
||||
library.add(faPlus);
|
||||
library.add(faTrash);
|
||||
library.add(faEye);
|
||||
library.add(faEyeSlash);
|
||||
library.add(faFolderOpen);
|
||||
library.add(faCrop);
|
||||
library.add(faQuestionCircle);
|
||||
library.add(faCheck);
|
||||
library.add(faUndoAlt);
|
||||
library.add(faRedoAlt);
|
||||
library.add(faSyncAlt);
|
||||
library.add(faSearchPlus);
|
||||
library.add(faSearchMinus);
|
||||
library.add(faArrowLeft);
|
||||
library.add(faArrowRight);
|
||||
library.add(faArrowUp);
|
||||
library.add(faArrowDown);
|
||||
library.add(faArrowsAltH);
|
||||
library.add(faArrowsAltV);
|
||||
library.add(faWandMagic);
|
||||
library.add(faPencil);
|
||||
library.add(faTimes);
|
||||
library.add(faBackspace);
|
||||
library.add(faSearch);
|
||||
library.add(faArrowRightFromBracket);
|
||||
library.add(faArrowAltCircleDown);
|
||||
library.add(faArrowAltCircleUp);
|
||||
library.add(faCircleCheck);
|
||||
library.add(faCircleXmark);
|
||||
library.add(faCopy);
|
||||
library.add(faListUl);
|
||||
library.add(faBan);
|
||||
library.add(faCircleExclamation);
|
||||
library.add(faCircleInfo);
|
||||
library.add(faPaintRoller);
|
||||
library.add(faComments);
|
||||
library.add(
|
||||
faEraser,
|
||||
faArrowLeftLong,
|
||||
faPlus,
|
||||
faTrash,
|
||||
faEye,
|
||||
faEyeSlash,
|
||||
faFolderOpen,
|
||||
faCrop,
|
||||
faQuestionCircle,
|
||||
faCheck,
|
||||
faUndoAlt,
|
||||
faRedoAlt,
|
||||
faSyncAlt,
|
||||
faSearchPlus,
|
||||
faSearchMinus,
|
||||
faArrowLeft,
|
||||
faArrowRight,
|
||||
faArrowUp,
|
||||
faArrowDown,
|
||||
faArrowsAltH,
|
||||
faArrowsAltV,
|
||||
faWandMagic,
|
||||
faPencil,
|
||||
faTimes,
|
||||
faBackspace,
|
||||
faSearch,
|
||||
faArrowRightFromBracket,
|
||||
faArrowAltCircleDown,
|
||||
faArrowAltCircleUp,
|
||||
faCircleCheck,
|
||||
faCircleXmark,
|
||||
faCopy,
|
||||
faListUl,
|
||||
faBan,
|
||||
faCircleExclamation,
|
||||
faCircleInfo,
|
||||
faPaintRoller,
|
||||
faComments,
|
||||
faPaperPlane,
|
||||
faArrowUpRightFromSquare,
|
||||
faCommentSlash,
|
||||
faCommentDots,
|
||||
);
|
||||
|
||||
// Front
|
||||
library.add(faChevronLeft);
|
||||
library.add(faChevronRight);
|
||||
library.add(faCircleXmark);
|
||||
library.add(faCircleNotch);
|
||||
library.add(faSliders);
|
||||
library.add(
|
||||
faChevronLeft,
|
||||
faChevronRight,
|
||||
faCircleXmark,
|
||||
faCircleNotch,
|
||||
faSliders
|
||||
);
|
||||
|
||||
dom.watch();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import axios from "axios";
|
||||
import * as bootstrap from "bootstrap";
|
||||
import bsTooltips from "./../../modules/bsTooltips";
|
||||
import { Tooltips } from "./../../modules/tooltips";
|
||||
|
||||
/**
|
||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||
|
|
@ -18,4 +18,4 @@ axios.defaults.headers.common = {
|
|||
window.axios = axios;
|
||||
window.bootstrap = bootstrap;
|
||||
|
||||
bsTooltips.methods.initTooltips();
|
||||
Tooltips.make();
|
||||
|
|
|
|||
22
resources/ts/index.d.ts
vendored
22
resources/ts/index.d.ts
vendored
|
|
@ -8,6 +8,7 @@ import * as printJsType from "print-js";
|
|||
interface EnumInterface {
|
||||
label: string;
|
||||
value: number | string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
// * Laravel Paginator
|
||||
|
|
@ -20,6 +21,7 @@ interface PaginatorLink {
|
|||
|
||||
interface Paginator {
|
||||
current_page: number;
|
||||
data: Array<LaravelModel>;
|
||||
first_page_url: string;
|
||||
from: number;
|
||||
last_page: number;
|
||||
|
|
@ -63,14 +65,32 @@ type NestedNumberList = NestedNumberListInterface | NumberList | number;
|
|||
type ModelList = Array<Model>;
|
||||
interface ModelListInterface extends ModelList {}
|
||||
|
||||
type VselectOptionType = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
type UserRelation = {
|
||||
user: LaravelModel|null;
|
||||
}
|
||||
|
||||
type ClaimRelations = {
|
||||
brand: LaravelModel;
|
||||
claim_subject: LaravelModel;
|
||||
}
|
||||
|
||||
declare global {
|
||||
type CustomTag = LaravelModel & VueTagsInput.ITag;
|
||||
type LaravelModel = Model;
|
||||
type LaravelModelList = ModelList;
|
||||
type LaravelModelUserRelation = UserRelation;
|
||||
type LaravelModelClaimRelations = ClaimRelations;
|
||||
type LaravelPaginator = Paginator;
|
||||
type LaravelPaginatorLink = PaginatorLink;
|
||||
|
||||
type VselectOption = VselectOptionType;
|
||||
type Enum = EnumInterface;
|
||||
type LaravelValidationErrors = Record<string, string[]>;
|
||||
type ValueOf<T> = T[keyof T];
|
||||
|
||||
interface Window {
|
||||
axios: AxiosStatic;
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
import type * as bootstrap from "bootstrap";
|
||||
|
||||
let tooltips: Array<bootstrap.Tooltip> = [];
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
initTooltips() {
|
||||
// Disable tooltips on reboot.
|
||||
tooltips.forEach((tooltip) => {
|
||||
tooltip.disable();
|
||||
tooltip.hide();
|
||||
});
|
||||
tooltips = [].slice
|
||||
.call(document.querySelectorAll("[data-bs-toggle=\"tooltip\"]"))
|
||||
.map(function (tooltipTriggerEl) {
|
||||
return new window.bootstrap.Tooltip(tooltipTriggerEl, {
|
||||
customClass: "large-tooltip",
|
||||
delay: {
|
||||
show: 1250,
|
||||
hide: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -38,9 +38,9 @@ export default {
|
|||
allErrors: Record<string, Array<string>> = {}
|
||||
): string | null {
|
||||
let errorList = [] as Array<string>;
|
||||
Object.keys(allErrors).filter((value, index) => {
|
||||
Object.keys(allErrors).filter((value) => {
|
||||
if (value == inputName) {
|
||||
errorList = allErrors[index];
|
||||
errorList = allErrors[inputName];
|
||||
}
|
||||
});
|
||||
return errorList.length
|
||||
|
|
@ -49,5 +49,30 @@ export default {
|
|||
})
|
||||
: null;
|
||||
},
|
||||
/**
|
||||
* Return error message after the ajax call.
|
||||
* @return void
|
||||
*/
|
||||
ajaxErrorHandler(e: any): void {
|
||||
const errors = e.response?.data?.errors ?? {};
|
||||
let message = "An error has occurred";
|
||||
if (e.response.status === 422) {
|
||||
message = this.parseValidationErrors(errors) || message;
|
||||
if (window.vueDebug) {
|
||||
console.warn(e.response.data.errors);
|
||||
}
|
||||
} else if (e.response.status === 419) {
|
||||
console.log("Your session has expired, the page will be reloaded");
|
||||
setTimeout(() => window.location.reload(), 2000);
|
||||
} else if (e.response.status === 403) {
|
||||
console.log("You are not authorized to perform this action");
|
||||
setTimeout(() => window.location.reload(), 2000);
|
||||
} else {
|
||||
if (window.vueDebug) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
console.log(message);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
@ -72,6 +72,19 @@ const route = {
|
|||
|
||||
return String(url);
|
||||
},
|
||||
/**
|
||||
* Return a specific route.
|
||||
*
|
||||
* @param string targetRoute
|
||||
* @return string
|
||||
*/
|
||||
getRoute(targetRoute: string, options: Record<string,string|number|Array<string|number>> = {}): string {
|
||||
const fetchMessageRoute = route.methods.route(targetRoute, options);
|
||||
if (!fetchMessageRoute) {
|
||||
throw new Error(`Undefined ${targetRoute}`);
|
||||
}
|
||||
return fetchMessageRoute;
|
||||
}
|
||||
},
|
||||
flattenProperties(
|
||||
obj: Record<PropertyKey, unknown>,
|
||||
|
|
|
|||
114
resources/ts/modules/tooltips.ts
Normal file
114
resources/ts/modules/tooltips.ts
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
import { Tooltip } from "bootstrap";
|
||||
|
||||
|
||||
type ConstructorTypeParent = "parent";
|
||||
type ConstructorTypeDom = "dom";
|
||||
|
||||
interface ParentSelectorTooltips {
|
||||
type: ConstructorTypeParent
|
||||
/** The parent element that contains Dom elements for which tooltips shall be created. */
|
||||
parentSelector: string;
|
||||
}
|
||||
|
||||
interface DomProvidedTooltips {
|
||||
type: ConstructorTypeDom;
|
||||
/** Dom elements for which tooltips shall be created. */
|
||||
elements: HTMLElement | NodeListOf<HTMLElement>;
|
||||
}
|
||||
|
||||
interface TooltipsOptions {
|
||||
/** Tooltip options. */
|
||||
options?: Partial<Tooltip.Options>|null|undefined;
|
||||
}
|
||||
|
||||
export type TooltipsConstructor = TooltipsOptions & (ParentSelectorTooltips|DomProvidedTooltips);
|
||||
|
||||
export class Tooltips {
|
||||
/** BS tooltips instances */
|
||||
private tooltips: Array<Tooltip> = [];
|
||||
|
||||
/** The parent element that contains Dom elements for which tooltips shall be created. */
|
||||
private parentSelector: string | null = null;
|
||||
|
||||
/** Dom elements for which tooltips shall be created. */
|
||||
private elements: Array<HTMLElement> = [];
|
||||
|
||||
/** Tooltip default options. */
|
||||
private static defaultOptions: Partial<Tooltip.Options> = {
|
||||
delay: {
|
||||
show: 1250,
|
||||
hide: 0,
|
||||
},
|
||||
};
|
||||
|
||||
/** Tooltip options. */
|
||||
private options: Partial<Tooltip.Options> = {};
|
||||
|
||||
/**
|
||||
* @param parentSelector
|
||||
* @param options Tooltip options.
|
||||
*/
|
||||
constructor(params: TooltipsConstructor) {
|
||||
if (params.type === "parent") {
|
||||
this.parentSelectorConstructor(params);
|
||||
}
|
||||
if (params.type === "dom") {
|
||||
this.domPrividedTooltipsContructor(params);
|
||||
}
|
||||
}
|
||||
|
||||
public static make(params: TooltipsConstructor = { type: "parent", parentSelector: "body"}
|
||||
) {
|
||||
const fullParams = { ...{ type: "parent", options: {} }, ...params };
|
||||
return new Tooltips(fullParams);
|
||||
}
|
||||
|
||||
private parentSelectorConstructor({ parentSelector, options }: TooltipsOptions & ParentSelectorTooltips) {
|
||||
this.parentSelector = parentSelector;
|
||||
this.options = { ...Tooltips.defaultOptions, ...options };
|
||||
this.initTooltips();
|
||||
}
|
||||
|
||||
private domPrividedTooltipsContructor({ elements, options }: TooltipsOptions & DomProvidedTooltips) {
|
||||
if (elements instanceof HTMLElement) {
|
||||
this.elements = [elements];
|
||||
} else {
|
||||
this.elements = Array.from(elements);
|
||||
}
|
||||
this.options = { ...Tooltips.defaultOptions, ...options };
|
||||
this.initTooltips();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all Bootstrap tooltips and reinstanciate them.
|
||||
*/
|
||||
public refreshTooltips(): void {
|
||||
this.closeBootstrapTooltip();
|
||||
this.initTooltips();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all Bootstrap tooltips for ever.
|
||||
*/
|
||||
public closeBootstrapTooltip(): void {
|
||||
this.tooltips.forEach((tooltip) => {
|
||||
tooltip.hide();
|
||||
// * Prevent pending tooltips beeing shown after we asked to hide them
|
||||
tooltip.disable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize tooltips
|
||||
*/
|
||||
private initTooltips() {
|
||||
this.closeBootstrapTooltip();
|
||||
/** data-bs-tooltip tooltips elements */
|
||||
const elements = this.parentSelector ? [].slice
|
||||
.call(document.querySelectorAll(`${this.parentSelector} [data-bs-tooltip="tooltip"]`)) :
|
||||
this.elements;
|
||||
this.tooltips = elements.map((tooltipTriggerEl) => {
|
||||
return new Tooltip(tooltipTriggerEl, this.options);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<nav class="navbar navbar-expand-lg position-fixed fixed-top bg-body-secondary shadow-sm">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" data-bs-toggle="tooltip" data-bs-placement="bottom" href="{{ route('fo.homepage') }}"
|
||||
<a class="navbar-brand" data-bs-tooltip="tooltip" data-bs-placement="bottom" href="{{ route('fo.homepage') }}"
|
||||
title="{{ __('Accéder au front du projet') }}" target="_blank">
|
||||
{{ config('app.name', 'Laravel') }}
|
||||
</a>
|
||||
|
|
@ -21,7 +21,14 @@
|
|||
<li class="nav-item dropdown @auth border-end @endauth">
|
||||
<button class="btn nav-link dropdown-toggle d-flex align-items-center h-100 flex-row border-0 pe-3"
|
||||
data-bs-toggle="dropdown" type="button" aria-expanded="false">
|
||||
<i class="fa-solid fa-paint-roller"></i>
|
||||
<i @class([
|
||||
'fa-solid fa-paint-roller',
|
||||
'd-none d-lg-block' => auth('backend')->check(),
|
||||
])></i>
|
||||
<span @class([
|
||||
'd-lg-none',
|
||||
'd-none' => !auth('backend')->check(),
|
||||
])>{{ __('Thèmes') }}</span>
|
||||
</button>
|
||||
<form class="dropdown-menu dropdown-menu-end text-center" id="theme-selector" action="{{ route('bo.theme.set') }}"
|
||||
method="POST">
|
||||
|
|
@ -52,16 +59,17 @@
|
|||
<!-- Authentication Links -->
|
||||
@auth
|
||||
<li class="nav-item dropdown">
|
||||
<button class="btn nav-link dropdown-toggle d-flex align-items-center h-100 flex-row border-0 ps-3" id="navbarDropdown"
|
||||
<button class="btn nav-link dropdown-toggle d-flex flex-row align-items-center h-100 border-0 ps-lg-3" id="navbarDropdown"
|
||||
data-bs-toggle="dropdown" type="button">
|
||||
<div class="d-flex flex-column align-items-end lh-1">
|
||||
<span
|
||||
class="fw-bold">{{ auth('backend')->user()->first_name }} {{ auth('backend')->user()->last_name }}</span>
|
||||
<div class="d-flex flex-column align-items-start align-items-lg-end lh-1">
|
||||
<span class="fw-bold">
|
||||
{{ auth('backend')->user()->first_name }} {{ auth('backend')->user()->last_name }}
|
||||
</span>
|
||||
<small class="text-secondary-body">{{ auth('backend')->user()->role->label() }}</small>
|
||||
</div>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end m-0 text-center" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item w-100 text-decoration-none p-2" data-bs-toggle="tooltip" data-bs-placement="left"
|
||||
<a class="dropdown-item w-100 text-decoration-none p-2" data-bs-tooltip="tooltip" data-bs-placement="left"
|
||||
href="{{ route('bo.users.edit',auth('backend')->user()->getKey()) }}"
|
||||
title="{{ __('Accéder à son profile') }}">
|
||||
{{ __('Profile') }}
|
||||
|
|
@ -69,7 +77,7 @@
|
|||
<hr class="dropdown-divider m-0">
|
||||
<form class="m-0 text-center" id="logout-form" action="{{ route('bo.logout') }}" method="POST">
|
||||
@csrf
|
||||
<button class="dropdown-item w-100 text-decoration-none p-2" data-bs-toggle="tooltip" data-bs-placement="left"
|
||||
<button class="dropdown-item w-100 text-decoration-none p-2" data-bs-tooltip="tooltip" data-bs-placement="left"
|
||||
type="submit" title="{{ __('Se déconnecter du back-office') }}">
|
||||
{{ __('Déconnexion') }}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -1,30 +1,44 @@
|
|||
@auth('backend')
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.dashboard')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.dashboard') }}"
|
||||
<a class="nav-link @if (request()->routeIs('bo.dashboard')) active @endif" data-bs-tooltip="tooltip" href="{{ route('bo.dashboard') }}"
|
||||
title="{{ __('Revenir à l\'accueil') }}">
|
||||
{{ __('Accueil') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link @if (in_array(request()->route()->getName(),
|
||||
['bo.stats.viewByBrand', 'bo.stats.viewByQuestion'])) active @endif dropdown-toggle" id="navbarDarkDropdownStats"
|
||||
data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ __('Statistiques') }}</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDarkDropdownStats">
|
||||
<li><a class="dropdown-item" href="{{ route('bo.stats.viewByBrand') }}">{{ __('Statistiques par marques') }}</a></li>
|
||||
<li><a class="dropdown-item" href="{{ route('bo.stats.viewByQuestion') }}">{{ __('Statistiques par questions') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link @if (in_array(request()->route()->getName(),
|
||||
['bo.customers.export', 'bo.questions.export'])) active @endif dropdown-toggle" id="navbarDarkDropdownExport"
|
||||
data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ __('Exports') }}</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDarkDropdownExport">
|
||||
<li><a class="dropdown-item" href="{{ route('bo.customers.export') }}">{{ __('Exporter des Clients') }}</a></li>
|
||||
<li><a class="dropdown-item" href="{{ route('bo.questions.export') }}">{{ __('Exporter des Questions/réponses') }}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@canAny(['viewStatsByBrand', 'viewByQuestion', 'answersByDays'])
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link @if (in_array(request()->route()->getName(), ['bo.stats.viewByBrand', 'bo.stats.viewByQuestion'])) active @endif dropdown-toggle"
|
||||
id="navbarDarkDropdownStats" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">
|
||||
{{ __('Statistiques') }}
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDarkDropdownStats">
|
||||
@can('viewStatsByBrand')
|
||||
<li><a class="dropdown-item" href="{{ route('bo.stats.viewByBrand') }}">{{ __('Statistiques par marques') }}</a></li>
|
||||
@endcan
|
||||
@can('viewByQuestion')
|
||||
<li><a class="dropdown-item" href="{{ route('bo.stats.viewByQuestion') }}">{{ __('Statistiques par questions') }}</a></li>
|
||||
@endcan
|
||||
</ul>
|
||||
</li>
|
||||
@endcan
|
||||
@if (
|
||||
auth()->user()->can('export', \App\Models\Customer::class) ||
|
||||
auth()->user()->can('export', \App\Models\Question::class)
|
||||
)
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link @if (in_array(request()->route()->getName(), ['bo.customers.export', 'bo.questions.export'])) active @endif dropdown-toggle"
|
||||
id="navbarDarkDropdownExport" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">{{ __('Exports') }}</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDarkDropdownExport">
|
||||
@can('export', \App\Models\Customer::class)
|
||||
<li><a class="dropdown-item" href="{{ route('bo.customers.export') }}">{{ __('Exporter des Clients') }}</a></li>
|
||||
@endcan
|
||||
@can('export', \App\Models\Question::class)
|
||||
<li><a class="dropdown-item" href="{{ route('bo.questions.export') }}">{{ __('Exporter des Questions/réponses') }}</a></li>
|
||||
@endcan
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
@canAny(['isConceptor', 'viewAny'], \App\Models\User::class)
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
|
|
@ -35,7 +49,7 @@
|
|||
<ol class="dropdown-menu">
|
||||
@can('viewAny', \App\Models\User::class)
|
||||
<li>
|
||||
<a class="dropdown-item @if (request()->routeIs('bo.users.*')) active @endif" data-bs-toggle="tooltip"
|
||||
<a class="dropdown-item @if (request()->routeIs('bo.users.*')) active @endif" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.users.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.user'))]) }}">
|
||||
{{ Str::of(__('models.classes.user'))->plural()->ucfirst() }}
|
||||
|
|
@ -44,7 +58,7 @@
|
|||
@endcan
|
||||
@can('isConceptor')
|
||||
<li>
|
||||
<a class="dropdown-item @if (request()->routeIs('bo.activity_logs.*')) active @endif" data-bs-toggle="tooltip"
|
||||
<a class="dropdown-item @if (request()->routeIs('bo.activity_logs.*')) active @endif" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.activity_logs.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => trans_choice('models.classes.activity_log', 1)]) }}">
|
||||
{{ Str::of(trans_choice('models.classes.activity_log', '*'))->ucfirst() }}
|
||||
|
|
|
|||
|
|
@ -2,38 +2,43 @@
|
|||
<div class="sticky-top d-flex flex-column justify-content-between align-items-center pt-3">
|
||||
<div class="col-12 mt-4">
|
||||
@php
|
||||
$prefix = 'bo.';
|
||||
$modelsClasses = [\App\Models\Customer::class, \App\Models\Brand::class, \App\Models\Question::class, \App\Models\Service::class, \App\Models\SingleOptin::class];
|
||||
$prefix = 'bo.';
|
||||
$modelsClasses = [
|
||||
\App\Models\Customer::class,
|
||||
\App\Models\Brand::class,
|
||||
\App\Models\Question::class,
|
||||
\App\Models\Service::class,
|
||||
\App\Models\SingleOptin::class,
|
||||
\App\Models\Claim::class,
|
||||
];
|
||||
@endphp
|
||||
@foreach ($modelsClasses as $crudModel)
|
||||
<h6 class="sidebar-heading text-muted mb-1 px-3">
|
||||
<span>{{ __(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($crudModel))))) }}</span>
|
||||
</h6>
|
||||
@php
|
||||
$crudModel = new $crudModel();
|
||||
@endphp
|
||||
<ul class="nav flex-column mb-2">
|
||||
@can('viewAny', $crudModel)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link w-fit" data-bs-toggle="tooltip" data-bs-placement="right"
|
||||
href="{{ route(sprintf('%s%s.index', $prefix ?? '', $crudModel->getTable())) }}"
|
||||
title="{{ __('Afficher la liste') }}">
|
||||
{{ __('Liste') }}
|
||||
</a>
|
||||
</li>
|
||||
@can('viewAny', $crudModel)
|
||||
<h6 class="sidebar-heading text-muted mb-1 px-3">
|
||||
<span>{{ __(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($crudModel))))) }}</span>
|
||||
</h6>
|
||||
@php $crudModel = new $crudModel(); @endphp
|
||||
<ul class="nav flex-column mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link w-fit" data-bs-tooltip="tooltip" data-bs-placement="right"
|
||||
href="{{ route(sprintf('%s%s.index', $prefix ?? '', $crudModel->getTable())) }}"
|
||||
title="{{ __('Afficher la liste') }}">
|
||||
{{ __('Liste') }}
|
||||
</a>
|
||||
</li>
|
||||
@can('create', $crudModel)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link w-fit" data-bs-tooltip="tooltip" data-bs-placement="right"
|
||||
href="{{ route(sprintf('%s%s.create', $prefix ?? '', $crudModel->getTable())) }}"
|
||||
title="{{ __('Ajouter une nouvelle ligne') }}">
|
||||
{{ __('Ajouter') }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
</ul>
|
||||
@if (!$loop->last)
|
||||
<hr>
|
||||
@endcan
|
||||
@can('create', $crudModel)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link w-fit" data-bs-toggle="tooltip" data-bs-placement="right"
|
||||
href="{{ route(sprintf('%s%s.create', $prefix ?? '', $crudModel->getTable())) }}"
|
||||
title="{{ __('Ajouter une nouvelle ligne') }}">
|
||||
{{ __('Ajouter') }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
</ul>
|
||||
@if (!$loop->last)
|
||||
<hr>
|
||||
@endcan
|
||||
@endforeach
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,21 +3,21 @@
|
|||
<div class="d-flex justify-content-center align-items-center">
|
||||
<a class="@if ($loop->first and $models->onFirstPage()) invisible @endif"
|
||||
href="{{ route('bo.' . $routeName . '.change-order', [Str::singular($routeName) => $model, 'direction' => 'up']) }}">
|
||||
<button class="btn btn-sm btn-outline-secondary @if ($loop->first and $models->onFirstPage()) disabled @endif" data-bs-toggle="tooltip"
|
||||
<button class="btn btn-sm btn-outline-secondary @if ($loop->first and $models->onFirstPage()) disabled @endif" data-bs-tooltip="tooltip"
|
||||
type="submit" title="{{ __('crud.other.up') }}">
|
||||
<i class="fas fa-arrow-up"></i>
|
||||
</button>
|
||||
</a>
|
||||
<a class="@if ($loop->last and $models->currentPage() === $models->lastPage()) invisible @endif"
|
||||
href="{{ route('bo.' . $routeName . '.change-order', [Str::singular($routeName) => $model, 'direction' => 'down']) }}">
|
||||
<button class="btn btn-sm btn-outline-secondary @if ($loop->last and $models->currentPage() === $models->lastPage()) disabled @endif ms-1" data-bs-toggle="tooltip"
|
||||
<button class="btn btn-sm btn-outline-secondary @if ($loop->last and $models->currentPage() === $models->lastPage()) disabled @endif ms-1" data-bs-tooltip="tooltip"
|
||||
type="submit" title="{{ __('crud.other.down') }}">
|
||||
<i class="fas fa-arrow-down"></i>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
@else
|
||||
<span class="text-danger" data-bs-toggle="tooltip" title="{{ __('crud.other.right') }}">
|
||||
<span class="text-danger" data-bs-tooltip="tooltip" title="{{ __('crud.other.right') }}">
|
||||
<i class="fa-solid fa-ban"></i>
|
||||
</span>
|
||||
@endcan
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
@can('changePublished', $model)
|
||||
<form action="{{ route('bo.' . $routeName . '.change-published', $model->getRouteKey()) }}" method="POST">
|
||||
@csrf
|
||||
<button class="btn btn-sm @if ($model->published) btn-primary @else btn-danger @endif" data-bs-toggle="tooltip"
|
||||
<button class="btn btn-sm @if ($model->published) btn-primary @else btn-danger @endif" data-bs-tooltip="tooltip"
|
||||
type="submit" title="{{ __($model->published ? __('crud.other.unpublish') : __('crud.other.publish')) }}">
|
||||
@if ($model->published)
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
</button>
|
||||
</form>
|
||||
@else
|
||||
<span class="text-danger" data-bs-toggle="tooltip" title="{{ __('crud.other.right') }}">
|
||||
<span class="text-danger" data-bs-tooltip="tooltip" title="{{ __('crud.other.right') }}">
|
||||
<i class="fa-solid fa-ban"></i>
|
||||
</span>
|
||||
@endcan
|
||||
|
|
|
|||
|
|
@ -1,21 +1,10 @@
|
|||
{{-- GET ACTUAL PAGINATION --}}
|
||||
@php
|
||||
$pagination = intval(
|
||||
Cache::get(
|
||||
'pagination.' .
|
||||
\Illuminate\Support\Str::slug(
|
||||
request()
|
||||
->route()
|
||||
->getName(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@endphp
|
||||
@php $pagination = intval(Cache::get('pagination.' . str(request()->route()->getName())->slug())); @endphp
|
||||
@if ($paginator->items())
|
||||
<nav class="pagination-custom d-flex justify-content-between align-items-center">
|
||||
{{-- SELECT ITEMS PER PAGE --}}
|
||||
<div class="dropup-center d-flex justify-content-center align-items-center input-group w-fit">
|
||||
<span class="btn-md input-group-text" data-bs-toggle="tooltip" title="{{ __('pagination.paginate_list') }}">
|
||||
<span class="btn-md input-group-text" data-bs-tooltip="tooltip" title="{{ __('pagination.paginate_list') }}">
|
||||
<i class="fa-solid fa-list-ul"></i>
|
||||
</span>
|
||||
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" type="button" aria-expanded="false">
|
||||
|
|
@ -39,7 +28,7 @@
|
|||
<ul class="pagination m-0">
|
||||
{{-- PREVIOUS PAGE --}}
|
||||
<li class="page-item @if ($paginator->onFirstPage()) disabled @endif">
|
||||
<a class="page-link d-flex align-items-center h-100" data-bs-toggle="tooltip"
|
||||
<a class="page-link d-flex align-items-center h-100" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.previous_page') }}" aria-label="{{ __('pagination.previous_page') }}"
|
||||
@if (!$paginator->onFirstPage()) href="{{ request()->fullUrlWithQuery(['page' => $paginator->currentPage() - 1]) }}" @endif
|
||||
rel="prev" @if ($paginator->onFirstPage()) aria-hidden="true" disabled @endif>
|
||||
|
|
@ -48,7 +37,7 @@
|
|||
</li>
|
||||
{{-- FIRST PAGE --}}
|
||||
@if ($paginator->currentPage() > 3)
|
||||
<li class="page-item d-none d-sm-block" data-bs-toggle="tooltip"
|
||||
<li class="page-item d-none d-sm-block" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.specific_page', ['id' => 1]) }}">
|
||||
<a class="page-link" href="{{ request()->fullUrlWithQuery(['page' => 1]) }}">1</a>
|
||||
</li>
|
||||
|
|
@ -62,25 +51,13 @@
|
|||
@if ($i >= $paginator->currentPage() - 2 && $i <= $paginator->currentPage() + 2)
|
||||
@if ($i == $paginator->currentPage())
|
||||
<li class="page-item">
|
||||
<div class="dropup-center">
|
||||
<button class="btn btn-primary dropdown-toggle rounded-0" data-bs-toggle="dropdown" type="button"
|
||||
aria-expanded="false">
|
||||
{{ $i }}
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
@for ($i = 1; $i <= $paginator->lastPage(); $i++)
|
||||
<li>
|
||||
<a class="dropdown-item user-select-none @if ($paginator->currentPage() === $i) active @endif text-center"
|
||||
href="{{ request()->fullUrlWithQuery(['page' => $i]) }}" role="button">
|
||||
{{ $i }}
|
||||
</a>
|
||||
</li>
|
||||
@endfor
|
||||
</ul>
|
||||
</div>
|
||||
<form action="{{ route(request()->route()->getName(), request()->route()->parameters()) }}">
|
||||
<input class="form-control border-start-0 rounded-0" type="number" name="page" value="{{ $i }}"
|
||||
min="1" max="{{ $paginator->lastPage() }}">
|
||||
</form>
|
||||
</li>
|
||||
@else
|
||||
<li class="page-item d-none d-md-block" data-bs-toggle="tooltip"
|
||||
<li class="page-item d-none d-md-block" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.specific_page', ['id' => $i]) }}">
|
||||
<a class="page-link" href="{{ request()->fullUrlWithQuery(['page' => $i]) }}">{{ $i }}</a>
|
||||
</li>
|
||||
|
|
@ -93,7 +70,7 @@
|
|||
@endif
|
||||
{{-- LAST PAGE --}}
|
||||
@if ($paginator->currentPage() < $paginator->lastPage() - 2)
|
||||
<li class="page-item d-none d-sm-block" data-bs-toggle="tooltip"
|
||||
<li class="page-item d-none d-sm-block" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.specific_page', ['id' => $paginator->lastPage()]) }}">
|
||||
<a class="page-link"
|
||||
href="{{ request()->fullUrlWithQuery(['page' => $paginator->lastPage()]) }}">{{ $paginator->lastPage() }}</a>
|
||||
|
|
@ -101,7 +78,7 @@
|
|||
@endif
|
||||
{{-- NEXT PAGE --}}
|
||||
<li class="page-item @if (!$paginator->hasMorePages()) disabled @endif">
|
||||
<a class="page-link d-flex align-items-center h-100" data-bs-toggle="tooltip"
|
||||
<a class="page-link d-flex align-items-center h-100" data-bs-tooltip="tooltip"
|
||||
title="{{ __('pagination.next_page') }}" aria-label="{{ __('pagination.next_page') }}"
|
||||
@if ($paginator->hasMorePages()) href="{{ request()->fullUrlWithQuery(['page' => $paginator->currentPage() + 1]) }}" @endif
|
||||
rel="next" @if (!$paginator->hasMorePages()) aria-hidden="true" disabled @endif>
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
@php
|
||||
$selectedBrand = request()->brand;
|
||||
$selectedQuestion = request()->question;
|
||||
$selectedAnswer = request()->answer;
|
||||
$search = request()->search;
|
||||
$sortCol = request()->sort_col;
|
||||
$sortWay = request()->sort_way;
|
||||
@endphp
|
||||
|
||||
<form action="{{ request()->fullUrlWithQuery(['rst' => null]) }}" class="row gx-2">
|
||||
<div class="col-12 col-lg-6">
|
||||
{{-- BRAND SELECT --}}
|
||||
<select class="form-select mb-1" id="brandSelect">
|
||||
<option value="0" @selected(!$selectedBrand)>{{ __('Sélectionnez une marque...') }}</option>
|
||||
@foreach (\App\Models\Brand::all() as $brand)
|
||||
<option value="{{ $brand->getKey() }}" @selected($selectedBrand == $brand->getKey())>
|
||||
{{ $brand->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
{{-- QUESTION SELECT --}}
|
||||
@if (request()->routeIs('bo.single_optins.index') && $selectedBrand && $questionModels)
|
||||
<select class="form-select mb-1" id="questionSelect">
|
||||
<option value="0" @selected(!$selectedQuestion)>{{ __('Sélectionnez une question...') }}</option>
|
||||
@foreach ($questionModels as $question)
|
||||
<option value="{{ $question->getKey() }}" @selected($selectedQuestion == $question->getKey())>
|
||||
{{ $question->question }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
|
||||
{{-- ANSWER SELECT --}}
|
||||
@if ($selectedQuestion && $answerModels)
|
||||
<select class="form-select mb-1" id="answerSelect">
|
||||
<option value="0" @selected(!$selectedAnswer)>{{ __('Sélectionnez une réponse...') }}</option>
|
||||
@foreach ($answerModels as $answer)
|
||||
<option value="{{ $answer->getKey() }}" @selected($selectedAnswer == $answer->getKey())>
|
||||
{{ $answer->answer }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 d-flex justify-content-center align-items-start">
|
||||
<div class="input-group">
|
||||
{{-- SEARCH FIELD --}}
|
||||
<label class="input-group-text" for="searchField">{{ $searchFields }}</label>
|
||||
<input class="form-control" id="searchField" name="search" type="search" value="{{ $search }}"
|
||||
placeholder="Recherche.." />
|
||||
|
||||
{{-- HIDDEN INPUTS --}}
|
||||
<input type="hidden" name="sort_col" type="text" value="{{ $sortCol }}">
|
||||
<input type="hidden" name="sort_way" type="text" value="{{ $sortWay }}">
|
||||
@foreach (['brand' => $selectedBrand, 'question' => $selectedQuestion, 'answer' => $selectedAnswer] as $key => $val)
|
||||
@if ($val)
|
||||
<input type="hidden" name="{{ $key }}" type="text" value="{{ $val }}">
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
{{-- ACTION BUTTONS --}}
|
||||
<button class="btn btn-primary" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ __('Lancer la recherche') }}">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
<a class="btn btn-danger ms-2" data-bs-toggle="tooltip"
|
||||
href="{{ request()->fullUrlWithQuery(['rst' => 'true', 'search' => null, 'brand' => null, 'question' => null, 'answer' => null]) }}"
|
||||
title="{{ __('Supprimer la recherche') }}">
|
||||
<i class="fas fa-backspace"></i>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -1,46 +1,83 @@
|
|||
@php
|
||||
$iArgs = [];
|
||||
if(request()->sort_col) {
|
||||
$iArgs['sort_col'] = request()->sort_col;
|
||||
}
|
||||
|
||||
if(request()->search) {
|
||||
$iArgs['search'] = request()->sort_way;
|
||||
}
|
||||
$selectedBrand = request()->brand;
|
||||
$selectedQuestion = request()->question;
|
||||
$selectedAnswer = request()->answer;
|
||||
$search = request()->search;
|
||||
$sortCol = request()->sort_col;
|
||||
$sortWay = request()->sort_way;
|
||||
$routes = !request()->routeIs('bo.activity_logs.*')
|
||||
&& !request()->routeIs('bo.users.*')
|
||||
&& !request()->routeIs('bo.brands.*');
|
||||
@endphp
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<form id="searchForm" action="/{{ request()->path() }}">
|
||||
<div class="input-group">
|
||||
<label class="input-group-text" for="searchField">{{ $searchFields }}</label>
|
||||
@if(request()->sort_col)
|
||||
<input class="d-none" type="text" name="sort_col" value="{{ request()->sort_col }}">
|
||||
|
||||
<form action="{{ request()->fullUrlWithQuery(['rst' => null]) }}" class="row gx-2 mb-2">
|
||||
@if ($routes)
|
||||
<div class="col-12 col-lg-6">
|
||||
{{-- BRAND SELECT --}}
|
||||
<select class="form-select mb-1 {{ request()->routeIs('bo.single_optins.index') && $selectedBrand && $questionModels ? 'mb-lg-1' : 'mb-lg-0' }}"
|
||||
id="brandSelect" role="button">
|
||||
<option value="0" @selected(!$selectedBrand)>{{ __('Sélectionnez une marque...') }}</option>
|
||||
@foreach (\App\Models\Brand::all() as $brand)
|
||||
<option value="{{ $brand->getKey() }}" @selected($selectedBrand == $brand->getKey())>
|
||||
{{ $brand->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
{{-- QUESTION SELECT --}}
|
||||
@if (request()->routeIs('bo.single_optins.*') && $selectedBrand && $questionModels)
|
||||
<select id="questionSelect" role="button" @class([
|
||||
'form-select',
|
||||
'mb-1' => $selectedQuestion && $answerModels,
|
||||
])>
|
||||
<option value="0" @selected(!$selectedQuestion)>{{ __('Sélectionnez une question...') }}</option>
|
||||
@foreach ($questionModels as $question)
|
||||
<option value="{{ $question->getKey() }}" @selected($selectedQuestion == $question->getKey())>
|
||||
{{ $question->question }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
|
||||
{{-- ANSWER SELECT --}}
|
||||
@if (request()->routeIs('bo.single_optins.*') && $selectedQuestion && $answerModels)
|
||||
<select id="answerSelect" class="form-select" role="button">
|
||||
<option value="0" @selected(!$selectedAnswer)>{{ __('Sélectionnez une réponse...') }}</option>
|
||||
@foreach ($answerModels as $answer)
|
||||
<option value="{{ $answer->getKey() }}" @selected($selectedAnswer == $answer->getKey())>
|
||||
{{ $answer->answer }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
<div class="col-12 {{ $routes ? 'col-lg-6' : '' }} d-flex justify-content-center align-items-start">
|
||||
<div class="input-group">
|
||||
{{-- SEARCH FIELD --}}
|
||||
<label class="input-group-text" for="searchField">{{ str($searchFields)->ucfirst() }}</label>
|
||||
<input class="form-control" id="searchField" name="search" type="search" value="{{ $search }}"
|
||||
placeholder="Recherche.." />
|
||||
|
||||
{{-- HIDDEN INPUTS --}}
|
||||
<input type="hidden" name="sort_col" type="text" value="{{ $sortCol }}">
|
||||
<input type="hidden" name="sort_way" type="text" value="{{ $sortWay }}">
|
||||
@foreach (['brand' => $selectedBrand, 'question' => $selectedQuestion, 'answer' => $selectedAnswer] as $key => $val)
|
||||
@if ($val)
|
||||
<input type="hidden" name="{{ $key }}" type="text" value="{{ $val }}">
|
||||
@endif
|
||||
@if(request()->sort_way)
|
||||
<input class="d-none" type="text" name="sort_way" value="{{ request()->sort_way }}">
|
||||
@endif
|
||||
@if(request()->rangefilter)
|
||||
<input class="d-none" type="text" name="rangefilter" value="{{ request()->rangefilter }}">
|
||||
@endif
|
||||
@if(request()->group)
|
||||
<input class="d-none" type="text" name="group" value="{{ request()->group }}">
|
||||
@endif
|
||||
<input type="search" id="searchField" name="search" class="form-control" value="{{ request()->search }}" placeholder="{{ __('Vos mots clés ici...') }}"/>
|
||||
<button type="submit" class="btn btn-primary" data-bs-toggle="tooltip" title="{{ __('Lancer la recherche') }}">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
<button id="searchDelete" type="button" class="btn btn-danger" data-bs-toggle="tooltip" title="{{ __('Supprimer la recherche') }}">
|
||||
<i class="fas fa-backspace"></i>
|
||||
</button>
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.getElementById('searchDelete').addEventListener('click', function (e) {
|
||||
document.getElementById('searchField').value = '';
|
||||
document.getElementById('searchForm').submit();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
</div>
|
||||
</form>
|
||||
@endforeach
|
||||
|
||||
{{-- ACTION BUTTONS --}}
|
||||
<button class="btn btn-primary" data-bs-tooltip="tooltip" type="submit"
|
||||
title="{{ __('Lancer la recherche') }}">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
<a class="btn btn-danger ms-2" data-bs-tooltip="tooltip"
|
||||
href="{{ request()->fullUrlWithQuery(['rst' => 'true', 'search' => null, 'brand' => null, 'question' => null, 'answer' => null]) }}"
|
||||
title="{{ __('Supprimer la recherche') }}">
|
||||
<i class="fas fa-backspace"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
session("$routeName.sort_way") === 'desc' and session("$routeName.sort_col") === $col)
|
||||
<a class="text-decoration-none ms-1"
|
||||
href="{{ request()->fullUrlWithQuery(array_merge($iArgs, ['sort_way' => 'asc', 'rst' => null])) }}">
|
||||
<button class="btn btn-sm btn-outline-secondary" data-bs-toggle="tooltip"
|
||||
<button class="btn btn-sm btn-outline-secondary" data-bs-tooltip="tooltip"
|
||||
title="{{ __('crud.other.sort_descending', ['name' => Str::lower($colname)]) }}">
|
||||
<i class="fas fa-arrow-down 2xs"></i>
|
||||
</button>
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
session("$routeName.sort_way") === 'asc' and session("$routeName.sort_col") === $col)
|
||||
<a class="text-decoration-none ms-1"
|
||||
href="{{ request()->fullUrlWithQuery(array_merge($iArgs, ['sort_way' => 'desc', 'rst' => null])) }}">
|
||||
<button class="btn btn-sm btn-outline-secondary" data-bs-toggle="tooltip"
|
||||
<button class="btn btn-sm btn-outline-secondary" data-bs-tooltip="tooltip"
|
||||
title="{{ __('crud.other.sort_ascending', ['name' => Str::lower($colname)]) }}">
|
||||
<i class="fas fa-arrow-up 2xs"></i>
|
||||
</button>
|
||||
|
|
@ -62,13 +62,13 @@
|
|||
{{-- Buttons Col --}}
|
||||
<th class="text-end" scope="col">
|
||||
@if (!$rst)
|
||||
<a class="btn btn-sm btn-danger" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-sm btn-danger" data-bs-tooltip="tooltip"
|
||||
href="{{ request()->fullUrlWithQuery(['sort_col' => null, 'sort_way' => null, 'rst' => true, 'search' => null]) }}"
|
||||
title="{{ __('crud.other.sort_delete') }}">
|
||||
<i class="fa fa-eraser"></i>
|
||||
</a>
|
||||
@else
|
||||
<span data-bs-toggle="tooltip" title="{{ __('crud.other.sort_arrow') }}">
|
||||
<span data-bs-tooltip="tooltip" title="{{ __('crud.other.sort_arrow') }}">
|
||||
<i class="fas fa-question-circle"></i>
|
||||
</span>
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</td>
|
||||
<td class="bg-{{ $activitylogModel->event->bootstrapClass() }}-subtle text-center align-middle">
|
||||
@if (isset($activitylogModel->user))
|
||||
<a class="btn btn-sm btn-primary text-decoration-none" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-sm btn-primary text-decoration-none" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.users.edit', $activitylogModel->user) }}"
|
||||
title="{{ __('crud.helpers.view_model', ['model' => __('models.classes.user')]) }}">
|
||||
{{ $activitylogModel->user->last_name }} {{ $activitylogModel->user->first_name }}
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
@endphp
|
||||
<td class="bg-{{ $activitylogModel->event->bootstrapClass() }}-subtle text-center align-middle">
|
||||
@if (!empty($targetModel) and Route::has($editRouteName))
|
||||
<a class="btn btn-sm btn-primary text-decoration-none" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-sm btn-primary text-decoration-none" data-bs-tooltip="tooltip"
|
||||
href="{{ route($editRouteName, $activitylogModel->model_id) }}"
|
||||
title="{{ __('crud.helpers.view_model', ['model' => __('models.classes.' . Str::singular($targetModel->getTable()))]) }}">
|
||||
@endif
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
</td>
|
||||
<td class="text-end align-middle">
|
||||
@can('isConceptor')
|
||||
<a class="btn btn-sm btn-warning" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-sm btn-warning" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.activity_logs.show', ['activity_log' => $activitylogModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.view')) }}">
|
||||
<i class="fa-solid fa-eye"></i>
|
||||
|
|
|
|||
|
|
@ -4,12 +4,26 @@
|
|||
@section('description', __('Liste de tous les :model', ['model' => trans_choice('models.classes.activity', '*')]))
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
<div class="card rounded-0 border-0">
|
||||
<div class="card-header">
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.activity_logs.index-list')
|
||||
</div>
|
||||
</div>
|
||||
{!! $activitylogModels->links() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
@include('bo.pages.activity_logs.index-list')
|
||||
</div>
|
||||
{{ $activitylogModels->links() }}
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-toggle="tooltip" href="{{ route('bo.activity_logs.index') }}"
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-tooltip="tooltip" href="{{ route('bo.activity_logs.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => trans_choice(__('models.classes.activity_log'), '*')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<td class="w-50 fw-bold text-center align-middle">{{ __('Auteur') }}</td>
|
||||
<td class="w-50 text-center align-middle">
|
||||
@if (isset($activitylogModel->user))
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-sm btn-primary" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.users.edit', $activitylogModel->user) }}"
|
||||
title="{{ __('crud.helpers.view_model', ['model' => __('models.classes.user')]) }}">
|
||||
{{ $activitylogModel->user->last_name }} {{ $activitylogModel->user->first_name }}
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
$editRouteName = 'bo.' . optional($targetModel)->getTable() . '.edit';
|
||||
@endphp
|
||||
@if (isset($targetModel) and Route::has($editRouteName))
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-sm btn-primary" data-bs-tooltip="tooltip"
|
||||
href="{{ route($editRouteName, $activitylogModel->model_id) }}"
|
||||
title="{{ __('crud.helpers.view_model', ['model' => __('models.classes.' . Str::singular($targetModel->getTable()))]) }}">
|
||||
@endif
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
@can('viewAny', \App\Models\Answer::class)
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" data-bs-placement="top" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.questions.answers.index', $questionModel) }}"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.answers')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
</div>
|
||||
@can('create', \App\Models\Answer::class)
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="button"
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-tooltip="tooltip" type="button"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<div class="row">
|
||||
<div class="col text-center">
|
||||
@can('create', \App\Models\Answer::class)
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-tooltip="tooltip" type="submit"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">{{ __('Sauvegarder') }}</button>
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
@can('viewAny', \App\Models\Answer::class)
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" data-bs-placement="top" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.questions.answers.index', $questionModel) }}"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.answers')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
action="{{ route('bo.questions.answers.destroy', ['question' => $questionModel, 'answer' => $answerModel]) }}"
|
||||
method="POST">
|
||||
@can('update', \App\Models\Answer::class)
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="button"
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-tooltip="tooltip" type="button"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
@csrf
|
||||
@method('DELETE')
|
||||
@can('delete', \App\Models\Answer::class)
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="tooltip"
|
||||
<button class="btn btn-sm btn-danger" data-bs-tooltip="tooltip"
|
||||
title="{{ __('Supprimer cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
@include('bo.pages.answers.form')
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-tooltip="tooltip" type="submit"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">{{ __('Sauvegarder') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,55 +1,53 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table-hover fix-action m-0 table">
|
||||
<thead class="border-top-0 border-start-0 border-end-0 border border-2">
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'answer' => __('Réponse'),
|
||||
'updated_at' => __('Date d\'ajout en base'),
|
||||
],
|
||||
'mobileHide' => ['status'],
|
||||
'ignore' => ['updated_at'],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if ($answerModels->count())
|
||||
@foreach ($answerModels as $answerModel)
|
||||
<tr>
|
||||
<td class="text-center align-middle">{{ $answerModel->answer }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-warning text-bg-warning text-wrap">
|
||||
{{ $answerModel->updated_at->isoFormat('LLLL') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
<form class="btn-group" id="dataDelete"
|
||||
action="{{ route('bo.questions.answers.destroy', ['question' => $questionModel, 'answer' => $answerModel]) }}"
|
||||
method="POST">
|
||||
@can('update', \App\Models\Answer::class)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.questions.answers.edit', ['question' => $questionModel, 'answer' => $answerModel]) }}"
|
||||
title="{{ __('Modifier cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
@can('delete', \App\Models\Answer::class)
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="tooltip"
|
||||
title="{{ __('Supprimer cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<table class="table table-hover table-fix-action m-0">
|
||||
<thead class="border-top-0 border-start-0 border-end-0 border border-2">
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'answer' => __('Réponse'),
|
||||
'updated_at' => __('Date d\'ajout en base'),
|
||||
],
|
||||
'mobileHide' => ['status'],
|
||||
'ignore' => ['updated_at'],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if ($answerModels->count())
|
||||
@foreach ($answerModels as $answerModel)
|
||||
<tr>
|
||||
<td class="text-center" colspan="5">
|
||||
<span class="h3">{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.answers')]) }}
|
||||
<td class="text-center align-middle">{{ $answerModel->answer }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-warning text-bg-warning text-wrap">
|
||||
{{ $answerModel->updated_at->isoFormat('LLLL') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
<form class="btn-group" id="dataDelete"
|
||||
action="{{ route('bo.questions.answers.destroy', ['question' => $questionModel, 'answer' => $answerModel]) }}"
|
||||
method="POST">
|
||||
@can('update', \App\Models\Answer::class)
|
||||
<a class="btn btn-sm btn-primary" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.questions.answers.edit', ['question' => $questionModel, 'answer' => $answerModel]) }}"
|
||||
title="{{ __('Modifier cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
@can('delete', \App\Models\Answer::class)
|
||||
<button class="btn btn-sm btn-danger" data-bs-tooltip="tooltip"
|
||||
title="{{ __('Supprimer cette :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td class="text-center" colspan="5">
|
||||
<span class="h3">{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.answers')]) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-toggle="tooltip" data-bs-placement="top"
|
||||
data-bs-toggle="tooltip" href="{{ route('bo.questions.index') }}"
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" data-bs-placement="top"
|
||||
data-bs-tooltip="tooltip" href="{{ route('bo.questions.index') }}"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.questions')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
@can('create', \App\Models\Answer::class)
|
||||
<div class="col-md-3 d-flex align-items-center p-0">
|
||||
<div class="input-group justify-content-end">
|
||||
<a class="btn btn-primary" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-primary" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.questions.answers.create', ['question' => $questionModel]) }}"
|
||||
title="{{ __('Ajouter une :model', ['model' => Str::singular(__('models.classes.answers'))]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
|
|
@ -34,8 +34,8 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.answers.index-list')
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
@can('viewAny', \App\Models\Brand::class)
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" data-bs-placement="top" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.brands.index') }}"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.brands')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
@can('create', \App\Models\Brand::class)
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="button"
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-tooltip="tooltip" type="button"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
<div class="row">
|
||||
<div class="col text-center">
|
||||
@can('create', \App\Models\Brand::class)
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-tooltip="tooltip" type="submit"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">{{ __('Sauvegarder') }}</button>
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
@can('viewAny', \App\Models\Brand::class)
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-toggle="tooltip"
|
||||
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" data-bs-placement="top" data-bs-tooltip="tooltip"
|
||||
href="{{ route('bo.brands.index') }}"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.brands')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
@can('update', \App\Models\Brand::class)
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-toggle="tooltip" type="button"
|
||||
<button class="btn btn-primary" id="formSubmitClone" data-bs-tooltip="tooltip" type="button"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<div class="row">
|
||||
<div class="col text-center">
|
||||
@can('update', \App\Models\Brand::class)
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-toggle="tooltip" type="submit"
|
||||
<button class="btn btn-primary" id="formSubmit" data-bs-tooltip="tooltip" type="submit"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -1,46 +1,44 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table-hover fix-action m-0 table">
|
||||
<thead class="border-top-0 border-start-0 border-end-0 border border-2">
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'name' => __('Nom'),
|
||||
'status' => __('Nombre de comptes'),
|
||||
'optin' => __('Nombre d\'optins'),
|
||||
'updated_at' => __('Date d\'ajout en base'),
|
||||
],
|
||||
'mobileHide' => ['status'],
|
||||
'ignore' => ['status', 'optin', 'updated_at'],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if ($brandModels->count())
|
||||
@foreach ($brandModels as $brandModel)
|
||||
<tr>
|
||||
<td class="text-center align-middle">{{ $brandModel->name }}</td>
|
||||
<td class="text-center align-middle">{{ $brandModel->customer_infos_count }}</td>
|
||||
<td class="text-center align-middle">{{ $brandModel->customer_infos_optin_count }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-warning text-bg-warning text-wrap">
|
||||
{{ $brandModel->updated_at }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
@can('update', \App\Models\Brand::class)
|
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="tooltip" href="{{ route('bo.brands.edit', $brandModel->id) }}"
|
||||
title="{{ __('Modifier cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<table class="table table-hover table-fix-action m-0">
|
||||
<thead class="border-top-0 border-start-0 border-end-0 border border-2">
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'name' => __('Nom'),
|
||||
'status' => __('Nombre de comptes'),
|
||||
'optin' => __('Nombre d\'optins'),
|
||||
'updated_at' => __('Date d\'ajout en base'),
|
||||
],
|
||||
'mobileHide' => ['status'],
|
||||
'ignore' => ['status', 'optin', 'updated_at'],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if ($brandModels->count())
|
||||
@foreach ($brandModels as $brandModel)
|
||||
<tr>
|
||||
<td class="text-center" colspan="5">
|
||||
<span class="h3">{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.brands')]) }}
|
||||
<td class="text-center align-middle">{{ $brandModel->name }}</td>
|
||||
<td class="text-center align-middle">{{ $brandModel->customer_infos_count }}</td>
|
||||
<td class="text-center align-middle">{{ $brandModel->customer_infos_optin_count }}</td>
|
||||
<td class="text-center align-middle">
|
||||
<span class="badge bg-warning text-bg-warning text-wrap">
|
||||
{{ $brandModel->updated_at }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end align-middle">
|
||||
@can('update', \App\Models\Brand::class)
|
||||
<a class="btn btn-sm btn-primary" data-bs-tooltip="tooltip" href="{{ route('bo.brands.edit', $brandModel->id) }}"
|
||||
title="{{ __('Modifier cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td class="text-center" colspan="5">
|
||||
<span class="h3">{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.brands')]) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
@can('create', \App\Models\Brand::class)
|
||||
<div class="col-md-3 d-flex align-items-center p-0">
|
||||
<div class="input-group justify-content-end">
|
||||
<a class="btn btn-primary" data-bs-toggle="tooltip" href="{{ route('bo.brands.create') }}"
|
||||
<a class="btn btn-primary" data-bs-tooltip="tooltip" href="{{ route('bo.brands.create') }}"
|
||||
title="{{ __('Ajouter une :model', ['model' => Str::singular(__('models.classes.brands'))]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
|
|
@ -27,8 +27,8 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
<div class="row w-100 mx-auto mb-2">
|
||||
<div class="col table-responsive p-0">
|
||||
@include('bo.pages.brands.index-list')
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
94
resources/views/bo/pages/claims/edit.blade.php
Normal file
94
resources/views/bo/pages/claims/edit.blade.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
@extends('bo.layout', ['brParam' => $claimModel])
|
||||
|
||||
@section('title', __('Édition d\'une :model', ['model' => str(__('models.classes.claims'))->singular()]))
|
||||
@section('description', __('Édition d\'une :model déjà existante', ['model' => str(__('models.classes.claims'))->singular()]))
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="row w-100 mx-auto">
|
||||
{{-- TITLE --}}
|
||||
<div class="col-12">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-tooltip="tooltip" href="{{ route('bo.claims.index') }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.claims')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $claimModel])
|
||||
</div>
|
||||
</div>
|
||||
{{-- CLAIM AUTHOR --}}
|
||||
<div class="col-12 mt-3">
|
||||
<div class="card shadow-sm w-100">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-4 text-center">
|
||||
<h5 class="card-title mb-1">{{ trim(sprintf('%s %s', $claimModel->first_name, $claimModel->last_name)) }}</h5>
|
||||
<p class="text-muted mb-2">{{ e($claimModel->email) }}</p>
|
||||
@if ($claimModel->customer && auth()->user()->can('view', $claimModel->customer))
|
||||
<a href="{{ route('bo.customers.show', [
|
||||
'customer' => $claimModel->customer,
|
||||
'brand' => $claimModel->brand,
|
||||
]) }}" target="_blank" rel="noopener">
|
||||
{{ __('Lien vers la fiche client') }}
|
||||
<i class="fas fa-arrow-up-right-from-square ms-1"></i>
|
||||
</a>
|
||||
@endif
|
||||
@if ($claimModel->getFormatedAddress())
|
||||
<p class="mb-0">{{ $claimModel->getFormatedAddress() ? e($claimModel->getFormatedAddress()) : null }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-12 col-lg-8 border-top border-lg-top-0 border-lg-start border-lg-3 border-lg-primary mt-2 pt-2 mt-lg-0 pt-lg-0">
|
||||
<div class="claim-message-collapse" data-json='@json(['message' => $claimModel->message])'></div>
|
||||
@if($claimModel->file)
|
||||
<div class="d-flex flex-row justify-content-start align-items-center">
|
||||
<p class="m-0 me-2">Fichier:</p>
|
||||
<a class="btn btn-sm btn-primary" href="{{ asset($claimModel->file) }}" target="_blank"
|
||||
data-bs-tooltip="tooltip" title="{{ __('Ouvrir le fichier associé à cette réclamation') }}">
|
||||
{{ __('Voir la pièce jointe associée') }}
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- ACTIONS / CONVERSATION--}}
|
||||
<div class="col-12 px-0 py-3">
|
||||
@php
|
||||
$data = [
|
||||
'authUserId' => auth('backend')->user()->getKey(),
|
||||
'claimModel' => $claimModel,
|
||||
'brandModels' => $brandModels ?? [],
|
||||
'claimSubjectModels' => $claimSubjectModels ?? [],
|
||||
'claimMessageModels' => $claimMessageModels,
|
||||
'claimTemplateModels' => $claimTemplateModels,
|
||||
'enums' => [
|
||||
'claimType' => \App\Enums\Claims\ClaimType::toArray(),
|
||||
'claimStatus' => \App\Enums\Claims\ClaimStatus::toArray(),
|
||||
'claimResponseType' => \App\Enums\Claims\ClaimResponseType::toArray(),
|
||||
],
|
||||
'can' => [
|
||||
'updateBrand' => Gate::check('updateBrand', \App\Models\Claim::class),
|
||||
'updateSubject' => Gate::check('updateSubject', \App\Models\Claim::class),
|
||||
'updateType' => Gate::check('updateType', \App\Models\Claim::class),
|
||||
'updateStatus' => Gate::check('updateStatus', \App\Models\Claim::class),
|
||||
'updateResponseType' => Gate::check('updateResponseType', \App\Models\Claim::class),
|
||||
],
|
||||
'allErrors' => $errors->getBag('default')->getMessages() ?? [],
|
||||
];
|
||||
@endphp
|
||||
<div class="claim-wrapper" data-json='@json($data)'></div>
|
||||
</div>
|
||||
{{-- OTHER CUSTOMER CLAIMS --}}
|
||||
@if ($customerClaimModels->count())
|
||||
<div class="col-12 py-3">
|
||||
<h3 class="h3 fw-bold">{{ __('Autres réclas du même demandeur') }}</h3>
|
||||
<div class="table-responsive mb-2">
|
||||
@include('bo.pages.claims.index-list', ['claimModels' => $customerClaimModels])
|
||||
</div>
|
||||
{!! $customerClaimModels->links() !!}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue