From 01edc8a2ae119199136e2d6ab232f48a40fa27ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 25 May 2022 11:59:54 +0200 Subject: [PATCH 1/8] NPM Add font awesome dep --- package-lock.json | 17 +++++++++++++++++ package.json | 1 + resources/views/layout/app.blade.php | 8 +++++--- webpack.mix.js | 4 ++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f641f34..b1949ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,6 +6,7 @@ "": { "devDependencies": { "@babel/plugin-transform-async-to-generator": "^7.16.8", + "@fortawesome/fontawesome-free": "^6.1.1", "autoprefixer": "10.4.5", "axios": "^0.21.1", "bootstrap": "^5.1.3", @@ -1656,6 +1657,16 @@ "node": ">=10.0.0" } }, + "node_modules/@fortawesome/fontawesome-free": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.1.1.tgz", + "integrity": "sha512-J/3yg2AIXc9wznaVqpHVX3Wa5jwKovVF0AMYSnbmcXTiL3PpRPfF58pzWucCwEiCJBp+hCNRLWClTomD8SseKg==", + "dev": true, + "hasInstallScript": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -11719,6 +11730,12 @@ "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", "dev": true }, + "@fortawesome/fontawesome-free": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.1.1.tgz", + "integrity": "sha512-J/3yg2AIXc9wznaVqpHVX3Wa5jwKovVF0AMYSnbmcXTiL3PpRPfF58pzWucCwEiCJBp+hCNRLWClTomD8SseKg==", + "dev": true + }, "@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", diff --git a/package.json b/package.json index 0bd4333..8fdc024 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "@babel/plugin-transform-async-to-generator": "^7.16.8", + "@fortawesome/fontawesome-free": "^6.1.1", "autoprefixer": "10.4.5", "axios": "^0.21.1", "bootstrap": "^5.1.3", diff --git a/resources/views/layout/app.blade.php b/resources/views/layout/app.blade.php index 31be5ac..329ed82 100644 --- a/resources/views/layout/app.blade.php +++ b/resources/views/layout/app.blade.php @@ -18,8 +18,9 @@ - - + + + @crudPoliciesCSS @stack('customCss') @@ -40,7 +41,8 @@ @include('layout.footer') @stack('scriptsConstants') - + + @stack('scripts') @crudPoliciesJS() @auth diff --git a/webpack.mix.js b/webpack.mix.js index a081743..be3aef2 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -56,3 +56,7 @@ mix.js('resources/js/app.js', 'public/js') // Copy Blade Images Assets mix.copyDirectory('resources/assets', 'public/assets') + +// fontawesome compile +mix.copy('node_modules/@fortawesome/fontawesome-free/js/all.min.js', 'public/js/fontawesome.min.js') + .copy('node_modules/@fortawesome/fontawesome-free/css/fontawesome.min.css', 'public/css/fontawesome.min.css'); From c8554b3d3230cef4f96df737bd7d69f46540cc9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 25 May 2022 12:00:20 +0200 Subject: [PATCH 2/8] Make some place on tickets.index --- app/Enums/TicketStatus.php | 46 +++ app/Enums/TicketType.php | 37 +++ resources/sass/bootstrap.scss | 7 + resources/views/ticket/index.blade.php | 385 ++++++++++++------------- 4 files changed, 278 insertions(+), 197 deletions(-) diff --git a/app/Enums/TicketStatus.php b/app/Enums/TicketStatus.php index 0e6b700..d764208 100644 --- a/app/Enums/TicketStatus.php +++ b/app/Enums/TicketStatus.php @@ -21,6 +21,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable; */ class TicketStatus extends BaseEnumRoutable { + /** + * Enum values + * + * @return array + */ protected static function values(): array { return [ @@ -40,6 +45,11 @@ class TicketStatus extends BaseEnumRoutable ]; } + /** + * Enum labels + * + * @return array + */ protected static function labels(): array { return [ @@ -58,4 +68,40 @@ class TicketStatus extends BaseEnumRoutable 'archived' => trans('Archivé'), ]; } + + /** + * Enum classes + * + * @return array + */ + protected static function classes(): array + { + return [ + 'new' => 'text-danger', + 'estimateTodo' => 'text-info', + 'estimateValidated' => 'text-info', + 'estimateDone' => 'text-info', + 'toPlan' => 'text-info', + 'planned' => 'text-info', + 'inprogress' => 'text-dark', + 'waiting' => 'text-white bg-danger', + 'waitingValidation' => 'text-warning bg-danger', + 'processed' => trans('Traité'), + 'recette' => 'text-primary', + 'production' => 'text-success', + 'archived' => 'text-secondary', + ]; + } + + /** + * @param string $attribute + * @return integer|string + */ + public function __get(string $attribute) + { + if ($attribute === 'class') { + return $this->classes()[$this->getDefinition()]; + } + return parent::__get($attribute); + } } diff --git a/app/Enums/TicketType.php b/app/Enums/TicketType.php index b7fb171..3b8025c 100644 --- a/app/Enums/TicketType.php +++ b/app/Enums/TicketType.php @@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable; */ class TicketType extends BaseEnumRoutable { + /** + * Enum values + * + * @return array + */ protected static function values(): array { return [ @@ -22,6 +27,11 @@ class TicketType extends BaseEnumRoutable ]; } + /** + * Enum labels + * + * @return array + */ protected static function labels(): array { return [ @@ -31,4 +41,31 @@ class TicketType extends BaseEnumRoutable 'newsletter' => trans('Demande newsletter') ]; } + + /** + * Enum classes + * + * @return array + */ + protected static function classes(): array + { + return [ + 'bug' => 'bg-danger', + 'evolution' => 'bg-success', + 'br' => 'bg-primary', + 'newsletter' => 'bg-warning' + ]; + } + + /** + * @param string $attribute + * @return integer|string + */ + public function __get(string $attribute) + { + if ($attribute === 'class') { + return $this->classes()[$this->getDefinition()]; + } + return parent::__get($attribute); + } } diff --git a/resources/sass/bootstrap.scss b/resources/sass/bootstrap.scss index 0b4a8f7..cde3ffe 100644 --- a/resources/sass/bootstrap.scss +++ b/resources/sass/bootstrap.scss @@ -1,3 +1,10 @@ @import 'variables'; @import '~bootstrap/scss/bootstrap'; @import 'bootswatch'; + +// OVERLOAD BOOTSTRAP +.btn-xs, .btn-group-xs > .btn { + padding: 0.1rem 0.4rem; + font-size: 0.8rem; + border-radius: 0.3rem; +} diff --git a/resources/views/ticket/index.blade.php b/resources/views/ticket/index.blade.php index b234cb9..b83876f 100644 --- a/resources/views/ticket/index.blade.php +++ b/resources/views/ticket/index.blade.php @@ -5,208 +5,199 @@ $userPr = Auth::user()->sites ?? collect([]); @endphp
-

- Gestion des tickets @if(request()->status) (Archivés) @endif -
-
-
-
- {{ __('Créer un ticket') }} - @if(session('tickets.st') == TicketStatus::archived()) - {{ __('Tickets Actifs') }} - @else - {{ __('Tickets Archivés') }} - @endif - {{ __('Réinitialiser le tri') }} -
-
- -
-
- -
-
-
-
-
-
- -
-
-
-
-
- - - -
-
-
-
-
-

- - - - - - - - @if(Auth::user()->isAdmin()) - - @endif - - - - - - - - @if(!count($tickets)) - - - - @endif - @foreach ($tickets as $ticket) - @php - $cls = $ticket->status == TicketStatus::archived() ? 'text-secondary' : null; - $cls = (!$cls && $ticket->status == TicketStatus::new()) ? 'text-danger' : $cls; - $cls = (!$cls && $ticket->status == TicketStatus::processed()) ? 'text-info' : $cls; - $cls = (!$cls && $ticket->status == TicketStatus::recette()) ? 'text-primary' : $cls; - $cls = (!$cls && $ticket->status == TicketStatus::production()) ? 'text-success' : $cls; - $cls = (!$cls && $ticket->status == TicketStatus::inprogress()) ? 'text-dark' : $cls; - $cls = (!$cls && $ticket->status == TicketStatus::waiting()) ? 'text-white bg-danger' : $cls; - $ticketClass = 'bg-primary'; - switch($ticket->type) { - case TicketType::bug(): - $ticketClass = 'bg-danger'; - break; - case TicketType::evolution(): - $ticketClass = 'bg-success'; - break; - case TicketType::newsletter(): - $ticketClass = 'bg-warning'; - break; - } - @endphp - - - - - - @if(Auth::user()->isAdmin()) - - @endif - - - - - - @endforeach - -
- #  - @include('modules.sorter', ['colname' => 'id']) - - {{__('Type') }}  - @include('modules.sorter', ['colname' => 'type']) - {{__('Fichiers') }} - {{__('Crée le') }}  - @include('modules.sorter', ['colname' => 'created_at']) - - {{__('Assigné à') }}  - @include('modules.sorter', ['colname' => 'assigned_to']) - - {{__('Créé par') }}  - @include('modules.sorter', ['colname' => 'created_by']) - - {{__('Statut') }}  - @include('modules.sorter', ['colname' => 'status']) - {{__('Contenu') }}{{__('Actions') }}
-

