Sha256: 2d265e398b4284e55dd89d32cb12eae277a8b91bd3d54930baa38ba2b769159b

Contents?: true

Size: 974 Bytes

Versions: 2

Compression:

Stored size: 974 Bytes

Contents

import {Controller} from "@hotwired/stimulus"
import Sortable from "sortablejs";
import { createPopper } from '@popperjs/core';

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

2 entries across 2 versions & 1 rubygems

Version Path
headmin-0.2.9 src/js/headmin/controllers/date_range_controller.js
headmin-0.2.8 src/js/headmin/controllers/date_range_controller.js