Add Quilljs for rich text input instead of simple textereas
This commit is contained in:
@@ -10,11 +10,13 @@
|
||||
licence_plate: null,
|
||||
name: null,
|
||||
type: null,
|
||||
informations: '',
|
||||
},
|
||||
rules: {
|
||||
licence_plate: ['required'], // 'regexMatch:^[A-Z]{1,2}-[0-9]{1,3}-[A-Z]{1,2}$'
|
||||
name: ['required'],
|
||||
type: ['required'],
|
||||
informations: ['optional']
|
||||
},
|
||||
formValidation: {
|
||||
valid: false,
|
||||
@@ -22,9 +24,19 @@
|
||||
name: {valid: null},
|
||||
licence_plate: {valid: null},
|
||||
type: {valid: null},
|
||||
informations: {valid: null},
|
||||
}
|
||||
},
|
||||
isFormValid: true,
|
||||
init() {
|
||||
let quill = new Quill(this.$refs.quill, { theme: 'snow', modules: { toolbar: [[{ 'header': [1, 2, 3, 4, 5, 6, false] }], ['bold', 'italic', 'underline'], ['link', 'image']] } })
|
||||
|
||||
quill.root.innerHTML = this.fields.informations
|
||||
|
||||
quill.on('text-change', () => {
|
||||
this.fields.informations = quill.root.innerHTML
|
||||
})
|
||||
},
|
||||
validate() {
|
||||
this.formValidation = Iodine.assert(this.fields, this.rules)
|
||||
},
|
||||
@@ -94,13 +106,13 @@
|
||||
@blur="fields.licence_plate = fields.licence_plate.toUpperCase(); validateField('licence_plate')"
|
||||
:class="formValidation.fields.licence_plate.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
|
||||
</div>
|
||||
<div class="col-span-3">
|
||||
<!--<div class="col-span-3">
|
||||
<label for="kilometers"
|
||||
class="block text-sm font-medium text-gray-700">Kilométrage</label>
|
||||
<input type="text" name="kilometers" id="kilometers" placeholder="1 km"
|
||||
class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-2xl"
|
||||
x-model="fields.kilometers">
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -118,8 +130,8 @@
|
||||
<div class="mt-5">
|
||||
<label for="informations" class="block text-sm font-medium text-gray-700">Informations pratiques</label>
|
||||
<div class="mt-1">
|
||||
<textarea rows="4" name="informations" id="informations"
|
||||
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-2xl"></textarea>
|
||||
<div x-ref="quill" class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-b-2xl"></div>
|
||||
<input type="hidden" name="informations" x-model="fields.informations" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,4 +150,4 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user