Merge branch 'issue-37' into 'develop'
Issue 37 See merge request ldc-web/projets/support-web!60
This commit is contained in:
commit
d95f413bbb
23 changed files with 63 additions and 113 deletions
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums\Projects;
|
||||
|
||||
use App\Traits\Enums\BaseEnum;
|
||||
|
||||
enum ProjectStatusEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
case new = 0;
|
||||
case specification = 1;
|
||||
case validated = 2;
|
||||
case development = 3;
|
||||
case recipe = 4;
|
||||
case production = 5;
|
||||
case finished = 6;
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::new->name => "Nouveau",
|
||||
self::specification->name => "Spécifications",
|
||||
self::validated->name => "Validé",
|
||||
self::development->name => "En développement",
|
||||
self::recipe->name => "En recettage",
|
||||
self::production->name => "En production",
|
||||
self::finished->name => "Terminé",
|
||||
];
|
||||
}
|
||||
|
|
@ -156,14 +156,14 @@ class InvoiceController extends Controller
|
|||
->route('bo.invoices.edit', $invoice)
|
||||
->with('success', __(
|
||||
'crud.messages.has_been_updated',
|
||||
['model' => Str::singular(__('models.classes.invoices'))]
|
||||
['model' => __('models.classes.invoices')]
|
||||
));
|
||||
} //end if
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', __(
|
||||
'crud.messages.cannot_be_updated',
|
||||
['model' => Str::singular(__('models.classes.invoices'))]
|
||||
['model' => __('models.classes.invoices')]
|
||||
));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class StoreBrandRequest extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'name' => 'required|string|min:3|max:255',
|
||||
'sites' => 'nullable|array',
|
||||
'sites.*.id' => 'required|exists:sites,id'
|
||||
];
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class StoreInformationRequest extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|max:255',
|
||||
'message' => 'required|string|max:255',
|
||||
'title' => 'required|string|min:3|max:255',
|
||||
'message' => 'required|string|min:3|max:255',
|
||||
'type' => [
|
||||
'required',
|
||||
Rule::in(collect(InfoColorsEnum::cases())->pluck('value')->all()),
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ class StorePackageRequest extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'amount' => 'required|numeric|regex:/^\d+(\.\d{1,2})?$/',
|
||||
'name' => 'required|string|min:3|max:255',
|
||||
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Http\Requests\Bo\Projects;
|
||||
|
||||
use App\Enums\Projects\ProjectStatusEnum;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreProjectRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -28,10 +26,6 @@ class StoreProjectRequest extends FormRequest
|
|||
{
|
||||
return [
|
||||
'name' => 'required|string|min:3|max:255|unique:projects,name',
|
||||
'status' => [
|
||||
'required',
|
||||
Rule::in(collect(ProjectStatusEnum::cases())->pluck('value')->all()),
|
||||
],
|
||||
'site_id' => 'required|exists:sites,id',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Http\Requests\Bo\TicketTypes;
|
||||
|
||||
use App\Enums\Tickets\TicketTypeEnum;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class UpdateTicketTypeRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -27,7 +25,6 @@ class UpdateTicketTypeRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'type' => ['required', new Enum(TicketTypeEnum::class)],
|
||||
'template' => 'required|string|min:3|max:255',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Projects\ProjectStatusEnum;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property ProjectStatusEnum $status
|
||||
* @property Site $site_id
|
||||
*/
|
||||
class Project extends Model
|
||||
|
|
@ -22,19 +20,9 @@ class Project extends Model
|
|||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'site_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'status' => ProjectStatusEnum::class
|
||||
];
|
||||
|
||||
// * RELATIONSHIPS.
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('projects', function (Blueprint $table) {
|
||||
$table->dropColumn('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('projects', function (Blueprint $table) {
|
||||
$table->unsignedSmallInteger('status')->default(0)->comment('Enum ProjectStatus')->after('name');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -13,7 +13,6 @@
|
|||
:placeholder="intPlaceholder"
|
||||
:required="intRequired"
|
||||
@input="onInput"
|
||||
@blur="onBlur"
|
||||
v-model="intValue"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -80,18 +79,6 @@ export default defineComponent({
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
onBlur() {
|
||||
const el = textarea.value;
|
||||
if (!el) {
|
||||
throw new Error("undefined textarea element");
|
||||
}
|
||||
// * Remove every new line char
|
||||
el.value = el.value.replace(/[\n\r]/g, "");
|
||||
this.$nextTick(() => {
|
||||
el.style.height = "auto";
|
||||
el.style.height = `${el.scrollHeight}px`;
|
||||
});
|
||||
},
|
||||
onInput() {
|
||||
const el = textarea.value;
|
||||
if (!el) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
'helper' => __('Séléctionnez les sites à associer à cet utilisateur (minimum 0, maximum :max)', [
|
||||
'max' => count($siteModels)
|
||||
]),
|
||||
'required' => true,
|
||||
'required' => false,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@extends('layout.app', ['brParam' => $invoiceModel])
|
||||
|
||||
@section('title', __('Création d\'un :model', ['model' => Str::singular(__('models.classes.invoices'))]))
|
||||
@section('description', __('Création d\'un tout nouveau :model', ['model' => Str::singular(__('models.classes.invoices'))]))
|
||||
@section('title', __('Création d\'un :model', ['model' => __('models.classes.invoices')]))
|
||||
@section('description', __('Création d\'un tout nouveau :model', ['model' => __('models.classes.invoices')]))
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
class="btn btn-primary"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => Str::singular(__('models.classes.invoices'))]) }}">
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.invoices')]) }}">
|
||||
{{ __('crud.actions.save') }}
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
class="btn btn-primary"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('crud.helpers.save_model', ['model' => Str::singular(__('models.classes.invoices'))]) }}">
|
||||
title="{{ __('crud.helpers.save_model', ['model' => __('models.classes.invoices')]) }}">
|
||||
{{ __('crud.actions.save') }}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@if($invoiceModel->status === \App\Enums\Invoices\InvoiceStatusEnum::opened)
|
||||
@if($invoiceModel->status === \App\Enums\Invoices\InvoiceStatusEnum::opened || $invoiceModel->status === null)
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
class="btn btn-primary float-right"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('crud.helpers.create_model', ['model' => Str::singular(__('models.classes.invoices'))]) }}">
|
||||
title="{{ __('crud.helpers.create_model', ['model' => __('models.classes.invoices')]) }}">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
</tbody>
|
||||
@else
|
||||
<tr>
|
||||
<td class="text-center fw-bold border-0">{{ __('crud.other.no_model_found', ['model' => Str::singular(__('models.classes.invoices'))]) }}</td>
|
||||
<td class="text-center fw-bold border-0">{{ __('crud.other.no_model_found', ['model' => __('models.classes.invoices')]) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@extends('layout.app', ['brParam' => $invoiceModel])
|
||||
|
||||
@section('title', __('Aperçu d\'un :model', ['model' => Str::singular(__('models.classes.invoices'))]))
|
||||
@section('description', __('Aperçu d\'un :model déjà existant', ['model' => Str::singular(__('models.classes.invoices'))]))
|
||||
@section('title', __('Aperçu d\'un :model', ['model' => __('models.classes.invoices')]))
|
||||
@section('description', __('Aperçu d\'un :model déjà existant', ['model' => __('models.classes.invoices')]))
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
|
|
|
|||
|
|
@ -48,13 +48,12 @@
|
|||
'name' => 'amount',
|
||||
'required' => true,
|
||||
'model' => $packageModel ?? null,
|
||||
'helper' => __('validation.between.numeric', [
|
||||
'helper' => __('validation.min.numeric', [
|
||||
'attribute' => __(':field du :model', [
|
||||
'field' => Str::ucfirst(__('validation.attributes.amount.day')),
|
||||
'model' => Str::singular(__('models.classes.packages')),
|
||||
]),
|
||||
'min' => 0,
|
||||
'max' => 10.000,
|
||||
]),
|
||||
'step' => 0.01
|
||||
])
|
||||
|
|
|
|||
|
|
@ -32,25 +32,6 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- STATUS --}}
|
||||
<div class="col-12 col-md-6 pb-3">
|
||||
<fieldset class="border h-100 bg-white p-3 mb-3">
|
||||
<legend>{{ Str::ucfirst(__('validation.attributes.status')) }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.tinyint-enum', [
|
||||
'id' => 'projectStatus',
|
||||
'label' => __('crud.minicrud.associated', ['entity' => 'Role']),
|
||||
'name' => 'status',
|
||||
'model' => $projectModel ?? null,
|
||||
'required' => true,
|
||||
'associatedModels' => \App\Enums\Projects\ProjectStatusEnum::toArray(),
|
||||
'helper' => __('crud.minicrud.select', ['entity' => 'statut']),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- SITE_ID --}}
|
||||
<div class="col-12 col-md-6 pb-3">
|
||||
<fieldset class="border bg-white h-100 p-3">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
@php
|
||||
$cols = [
|
||||
'name' => Str::ucfirst(__('validation.attributes.name')),
|
||||
'status' => Str::ucfirst(__('validation.attributes.status')),
|
||||
'site_id' => Str::ucfirst(__('models.classes.sites')),
|
||||
];
|
||||
@endphp
|
||||
|
|
@ -34,7 +33,6 @@
|
|||
@foreach ($projectModels as $projectModel)
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ $projectModel->name }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->status->label() }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->site->name }}</td>
|
||||
<td class="text-end align-middle">
|
||||
<form action="{{ route('bo.projects.destroy', $projectModel->id) }}"
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.name')) }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->name }}</td>
|
||||
</tr>
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.status')) }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->status->label() }}</td>
|
||||
</tr>
|
||||
<tr class="list-item border-bottom">
|
||||
<td class="text-center align-middle">{{ Str::ucfirst(__('validation.attributes.sites')) }}</td>
|
||||
<td class="text-center align-middle">{{ $projectModel->site->name }}</td>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
'min' => 0,
|
||||
'max' => count($userModels),
|
||||
]),
|
||||
'required' => true,
|
||||
'required' => false,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="row">
|
||||
{{-- ROLE --}}
|
||||
{{-- TYPE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ trans_choice('models.classes.ticket_types', 1) }}</legend>
|
||||
|
|
@ -12,7 +12,8 @@
|
|||
]),
|
||||
'name' => 'type',
|
||||
'model' => $ticketTypeModel ?? null,
|
||||
'required' => true,
|
||||
'required' => false,
|
||||
'disabled' => $ticketTypeModel ? true : false,
|
||||
'associatedModels' => \App\Enums\Tickets\TicketTypeEnum::toArray(),
|
||||
'helper' => __('crud.minicrud.enum_select', [
|
||||
'enum' => trans_choice('models.classes.ticket_types', 1),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,14 @@
|
|||
<b>{{ $label }} {{ $required ? '*' : '' }}</b>
|
||||
</label>
|
||||
@php
|
||||
if (old($name)) {
|
||||
$model = $targetModel::find(old($name, []));
|
||||
$modelSelected = [
|
||||
'id' => $model->id,
|
||||
'name' => $model->name,
|
||||
'value' => $model->id,
|
||||
];
|
||||
}
|
||||
$data = [
|
||||
'readonly' => $readonly,
|
||||
'name' => $name,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@if(!empty($label))
|
||||
<label for="{{ $name }}" class="col-form-label"><b>{{ $label }}@if(!empty($required)) * @endif</b></label>
|
||||
@endif
|
||||
<select id="{{ $name }}" class="form-select" name="{{ $name }}" aria-describedby="{{ $id }}Help" @if(!empty($require))required @endif>
|
||||
<select id="{{ $name }}" class="form-select" name="{{ $name }}" aria-describedby="{{ $id }}Help" @if(!empty($require))required @endif @if(!empty($disabled))disabled @endif>
|
||||
@foreach ($associatedModels as $associatedModel)
|
||||
<option value="{{ $associatedModel->value}}" @if (old($name, $model->{$name}->value ?? $value ?? Arr::first($associatedModels)->value) == $associatedModel->value) selected @endif>
|
||||
{{ $associatedModel->label }}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue