Bump inputs form base project

This commit is contained in:
Jérémy Munsch 2023-12-21 13:56:34 +01:00
parent f34bb70504
commit fed7a112c2
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
24 changed files with 418 additions and 247 deletions

View file

@ -13,26 +13,27 @@ return [
],
'helpers' => [
'list' => 'List',
'list_all' => 'List all :model',
'create_model' => 'Create :model',
'view_model' => 'View :model',
'update_model' => 'Update :model',
'duplicate_model' => 'Duplicate :model',
'delete_model' => 'Delete :model',
'save_model' => 'Save :model',
'edit_model' => 'Edit :model',
'no_results' => 'No results for :models',
'publish' => 'Publish',
'unpublish' => 'Unpublish',
'seo_title' => 'Must give a precise description of the page, which is recommended for optimum
'list' => 'List',
'list_all' => 'List all :model',
'create_model' => 'Create :model',
'view_model' => 'View :model',
'update_model' => 'Update :model',
'duplicate_model' => 'Duplicate :model',
'delete_model' => 'Delete :model',
'save_model' => 'Save :model',
'edit_model' => 'Edit :model',
'no_results' => 'No results for :models',
'publish' => 'Publish',
'unpublish' => 'Unpublish',
'seo_title' => 'Must give a precise description of the page, which is recommended for optimum
positioning in search engines (<title> tag).',
'seo_description' => 'Must give a precise description of the page content (<meta> description tag).',
'required_fields' => 'Required fields',
'seo_description' => 'Must give a precise description of the page content (<meta> description tag).',
'required_fields' => 'Required fields',
'visibility_with_dates' => 'This field will only have an effect if no date is entered.',
'publish_at' => 'The :model will be published from that date.',
'unpublish_at' => 'The :model will be unpublished from that date.',
'nutritionnal_values' => 'Values must be given in grams, except for energy in kJ and kcal.',
'publish_at' => 'The :model will be published from that date.',
'unpublish_at' => 'The :model will be unpublished from that date.',
'nutritionnal_values' => 'Values must be given in grams, except for energy in kJ and kcal.',
'year' => 'Year of :model'
],
'libs' => [

View file

@ -13,27 +13,35 @@ return [
],
'helpers' => [
'list' => 'Liste',
'list_all' => 'Lister tous les :model',
'create_model' => 'Créer :model',
'view_model' => 'Voir :model',
'update_model' => 'Éditer :model',
'duplicate_model' => 'Dupliquer :model',
'delete_model' => 'Supprimer :model',
'save_model' => 'Sauvegarder :model',
'edit_model' => 'Mettre à jour :model',
'no_results' => 'Aucun résultat pour :model',
'publish' => 'Publié',
'unpublish' => 'Dépublié',
'seo_title' => 'Doit décrire précisément la page, recommandation pour un positionnement
'list' => 'Liste',
'list_all' => 'Lister tous les :model',
'create_model' => 'Créer :model',
'view_model' => 'Voir :model',
'update_model' => 'Éditer :model',
'duplicate_model' => 'Dupliquer :model',
'delete_model' => 'Supprimer :model',
'save_model' => 'Sauvegarder :model',
'edit_model' => 'Mettre à jour :model',
'no_results' => 'Aucun résultat pour :model',
'publish' => 'Publié',
'unpublish' => 'Dépublié',
'seo_title' => 'Doit décrire précisément la page, recommandation pour un positionnement
optimal dans les moteurs de recherche (balise <title>).',
'seo_description' => 'Doit décrire précisément le contenu de la page (balise <meta> description).',
'required_fields' => 'Champs obligatoires',
'seo_description' => 'Doit décrire précisément le contenu de la page (balise <meta> description).',
'required_fields' => 'Champs obligatoires',
'visibility_with_dates' => 'Ce champ n\'aura d\'effet que si aucune date n\'est renseignée.',
'publish_at' => 'Le :model sera publié à partir de cette date.',
'unpublish_at' => 'Le :model sera dépublié à partir de cette date.',
'nutritionnal_values' => 'Les valeurs doivent être renseignées en grammes,
'publish_at' => ':model sera publié à partir de cette date.',
'unpublish_at' => ':model sera dépublié à partir de cette date.',
'nutritionnal_values' => 'Les valeurs doivent être renseignées en grammes,
exceptés pour l\'énergie en kJ et en kcal.',
'new_tab_boolean' => 'Cocher pour ouvrir dans un nouvel onglet.',
'game_text' => 'Doit contenir au minimum 15 caractères et au maximum 32 mots.',
'url' => 'Doit être une URL valide.',
'year' => 'Année du :model',
],
'labels' => [
'new_tab_boolean' => 'Ouvrir dans un nouvel onglet ?',
],
'libs' => [
@ -57,7 +65,6 @@ return [
'publish_status_saved' => 'Changement de l\'état de publication réussi !',
'right' => 'Vous n\'avez pas les droits pour accéder à cette partie !',
'theme_updated' => 'Le thème a été mis à jour !',
],
'minicrud' => [

View file

@ -67,9 +67,9 @@ 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";
import parseLaravelErrorMessages from "./../../modules/parseLaravelErrorMessages";
import route from "./../../modules/route";
import trans from "./../../modules/trans";
export default defineComponent({
name: "BelongsToManyDropdownComponent",
@ -77,6 +77,26 @@ export default defineComponent({
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;
@ -104,26 +124,6 @@ export default defineComponent({
message: null,
};
},
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;
},
methods: {
parseTags(selectedItems: Array<CustomTag>): Array<CustomTag> {
return selectedItems.map((item: CustomTag) => {
@ -196,13 +196,7 @@ export default defineComponent({
</script>
<style lang="scss">
@import url("./../../../js/vendor/ckeditor/build/styles.css");
.belongs-to-many-dropdown {
// 2. Include functions first (so you can manipulate colors, SVGs, calc, etc)
@import "bootstrap/scss/functions";
// 3. Include remainder of required Bootstrap stylesheets
@import "bootstrap/scss/variables";
&, .vue-tags-input {
max-width: 100% !important;
}
@ -243,9 +237,6 @@ export default defineComponent({
background-color: var(--bs-gray-300) !important;
color: var(--bs-gray-900) !important;
}
&item {
color: $body-color;
}
}
.message {

View file

@ -380,6 +380,7 @@
class="form-text text-body-secondary d-block"
>{{ __("vue.ImageInputComponent.preview_picture") }}</small>
<img
v-if="intValue"
class="img-fluid"
:src="intValue"
:alt="__('Image placeholder')"
@ -399,8 +400,8 @@
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import Cropper from "cropperjs";
import { defineComponent } from "vue";
import bsTooltips from "../../modules/bsTooltips";
import trans from "../../modules/trans";
import bsTooltips from "./../../modules/bsTooltips";
import trans from "./../../modules/trans";
const UNITS = [
"byte",
@ -431,6 +432,7 @@ export default defineComponent({
mounted() {
const json = String(this.$attrs.json ?? "");
this.initTooltips();
if (json.length) {
// * Init uppon Laravel Blade
const data = JSON.parse(json);
@ -453,6 +455,10 @@ export default defineComponent({
if (data.browseEvent !== undefined) {
this.intBrowseEvent = data.browseEvent ? true : false;
}
this.intHasImage = false;
if (this.intValue.length) {
this.fetchPictureFromPath(`${this.intValue}`);
}
} else {
// * Init Uppon Vue component
this.intId = this.id;
@ -469,7 +475,6 @@ export default defineComponent({
this.intRequired = this.required;
this.intBrowseEvent = this.browseEvent;
}
this.intHasImage = false;
},
props: {
id: {
@ -603,7 +608,7 @@ export default defineComponent({
},
},
watch: {
intRotationValue(value) {
intRotationValue(value: number) {
if (!this.intCropper) {
return;
}
@ -628,37 +633,15 @@ export default defineComponent({
} else {
this.intHasImage = true;
}
// * Using browse event, If user changed imagem recompile blob (File Upload storage strategy)
if (this.inTbrowseEvent && this.inThasImage) {
const actualImage = this.$refs.actualImage as HTMLInputElement,
container = new DataTransfer();
this.$nextTick(() => {
this.intValue = value.replace(/^\/|^/, "/");
this.intValueFileName = value.replace(/^\/|^/, "");
fetch(this.intValue)
.then((response) => {
this.intOriginalFileName = decodeURI(response.url.substring(
response.url.lastIndexOf("/") + 1
));
return response.blob();
})
.then((blob: Blob) => {
if (!actualImage.files) {
throw new Error("3- missing files list");
}
this.fetchDataUrlImageSizes(this.inTvalue);
const file = new File([blob], this.inTvalueFileName, {
type: "image/png",
lastModified: new Date().getTime(),
});
this.intHasImage = true;
this.intOriginalFile = file;
this.$emit("imageFile", file);
container.items.add(file);
actualImage.files = container.files;
this.changedImage();
});
});
// * Using browse event, If user changed image recompile blob (File Upload storage strategy)
if (this.browseEvent && this.intHasImage) {
this.$nextTick(() => this.fetchPictureFromPath(value));
} else {
this.intValue = value;
if (this.intValue.length) {
this.intValueFileName = this.intValue.replace(/^\/|^/, "");
this.intValue = this.intValue.replace(/^\/|^/, "/");
}
}
},
},
@ -761,6 +744,42 @@ export default defineComponent({
this.$nextTick(() => (this.intHasImage = false));
this.$emit("imageFile", null);
},
fetchPictureFromPath(value: string): void {
const actualImage: HTMLInputElement = this.$refs.actualImage as HTMLInputElement,
container: DataTransfer = new DataTransfer();
this.$nextTick(() => {
const stringValue: string = value.replace(/^\/|^/, "/"),
stringFileName: string = stringValue.substring(stringValue.lastIndexOf("/")).replace(/^\/|^/, "");
fetch(stringValue)
.then((response) => {
this.intOriginalFileName = decodeURI(response.url.substring(
response.url.lastIndexOf("/") + 1
));
return response.blob();
})
.then((blob: Blob) => {
if (!actualImage.files) {
throw new Error("3- missing files list");
}
this.fetchDataUrlImageSizes(stringValue);
const file = new File([blob], stringFileName, {
type: "image/png",
lastModified: new Date().getTime(),
});
this.intValue = stringValue;
this.intValueFileName = stringFileName;
this.intHasImage = true;
this.intOriginalFile = file;
this.$emit("imageFile", file);
container.items.add(file);
actualImage.files = container.files;
this.changedImage();
});
});
},
changedImage() {
const reader = new FileReader(),
actualImage = this.$refs.actualImage as HTMLInputElement;

View file

@ -6,7 +6,7 @@
<textarea
ref="textarea"
:id="intId"
:class="`input-text-auto-component form-control ${intClass}`"
:class="`input-text-auto-component ${intClass}`"
:name="intName"
:aria-describedby="intAriaDescribedby"
:placeholder="intPlaceholder"
@ -19,12 +19,13 @@
<script lang="ts">
import { defineComponent, ref } from "vue";
import trans from "../../modules/trans";
import trans from "./../../modules/trans";
import WordCounter from "./WordCounterComponent.vue";
const textarea = ref<HTMLTextAreaElement | null>(null);
export default defineComponent({
name: "InputTextAutoComponent",
inheritAttrs: false,
mixins: [trans],
components: {

View file

@ -1,32 +1,31 @@
<template>
<div :class="`password-visibility-${inputId} h-100`">
<button
@click.prevent="toggleVisibility()"
@keydown="keydown"
:class="`btn btn-primary rounded-0 rounded-end password-visibility-${inputId} h-100`"
:aria-pressed="visible"
>
<span
v-if="visible"
class="text-bg-primary reveal d-flex justify-content-center align-items-center h-100"
@click.prevent="toggleVisibility()"
type="button"
:title="__('vue.PasswordVisibility.hide')"
:title="visible ? __('vue.PasswordVisibility.hide') : __('vue.PasswordVisibility.show')"
data-bs="tooltip"
>
<FontAwesomeIcon
v-if="visible"
icon="fas fa-eye-slash"
:aria-hidden="true"
/>
</span>
<span
v-else
class="text-bg-primary reveal d-flex justify-content-center align-items-center h-100"
@click.prevent="toggleVisibility()"
type="button"
:title="__('vue.PasswordVisibility.show')"
data-bs="tooltip"
>
<FontAwesomeIcon
v-else
icon="fas fa-eye"
:aria-hidden="true"
/>
</span>
</div>
</button>
</template>
<script lang="ts">
@ -73,6 +72,19 @@ export default defineComponent({
});
},
methods: {
keydown(e:KeyboardEvent):void {
if (
e.key === " " ||
e.code === "Space" ||
e.keyCode === 32 ||
e.key === "Enter" ||
e.code === "Enter" ||
e.keyCode === 13
) {
this.toggleVisibility();
e.preventDefault();
}
},
/**
* Update password status (visible, hidden).
*/

View file

@ -11,9 +11,10 @@
<script lang="ts">
import { defineComponent } from "vue";
import trans from "../../modules/trans";
import trans from "./../../modules/trans";
export default defineComponent({
name: "WordCounterComponent",
mixins: [trans],
mounted() {
const json = String(this.$attrs.json ?? "{}");

View file

@ -223,10 +223,8 @@
</div>
</fieldset>
</div>
<div class="row">
<div class="col text-center">
<p><b>* {{ __('crud.helpers.required_fields') }}</b></p>
</div>
<div class="col-12 text-center">
<p><b>* {{ __('crud.helpers.required_fields') }}</b></p>
</div>
</div>

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -17,15 +18,18 @@
@endif
<select
id="{{ $id }}"
class="form-select @if($errors->has($name)) is-invalid @endif"
@class([
'form-select',
'is-invalid' => $errors->has($name)
])
name="{{ $name }}"
@if(!empty($size))
size="{{ $size }}"
@endif
aria-describedby="{{ $id }}Help"
@if(!empty($required))
required
@endif>
@disabled(!empty($disabled))
@readonly(!empty($readonly))
@required(!empty($required))>
@foreach ($associatedModels as $associatedModel)
<option
value="{{ $associatedModel->id }}"
@ -38,6 +42,6 @@
</select>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{{ $id }}Help",
'helperId' => "{$id}Help",
'helper' => $helper
])

View file

@ -0,0 +1,71 @@
{{-- blade-formatter-disable --}}
@if(!empty($label))
<label for="{{ $id }}" class="col-form-label">
<b>{{ $label }} {{ $required ? '*' : '' }}</b>
</label>
@endif
@if(isset($appendText))
<div class="input-group">
@endif
<input
id="{{ $id }}"
name="{{ $name }}"
type="text"
data-jscolor=""
class="form-control"
aria-describedby="{{ $id }}Help"
value="{{ old($name, $model->{$name} ?? $value ?? '') }}"
@if(!empty($disabled))disabled @endif
@if(!empty($readonly))readonly @endif
@if(!empty($required))required @endif>
@if(isset($appendText))
<label class="input-group-text">{{ $appendText }}</label>
</div>
@endif
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{$id}Help",
'helper' => $helper
])
@push('scripts')
<script @if(isset($nonce) and is_string($nonce)) nonce="{{ $nonce }}" @endif>
window.addEventListener("DOMContentLoaded", (event) => {
// https://stackoverflow.com/a/35970186/4355295
let __invertColor = function(hex, bw) {
if (hex.indexOf('#') === 0) {
hex = hex.slice(1);
}
// convert 3-digit hex to 6-digits.
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
if (hex.length !== 6) {
throw new Error('Invalid HEX color.');
}
var r = parseInt(hex.slice(0, 2), 16),
g = parseInt(hex.slice(2, 4), 16),
b = parseInt(hex.slice(4, 6), 16);
if (bw) {
// https://stackoverflow.com/a/3943023/112731
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
? '#000000'
: '#FFFFFF';
}
// invert color components
r = (255 - r).toString(16);
g = (255 - g).toString(16);
b = (255 - b).toString(16);
// pad each with zeros and return
return "#" + r.padStart(1, '0') + g.padStart(1, '0') + b.padStart(1, '0');
}
let colorSpans = document.getElementsByClassName('colorize');
if(colorSpans.length) {
for(let colorSpan of colorSpans) {
colorSpan.style.color = __invertColor(colorSpan.textContent, true);
colorSpan.style.backgroundColor = colorSpan.textContent;
}
}
});
</script>
@endpush

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -9,39 +10,52 @@
of the input. || string || OPTIONNAL || null
$required || Is the field required ? || boolean || OPTIONNAL || false
$value || The default value of the input. || integer || OPTIONNAL || 0
$step || The step of the input. || integer|float || OPTIONNAL || 1
$step || The step of the input. || integer || OPTIONNAL || 1
$unsigned || Is the value unsigned ? || boolean || OPTIONNAL || false
$min || The min value of the input. || integer || OPTIONNAL || !empty($unsigned) ? 0 : -2147483648
$max || The max value of the input. || integer || OPTIONNAL || !empty($unsigned) ? 4294967295 : 2147483647
$model || The model we're creating/editing || Model class || OPTIONNAL || null
--}}
@if (!empty($label))
<label class="col-form-label" for="{{ $id }}">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@if(!empty($label))
<label for="{{ $id }}" class="col-form-label">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@endif
@if (isset($appendText))
<div class="input-group">
@endif
<input class="form-control @if ($errors->has($name)) is-invalid @endif" id="{{ $id }}" name="{{ $name }}"
type="number" value="{{ Str::replace(',', '.', strval(old($name, $value ?? ($model->{$name} ?? 0)))) }}"
@if(isset($appendText))
<div class="input-group">
@endif
<input id="{{ $id }}"
name="{{ $name }}"
type="number"
value="{{ Str::replace(',', '.', strval(old($name, $value ?? $model->{$name} ?? 0))) }}"
@class([
'form-control',
'is-invalid' => $errors->has($name)
])
aria-describedby="{{ $id }}Help"
@if (!empty($step)) step="{{ Str::replace(',', '.', strval($step)) }}"
@else step="1" @endif
@if (!empty($max)) max="{{ $max }}"
@if(!empty($step))
step="{{ Str::replace(',', '.', strval($step)) }}"
@else step="1"
@endif
@if(!empty($max))
max="{{ $max }}"
@else
max="{{ !empty($unsigned) ? '4294967295' : '2147483647' }}" @endif
@if (!empty($min)) min="{{ $min }}"
max="{{ !empty($unsigned) ? '4294967295' : '2147483647' }}"
@endif
@if(!empty($min)) min="{{ $min }}"
@else
min="{{ !empty($unsigned) ? '0' : '-2147483648' }}" @endif
@if (!empty($required)) required @endif>
@if (isset($appendText))
min="{{ !empty($unsigned) ? '0' : '-2147483648' }}"
@endif
@disabled(!empty($disabled))
@readonly(!empty($readonly))
@required(!empty($required))>
@if(isset($appendText))
<label class="input-group-text">{{ $appendText }}</label>
</div>
</div>
@endif
@include('modules.input-error', [
'inputName' => $name,
'helperId' => '{{ $id }}Help',
'helper' => $helper,
'helperId' => "{$id}Help",
'helper' => $helper
])

View file

@ -10,15 +10,15 @@
$model || The model we're creating/editing || Model class || OPTIONNAL || null
--}}
@if(!empty($label))
<label for="{{ $id }}" class="col-form-label">
<b>{{ $label }} {{ $required ? '*' : '' }}</b>
</label>
@endif
@php
$value = old($name) ?? ($model->{$name} ?? []);
if (is_object($value) and $value instanceof \Illuminate\Support\Collection) {
// * Force beeing an array
$value = $value->all();
}
$data = [
'name' => $name,
'value' => old($name, $model->{$name} ?? []) ?? [],
'value' => Arr::wrap($value),
'placeholder' => $placeholder,
'itemsList' => $itemsList,
'itemLimit' => $itemLimit ?? null,

View file

@ -1,16 +1,16 @@
@php
$data = [
"name" => $name,
"label" => $label,
"value" => $value ?? [],
"placeholder" => $placeholder,
"itemsSelected" => $itemsSelected,
"itemsList" => $itemsList,
"itemLimit" => $itemLimit,
"showSpecificItem" => $showSpecificItem ?? null,
"errors" => $errors->getBag("default")->getMessages() ?? [],
'helper' => $helper,
'require' => $require
];
$data = [
'name' => $name,
'label' => $label,
'value' => $value ?? [],
'placeholder' => $placeholder,
'itemsSelected' => $itemsSelected,
'itemsList' => $itemsList,
'itemLimit' => $itemLimit,
'showSpecificItem' => $showSpecificItem ?? null,
'errors' => $errors->getBag('default')->getMessages() ?? [],
'helper' => $helper,
'require' => $require,
];
@endphp
<div class="select-multiple-enum" data-json='@json($data)'></div>

View file

@ -10,23 +10,27 @@
$model || The model we're creating/editing || Model class || OPTIONNAL || null
--}}
@if(!empty($label))
<label for="{{ $id }}" class="col-form-label">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@if (!empty($label))
<label class="col-form-label" for="{{ $id }}">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@endif
@php
$data = [
'name' => $name,
'text' => old($name, $model->{$name} ?? $value ?? '')
];
$data = [
'name' => $name,
'text' => old($name, $model->{$name} ?? ($value ?? '')),
];
@endphp
<div class="ck-editor" data-json='@json($data)'></div>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{$id}Help",
'helper' => $helper ?? __('crud.minicrud.text_warning') . '. ' . __('validation.min.string', [
'attribute' => $input['label'],
'min' => 15
]),
'helper' =>
$helper ??
__('crud.minicrud.text_warning') .
'. ' .
__('validation.min.string', [
'attribute' => $input['label'],
'min' => 15,
]),
])

View file

@ -1,7 +1,7 @@
<div class="container p-0 m-0">
<div class="container m-0 p-0">
<div class="row">
<div class="col">
<label for="{{ $name }}" class="col-form-label">
<label class="col-form-label" for="{{ $name }}">
<b>{{ $label }} {{ $required ? '*' : '' }}</b>
</label>
</div>
@ -9,16 +9,16 @@
<div class="row">
<div class="col">
@php
$data = [
'itemList' => old($name, $model->{$name} ?? []) ?? [],
'itemColumns' => $itemColumns,
'itemType' => $itemType,
'itemLimit' => $itemLimit ?? [],
'inputName' => $name,
'inputPlaceholder' => $inputPlaceholder,
'header' => $header ?? false,
'errors' => $errors->getBag('default')->getMessages() ?? []
];
$data = [
'itemList' => old($name, $model->{$name} ?? []) ?? [],
'itemColumns' => $itemColumns,
'itemType' => $itemType,
'itemLimit' => $itemLimit ?? [],
'inputName' => $name,
'inputPlaceholder' => $inputPlaceholder,
'header' => $header ?? false,
'errors' => $errors->getBag('default')->getMessages() ?? [],
];
@endphp
<div class="list-item" data-json='@json($data)'></div>
@include('modules.input-error', [

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -7,22 +8,24 @@
$label || The text displayed as a label. || string || OPTIONNAL || null
$required || Is the field required ? || boolean || OPTIONNAL || false
$model || The model we're creating/editing || Model class || OPTIONNAL || null
$type || The input data type || string || OPTIONNAL || datetime-local
$format || The inpute date format || string || OPTIONNAL || Y-m-d\TH:i
--}}
@if(!empty($label))
<label for="{{ $id }}" class="col-form-label">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@if (!empty($label))
<label class="col-form-label" for="{{ $id }}">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@endif
<input id="{{ $id }}"
name="{{ $name }}"
class="form-control @if($errors->has($name)) is-invalid @endif"
type="datetime-local"
class="form-control @if ($errors->has($name)) is-invalid @endif"
type="{{ $type ?? 'datetime-local' }}"
data-form-type="date"
aria-describedby="{{ "{$id}Help" }}"
value="{{ old($name, ((isset($model) and $model->{$name}) ? ($model->{$name}->format('Y-m-d\TH:i') ?? '') : '')) }}">
value="{{ old($name, (isset($model) and $model->{$name}) ? $model->{$name}->format($format ?? 'Y-m-d\TH:i') ?? '' : '') }}"
aria-describedby="{{ "{$id}Help" }}">
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{$id}Help",
'helper' => $helper
'helper' => $helper,
])

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -9,7 +10,7 @@
--}}
<div class="form-check form-switch ms-2">
<label class="col-form-label p-0" type="button" for="{{ $id }}"><b>{{ $label }}</b></label>
<label class="col-form-label p-0" for="{{ $id }}"><b>{{ $label }}</b></label>
<input
id="{{ $id }}"
aria-describedby="{{ $id }}Help"
@ -17,10 +18,13 @@
type="checkbox"
class="ml-2 form-check-input"
value="1"
@if(old($name, (old('_token') ? false : ($model->{$name} ?? false)))) checked @endif>
@disabled(!empty($disabled))
@readonly(!empty($readonly))
@required(!empty($required))
@checked(old($name, (old('_token') ? false : ($model->{$name} ?? false))))>
</div>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => '{{ $id }}Help' ,
'helperId' => "{$id}Help",
'helper' => $helper
])

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -17,7 +18,10 @@
@endif
<select
id="{{ $name }}"
class="form-select @if($errors->has($name)) is-invalid @endif"
@class([
'form-select',
'is-invalid' => $errors->has($name)
])
name="{{ $name }}"
aria-describedby="{{ $id }}Help"
@if(!empty($disabled))
@ -39,6 +43,6 @@
</select>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{{ $id }}Help",
'helperId' => "{$id}Help",
'helper' => $helper
])

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -10,8 +11,8 @@
$model || The model we're creating/editing || Model class || OPTIONNAL || null
--}}
@if(!empty($label))
<label for="{{ $id }}" class="col-form-label">
@if (!empty($label))
<label class="col-form-label" for="{{ $id }}">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@endif
@ -19,15 +20,15 @@
name="{{ $name }}"
type="email"
value="{{ old($name, $model->{$name} ?? '') }}"
class="form-control @if($errors->has($name)) is-invalid @endif"
class="form-control @if ($errors->has($name)) is-invalid @endif"
id="{{ $id }}"
aria-describedby="{{ $id }}Help"
placeholder="{{ $placeholder ?? __('aaa.bbb@example.com') }}"
@if(!empty($required))
required
@endif>
@disabled(!empty($disabled))
@readonly(!empty($readonly))
@required(!empty($required))>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => '{{ $id }}Help',
'helper' => $helper
'helperId' => "{$id}Help",
'helper' => $helper,
])

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -35,6 +36,32 @@
data-bs-toggle="tooltip">
{{ basename($model->{$name}) }}
</a>
@php
$removeBtnId = 'remove-btn-id-' . uniqid();
@endphp
<button class="btn btn-danger" id="{{ $removeBtnId }}" data-bs-toggle="tooltip"
title="{{ __('Supprimer le fichier :type', ['type' => $file ?? '.pdf']) }}">
<i class="fa fa-trash"></i>
</button>
@push('scripts')
<script nonce="{{ $nonce }}">
document.addEventListener('DOMContentLoaded', function() {
const removeBtn = document.getElementById('{{ $removeBtnId }}'),
input = removeBtn.parentElement.querySelector('input'),
link = removeBtn.parentElement.querySelector('a');
input.addEventListener('change', () => {
removeBtn.classList.remove('d-none');
link.classList.add('d-none');
});
removeBtn.addEventListener('click', (e) => {
e.preventDefault();
input.value = "";
removeBtn.classList.add('d-none');
link.classList.add('d-none');
});
});
</script>
@endpush
@endif
</div>
@include('modules.input-error', [

View file

@ -10,24 +10,23 @@
$model || The model we're creating/editing || Model class || OPTIONNAL || null
--}}
<label for="{{ $id }}" class="col-form-label">
<label class="col-form-label" for="{{ $id }}">
<b>{{ $label }} {{ $required ?? false ? '*' : '' }}</b>
</label>
@php
$invalid = !empty($errors->get($name)) ? 'is-invalid' : '';
$data = [
'id' => $id,
'class' => 'form-control ' . $invalid,
'name' => $name,
'placeholder' => $placeholder,
'ariaDescribedby' => "{$id}Help",
'required' => $required,
'value' => old($name, $model->{$name} ?? '')
];
$data = [
'id' => $id,
'class' => 'w-100 form-control ' . ($errors->has($name) ? 'is-invalid ' : ''),
'name' => $name,
'placeholder' => $placeholder,
'ariaDescribedby' => "{$id}Help",
'required' => $required,
'value' => old($name, $model->{$name} ?? ''),
];
@endphp
<div class="input-text-auto" data-json='@json($data)'></div>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{$id}Help",
'helper' => $helper
'helper' => $helper,
])

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -24,14 +25,18 @@
name="{{ $name }}"
type="password"
value="{{ old($name, $model->{$name} ?? '') }}"
class="form-control @if($errors->has($name)) is-invalid @endif @if(!empty($hasWordCounter ?? false)) need-word-counter-password @endif"
@class([
'form-control',
'is-invalid' => $errors->has($name),
'need-word-counter-password' => !empty($hasWordCounter ?? false)
])
id="{{ $id }}"
aria-describedby="{{ $id }}Help"
placeholder="{{ $placeholder ?? __('Un beau mot de passe') }}"
autocomplete="current-password"
@if(!empty($required))
required
@endif>
@disabled(!empty($disabled))
@readonly(!empty($readonly))
@required(!empty($required))>
@php $dataPassword = ['inputId' => $id]; @endphp
<span class="btn btn-primary password-visibility w-fit d-flex justify-content-center align-items-center p-0 @if(!empty($hasWordCounter ?? false)) need-word-counter-password-btn @endif"
data-json='@json($dataPassword)'>
@ -39,6 +44,6 @@
</div>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => $id . 'Help',
'helperId' => "{$id}Help",
'helper' => $helper
])

View file

@ -15,17 +15,17 @@
--}}
@php
$data = [
'id' => $id,
'name' => $name,
'helper' => $helper,
'width' => $width,
'height' => $height,
'value' => $model->{$name} ?? $value ?? '',
'preview' => $preview ?? false,
'browseEvent' => $browseEvent ?? false,
'required' => $required ?? false,
];
$data = [
'id' => $id,
'name' => $name,
'helper' => $helper,
'width' => $width,
'height' => $height,
'value' => $model->{$name} ?? ($value ?? ''),
'preview' => $preview ?? false,
'browseEvent' => $browseEvent ?? false,
'required' => $required ?? false,
];
@endphp
<div class="image-input" data-json='@json($data)'></div>
@include('modules.input-error', ['inputName' => $name, 'helper' => null])

View file

@ -1,3 +1,4 @@
{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
@ -24,12 +25,16 @@
type="text"
value="{{ old($name, $model->{$name} ?? $value ?? '') }}"
class="form-control @if($errors->has($name)) is-invalid @endif"
@class([
'form-control',
'is-invalid' => $errors->has($name)
])
id="{{ $id }}"
aria-describedby="{{ $id }}Help"
placeholder="{{ $placeholder ?? __('A beautiful title') }}"
@if(!empty($required))
required
@endif>
@disabled(!empty($disabled))
@readonly(!empty($readonly))
@required(!empty($required))>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => $id.'Help',