{{ __('Aucun ticket') }}

-
-
- {{ $ticket->id }} @if($ticket->is_internal)🔒@endif - {{ $ticket->site->name }} -
-
- {{ $ticket->type->label }} - - @if ($ticket->file !== null) - Fichier - @endif - @if ($ticket->file2 !== null) - Fichier 2 - @endif - {{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }}{{ $ticket->assignedUser ? $ticket->assignedUser->name : __('Personne') }}{{ $ticket->user ? $ticket->user->name : __('Utilisateur supprimé') }}{{ $ticket->status->label }} - {{-- Modal du ticket --}} - - - - - - {{ __('Messages') }} - @if(auth()->user()->isAdmin()) - {{ __('Modifier') }} - @endif - @can('delete', $ticket) - @if(!$ticket->status->equals(TicketStatus::archived())) -
- @method('PUT') - @csrf - -
- @endif - @endcan -
- {{ $tickets->withQueryString()->links() }} +
+
+ + + + + + @if(Auth::user()->isAdmin()) + + @endif + + + + + + + @if(!count($tickets)) + + + + @endif + @foreach ($tickets as $ticket) + + + + @if(Auth::user()->isAdmin()) + + @endif + + + + + @endforeach + +
+ #  + @include('modules.sorter', ['colname' => 'id']) + + {{__('Type') }}  + @include('modules.sorter', ['colname' => 'type']) + + {{__('Assigné à') }}  + @include('modules.sorter', ['colname' => 'assigned_to']) + + {{__('Créé par') }}  + @include('modules.sorter', ['colname' => 'created_by']) + + {{__('Le') }}  + @include('modules.sorter', ['colname' => 'created_at']) +
+

{{ __('Aucun ticket') }}

+
+
+ {{ $ticket->id }} @if($ticket->is_internal)🔒@endif + + {{ $ticket->site->name }} + {{ $ticket->status->label }} + +
+
+ {{ $ticket->type->label }} + {{ $ticket->assignedUser ? $ticket->assignedUser->name : __('Personne') }}{{ $ticket->user ? $ticket->user->name : __('Utilisateur supprimé') }}{{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }} +
+
+
+ @if ($ticket->file !== null) + + @endif + @if ($ticket->file2 !== null) + + @endif + {{-- Modal du ticket --}} + + + + @if(auth()->user()->isAdmin()) + + @endif + @can('delete', $ticket) + @if(!$ticket->status->equals(TicketStatus::archived())) +
+ @method('PUT') + @csrf + +
+ @endif + @endcan +
+
+
+ + +
+ {{ $tickets->withQueryString()->links() }} +
+ + + @endsection From 75b4f762b15086f24149811a890cbc37f8ea775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 26 May 2022 13:17:43 +0200 Subject: [PATCH 3/8] Fix Store ticket regression --- app/Http/Requests/StoreTicket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/StoreTicket.php b/app/Http/Requests/StoreTicket.php index a5bbb8b..01db4fd 100644 --- a/app/Http/Requests/StoreTicket.php +++ b/app/Http/Requests/StoreTicket.php @@ -30,7 +30,7 @@ class StoreTicket extends FormRequest if ($user) { if (!$user->isAdmin()) { $this->merge([ - 'status' => $this->site->status->value, + 'status' => TicketStatus::new()->value, 'is_internal' => false, ]); } else { From 7d7bc5843a18835e2b9da491fd2ecc6bfe996e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 26 May 2022 13:18:47 +0200 Subject: [PATCH 4/8] Fix Schedule autorisation hole --- app/Http/Controllers/ScheduleController.php | 9 +++++++++ resources/views/layout/nav.blade.php | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ScheduleController.php b/app/Http/Controllers/ScheduleController.php index 1f555f5..525e4c9 100644 --- a/app/Http/Controllers/ScheduleController.php +++ b/app/Http/Controllers/ScheduleController.php @@ -17,6 +17,15 @@ use Carbon\CarbonImmutable; */ class ScheduleController extends Controller { + /** + * ScheduleController + */ + public function __construct() + { + parent::__construct(); + $this->middleware('is-admin'); + } + public function index(Request $request) { $date = CarbonImmutable::now()->startOfWeek(); diff --git a/resources/views/layout/nav.blade.php b/resources/views/layout/nav.blade.php index 9ea5527..54e4da3 100644 --- a/resources/views/layout/nav.blade.php +++ b/resources/views/layout/nav.blade.php @@ -11,19 +11,27 @@ @auth