From a0ddeda5a9bbfb78de19532e4d756cd5a47d7db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Mon, 11 Sep 2023 15:07:25 +0200 Subject: [PATCH 1/3] pagination upgrade --- resources/sass/base/_common.scss | 6 + resources/views/modules/pagination.blade.php | 205 ++++++++++-------- .../views/pages/products/index.blade.php | 16 +- 3 files changed, 124 insertions(+), 103 deletions(-) diff --git a/resources/sass/base/_common.scss b/resources/sass/base/_common.scss index 479a389..47ab386 100644 --- a/resources/sass/base/_common.scss +++ b/resources/sass/base/_common.scss @@ -26,3 +26,9 @@ display: block; } } + +.pagination-custom .dropdown-menu { + overflow: auto; + min-width: 5rem; + max-height: 178px; +} diff --git a/resources/views/modules/pagination.blade.php b/resources/views/modules/pagination.blade.php index c86ebd1..4486c20 100644 --- a/resources/views/modules/pagination.blade.php +++ b/resources/views/modules/pagination.blade.php @@ -1,98 +1,115 @@ - +@endif diff --git a/resources/views/pages/products/index.blade.php b/resources/views/pages/products/index.blade.php index 3197b69..0f790d3 100644 --- a/resources/views/pages/products/index.blade.php +++ b/resources/views/pages/products/index.blade.php @@ -9,16 +9,15 @@
-

- {{ trans_choice('models.classes.products_monitoring', 2) }} {{ Str::ucfirst(__('liste')) }} +

+ {{ trans_choice('models.classes.products_monitoring', 2) }} {{ Str::ucfirst(__('liste')) }}

@@ -28,7 +27,7 @@
@include('pages.products.product-filters')
-
+
{{ $products->withQueryString()->onEachSide(1)->links() }}
@@ -38,11 +37,10 @@
-
+
{{ $products->withQueryString()->onEachSide(1)->links() }}
@endsection - From 99f75455950d3425db41d80addb436588112cabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Mon, 11 Sep 2023 16:54:15 +0200 Subject: [PATCH 2/3] Closes #32 Multiple file inputs for all doc types --- .../Requests/Products/StoreProductRequest.php | 6 +- ...ment.php => HasDocumentAndPictureList.php} | 50 +- .../MultipleDocumentsInputComponent.vue | 431 ++++++------------ resources/ts/modules/bsTooltips.ts | 27 ++ resources/views/pages/products/form.blade.php | 16 +- 5 files changed, 206 insertions(+), 324 deletions(-) rename app/Traits/Requests/{HasDocument.php => HasDocumentAndPictureList.php} (62%) create mode 100644 resources/ts/modules/bsTooltips.ts diff --git a/app/Http/Requests/Products/StoreProductRequest.php b/app/Http/Requests/Products/StoreProductRequest.php index 73d0eb2..4a93091 100644 --- a/app/Http/Requests/Products/StoreProductRequest.php +++ b/app/Http/Requests/Products/StoreProductRequest.php @@ -11,7 +11,7 @@ use App\Enums\Products\RangeEnum; use App\Enums\Products\RayEnum; use App\Enums\Products\SourceEnum; use App\Lib\Helpers\ToolboxHelper; -use App\Traits\Requests\HasDocument; +use App\Traits\Requests\HasDocumentAndPictureList; use App\Traits\Requests\HasPicture; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rules\Enum; @@ -20,7 +20,7 @@ use Illuminate\Validation\ValidationException; class StoreProductRequest extends FormRequest { use HasPicture; - use HasDocument; + use HasDocumentAndPictureList; /** * Determine if the user is authorized to make this request. @@ -110,7 +110,7 @@ class StoreProductRequest extends FormRequest return \array_merge( $rules, $this->pictureRules('picture', false, 1200, 900, 1200, 900), - $this->documentsRules('docs', false), + $this->documentsRules('docs'), ); } diff --git a/app/Traits/Requests/HasDocument.php b/app/Traits/Requests/HasDocumentAndPictureList.php similarity index 62% rename from app/Traits/Requests/HasDocument.php rename to app/Traits/Requests/HasDocumentAndPictureList.php index 63ea180..b893845 100644 --- a/app/Traits/Requests/HasDocument.php +++ b/app/Traits/Requests/HasDocumentAndPictureList.php @@ -4,24 +4,43 @@ namespace App\Traits\Requests; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; -trait HasDocument +trait HasDocumentAndPictureList { + /** + * Autorised mimtypes + * + * @var string[] + */ + private $autorisedMimTypes = [ + 'application/msword', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'image/jpeg', + 'image/png', + 'image/gif', + 'application/pdf', + 'application/vnd.ms-powerpoint', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'text/csv', + 'text/plain', + ]; + /** * Images rules * - * @param string $name - * @param boolean $required + * @param string $name * @return array */ public function documentsRules( - string $name = 'documents', - ?bool $required = null + string $name = 'docs', ): array { return [ - "{$name}" => ($required ? 'required' : 'nullable') . '|array', + "{$name}" => 'present|array', "{$name}.*" => [ - $required ? 'required' : 'nullable', + 'required', function (string $attribute, $value, callable $fail) { return $this->validateDocument($attribute, $value, $fail); } @@ -40,29 +59,28 @@ trait HasDocument */ private function validateDocument(string $attribute, mixed $value, callable $fail) { + // phpcs:enable if (!($useStorage = Storage::exists($value)) and !File::exists($value)) { $fail(trans(":attribute n'existe pas dans le système de fichier")); return; } - if ( - !\in_array($this->getUploadedFileMimeType($value, $useStorage), [ - 'application/pdf' - ]) - ) { - $fail(trans(":attribute doit être une image de type 'application/pdf'")); + if (!\in_array($this->getUploadedFileMimeType($value, $useStorage), $this->autorisedMimTypes)) { + $fail(trans(':attribute doit être un document de type :mimetypes', [ + 'mimetypes' => Str::of($this->autorisedMimTypes)->implode(' ou ') + ])); } } /** - * Merges documents fields with request data. + * Merges docs fields with request data. * * @param string $name * @return void */ - protected function mergeDocuments(string $name = 'documents'): void + protected function mergeDocuments(string $name = 'docs'): void { $documents = $this->{$name}; - $this->merge(['doc' => $this->docs ?? []]); + $this->merge([$name => $this->{$name} ?? []]); $this->merge(["{$name}Validate" => []]); if (is_array($documents)) { foreach ($documents as $key => $documentPath) { diff --git a/resources/ts/components/MultipleDocumentsInputComponent.vue b/resources/ts/components/MultipleDocumentsInputComponent.vue index f2e0425..ed33fa9 100644 --- a/resources/ts/components/MultipleDocumentsInputComponent.vue +++ b/resources/ts/components/MultipleDocumentsInputComponent.vue @@ -7,11 +7,11 @@
- - - - -
-
-

- {{ - parseValidationInput( - `${intName.replace(/[\[\]']+/g, "")}.${n - 1}`, - intAllErrors - ) - }} -

-
- -