Skip to content

Commit a4b30ae

Browse files
committed
fix recurrence form state
1 parent ac7069f commit a4b30ae

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

packages/devextreme/js/__internal/scheduler/appointment_popup/m_form.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@ export class AppointmentForm {
280280
this.updateDateEditorsValues();
281281
}
282282

283+
if (isRecurrenceRuleChanged || startDateExpr === dataField) {
284+
this._recurrenceForm.updateRecurrenceFormValues(
285+
this.recurrenceRuleRaw,
286+
this.startDate,
287+
);
288+
}
289+
283290
if (isRecurrenceRuleChanged) {
284291
this.updateRepeatEditorValue();
285292
}
@@ -663,8 +670,14 @@ export class AppointmentForm {
663670
onValueChanged: (e): void => {
664671
if (e.value === repeatNeverValue) {
665672
this.dxForm.updateData(recurrenceRuleExpr, '');
666-
this._recurrenceForm.recurrenceRule = new RecurrenceRule('', this.startDate);
667-
} else if (e.event) {
673+
} else {
674+
const currentRecurrenceRule = this._recurrenceForm.recurrenceRule.toString() ?? '';
675+
const recurrenceRule = new RecurrenceRule(currentRecurrenceRule, this.startDate);
676+
recurrenceRule.frequency = e.value;
677+
this.dxForm.updateData(recurrenceRuleExpr, recurrenceRule.toString());
678+
}
679+
680+
if (e.value !== repeatNeverValue && e.event) {
668681
this.showRecurrenceGroup();
669682
}
670683

@@ -847,14 +860,6 @@ export class AppointmentForm {
847860
this._$recurrenceGroup?.removeClass(CLASSES.recurrenceHidden);
848861
this._$recurrenceGroup?.removeAttr('tabindex');
849862

850-
const repeatEditorValue = this.dxForm.getEditor(REPEAT_EDITOR_NAME)?.option('value');
851-
852-
this._recurrenceForm.updateRecurrenceFormValues(
853-
repeatEditorValue,
854-
this.recurrenceRuleRaw,
855-
this.startDate,
856-
);
857-
858863
this._popup.updateToolbarForRecurrenceGroup();
859864
}
860865

@@ -873,7 +878,6 @@ export class AppointmentForm {
873878
this._$recurrenceGroup?.attr('tabindex', '-1');
874879

875880
this._popup.updateToolbarForMainGroup();
876-
this.updateRepeatEditorValue();
877881
}
878882

879883
saveRecurrenceValue(): void {
@@ -932,18 +936,12 @@ export class AppointmentForm {
932936

933937
if (this.recurrenceRuleRaw === null) {
934938
repeatEditor.option('value', repeatNeverValue);
935-
this._recurrenceForm.recurrenceRule = new RecurrenceRule('', this.startDate);
936939
} else {
937940
const recurrenceRule = new RecurrenceRule(this.recurrenceRuleRaw, this.startDate);
938941
const { frequency } = recurrenceRule;
939942
const value = frequency ?? repeatNeverValue;
940943

941944
repeatEditor.option('value', value);
942-
this._recurrenceForm.updateRecurrenceFormValues(
943-
value === repeatNeverValue ? '' : value,
944-
this.recurrenceRuleRaw,
945-
this.startDate,
946-
);
947945
}
948946
}
949947

packages/devextreme/js/__internal/scheduler/appointment_popup/m_recurrence_form.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -540,18 +540,16 @@ export class RecurrenceForm {
540540
}
541541

542542
updateRecurrenceFormValues(
543-
repeatEditorValue: string,
544543
recurrenceRuleRaw: string | null,
545544
startDate: Date | null,
546545
): void {
547546
this.recurrenceRule = this.createRecurrenceRule(
548-
repeatEditorValue,
549547
recurrenceRuleRaw,
550548
startDate,
551549
);
552550

553551
this.dxForm.getEditor(EDITOR_NAMES.recurrenceStartDateEditor)?.option('value', this.recurrenceRule.startDate);
554-
this.dxForm.getEditor(EDITOR_NAMES.recurrencePeriodEditor)?.option('value', repeatEditorValue);
552+
this.dxForm.getEditor(EDITOR_NAMES.recurrencePeriodEditor)?.option('value', this.recurrenceRule.frequency);
555553
this.dxForm.getEditor(EDITOR_NAMES.recurrenceCountEditor)?.option('value', this.recurrenceRule.interval);
556554
this.dxForm.getEditor(EDITOR_NAMES.recurrenceRepeatEndEditor)?.option('value', this.recurrenceRule.repeatEnd);
557555
this.dxForm.getEditor(EDITOR_NAMES.recurrenceEndUntilEditor)?.option('value', this.recurrenceRule.until);
@@ -562,22 +560,17 @@ export class RecurrenceForm {
562560
}
563561

564562
private createRecurrenceRule(
565-
repeatEditorValue: string,
566563
recurrenceRuleRaw: string | null,
567564
startDate: Date | null,
568565
): RecurrenceRule {
569566
const recurrenceRule = new RecurrenceRule(recurrenceRuleRaw ?? '', startDate);
570-
const { frequency } = recurrenceRule;
571567

572-
if (frequency !== repeatEditorValue) {
573-
const newRecurrenceRule = new RecurrenceRule(`freq=${repeatEditorValue};`, startDate);
568+
if (recurrenceRule.byDay.length === 0) {
574569
const defaultByDay = [
575570
weekDays[startDate?.getDay() ?? this.scheduler.getFirstDayOfWeek()],
576571
];
577572

578-
newRecurrenceRule.byDay = defaultByDay;
579-
580-
return newRecurrenceRule;
573+
recurrenceRule.byDay = defaultByDay;
581574
}
582575

583576
return recurrenceRule;

0 commit comments

Comments
 (0)