From 1000ccc192f6fdbce30a7dad5b1d036339a2b5f7 Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Tue, 5 Sep 2023 16:51:23 +0200 Subject: [PATCH] User schedule notifications improvement --- .../EditNotificationScheduleModal.tsx | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/assets/user-profile/components/EditNotificationScheduleModal.tsx b/assets/user-profile/components/EditNotificationScheduleModal.tsx index 956f1b6a7..8c7e28366 100644 --- a/assets/user-profile/components/EditNotificationScheduleModal.tsx +++ b/assets/user-profile/components/EditNotificationScheduleModal.tsx @@ -26,6 +26,7 @@ interface IState { class EditNotificationScheduleModalComponent extends React.Component { + formRef: React.RefObject; constructor(props: IProps) { super(props); @@ -33,6 +34,9 @@ class EditNotificationScheduleModalComponent extends React.Component(); } componentDidMount() { @@ -49,13 +53,36 @@ class EditNotificationScheduleModalComponent extends React.Component) { + event.stopPropagation(); + event.preventDefault(); + + if (this.formRef.current == null) { + return; + } + + const inputs = this.formRef.current.querySelectorAll('input') as NodeListOf; + + const hasErrors = [...inputs].some(input => { + return input.checkValidity() !== true; + }); + + if (hasErrors === true) { + this.formRef.current.reportValidity(); + } else { + this.props.updateUserNotificationSchedules(this.state); + } + } + render() { return ( this.props.updateUserNotificationSchedules(this.state)} + onSubmit={() => { + this.formRef.current?.dispatchEvent(new Event('submit', {cancelable: true, bubbles: true})); + }} title={gettext('Edit global notifications schedule')} onSubmitLabel={gettext('Save')} - disableButtonOnSubmit={true} + disableButtonOnSubmit={false} className="edit-schedule__modal" >
@@ -69,7 +96,10 @@ class EditNotificationScheduleModalComponent extends React.Component {gettext('Daily, at:')} -
+ this.onSubmitForm(event)} + >
{ this.updateTime(event.target.value, 0); }} + step="900" + min="00:00" /> { this.updateTime(event.target.value, 1); }} + step="900" + min="00:00" /> { this.updateTime(event.target.value, 2); }} + step="900" + min="00:00" />