search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Confirm pop up on calendar

Asked by Byron D
21 days ago.

I have set up a form where if the user sets up a date in past the user will be prompted with a confirmation box.
However sometimes the confirmation dialog box does not block the next step. If I click next on calendar box the confirmation will trigger again and sometimes the if statement does not sometimes hold true if I pick today's date.

async validateDateRequired(args) {
        const value = args.value || "";
        if (value.trim().length === 0) {
            args.valid = false;
            args.message = "Date required";
        }

        if (DayPilot.Date.today() > args.value) {
           
        const modal =  await DayPilot.Modal.confirm("Date scheduled in the pass. Continue?");
            if (modal.canceled) {
                args.valid = false;
                args.message = "Valid date is required"
            }
        }
    },
////////////
assignmentForm(title, groups) {
        const form = [
            {name: title},
            {name: 'Group', id: 'group_id', type: 'select', options: groups, onValidate: this.validateGroupRequired },
            {name: "Start date", id: "start", type: "date", dateFormat: "d/M/yyyy", onValidate: this.validateDateRequired },
        ];

        return form;
    },
////////
const form = this.assignmentForm(title, responseJson.data);

        const modal = await DayPilot.Modal.form(form, item, { okText: 'Assign', cancelText: 'Close'}); 

        if (modal.canceled) {
            return;
        }

api call 
Answer posted by Dan Letecky [DayPilot]
21 days ago.

The onValidate event handler can't be asynchronous. Every change of "args" made after the "await" call in validateDateRequired() method will be ignored.

If there are values which you allow but require additional confirmation, I recommend moving all these warnings to another dialog that you show _after_ the main input dialog closes.

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):