Sha256: e6f7a920aa843cfa8199d474a52b35c48c0b0473f6098e68b30757b59a7bc9b9
Contents?: true
Size: 892 Bytes
Versions: 4
Compression:
Stored size: 892 Bytes
Contents
import {Controller} from "@hotwired/stimulus" export default class extends Controller { static get targets() { return ["dateInput", "startDateInput", "endDateInput"] } update(event) { const flatpickr = event.target._flatpickr const startDate = flatpickr.selectedDates[0] const endDate = flatpickr.selectedDates[1] this.setStartDateInputValue(this.formatDate(startDate)) this.setEndDateInputValue(this.formatDate(endDate)) } setStartDateInputValue(value) { this.startDateInputTarget.value = value } setEndDateInputValue(value) { this.endDateInputTarget.value = value } formatDate(date) { if(date instanceof Date) { return date.toLocaleDateString('nl-BE', {day: '2-digit', month: '2-digit', year: 'numeric'}) } else { return null; } } }
Version data entries
4 entries across 4 versions & 1 rubygems