Skip to content

Commit 2e3de5c

Browse files
committed
fix: fix bug when opening appointment with predefined recurrent rule
1 parent 04e6e9a commit 2e3de5c

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

apps/react-storybook/stories/scheduler/SchedulerFormCustomization.stories.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ export const LegacyPopup: Story = {
348348
<ReactScheduler
349349
ref={schedulerRef}
350350
{...baseConfig}
351+
onAppointmentUpdating={(e) => {
352+
delete e.newData.repeat;
353+
}}
354+
onAppointmentAdding={(e) => {
355+
delete e.appointmentData.repeat;
356+
}}
351357
editing={{
352358
popup: {
353359
maxWidth: 800,
@@ -382,6 +388,12 @@ export const LegacyPopup: Story = {
382388
form: {
383389
onContentReady: function (e) {
384390
form = e.component;
391+
392+
form.on('fieldDataChanged', (e) => {
393+
if (e.dataField === 'recurrenceRule') {
394+
form?.option('formData.repeat', !!e.value)
395+
}
396+
});
385397
},
386398
iconsShowMode: "both",
387399
items: [
@@ -401,23 +413,16 @@ export const LegacyPopup: Story = {
401413
dataField: "repeat",
402414
editorOptions: {
403415
onValueChanged: (e) => {
404-
if (e.value === true) {
405-
form?.option("colCount", 2);
406-
416+
if (e.value) {
407417
const recurrenceRule = form?.option('formData')?.recurrenceRule;
408418

409-
form?.option('formData', {
410-
...form.option('formData'),
411-
recurrenceRule: recurrenceRule || "FREQ=DAILY"
412-
})
413-
form?.itemOption("recurrenceGroup", "cssClass", "");
419+
form?.option("colCount", 2);
420+
form?.option('formData.recurrenceRule', recurrenceRule || "FREQ=DAILY");
421+
form?.itemOption("recurrenceGroup", "visible", true);
414422
} else {
415423
form?.option("colCount", 1);
416-
form?.option('formData', {
417-
...form.option('formData'),
418-
recurrenceRule: ""
419-
})
420-
form?.itemOption("recurrenceGroup", "cssClass", "dx-hidden");
424+
form?.option('formData.recurrenceRule', "");
425+
form?.itemOption("recurrenceGroup", "visible", false);
421426
}
422427
},
423428
},
@@ -431,6 +436,8 @@ export const LegacyPopup: Story = {
431436
{
432437
name: "recurrenceGroup",
433438
itemType: "group",
439+
cssClass: "",
440+
visible: false,
434441
items: [
435442
"recurrenceRuleGroup",
436443
"recurrenceEndGroup",

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export class RecurrenceForm {
179179

180180
setReadOnly(value: boolean): void {
181181
this._readOnly = value;
182-
// this.updateWeekDaysButtons();
183182
}
184183

185184
createRecurrenceFormGroup(): GroupItem {
@@ -368,8 +367,11 @@ export class RecurrenceForm {
368367
this.recurrenceRule.byDay.push(item.key);
369368
}
370369

371-
// todo: update state only of the current button and remove this.updateWeekDaysButtons
372-
this.updateWeekDaysButtons();
370+
const button = this._weekDayButtons[item.key];
371+
const newIsSelected = this.recurrenceRule.byDay.includes(item.key);
372+
373+
button.option('stylingMode', newIsSelected ? 'contained' : 'outlined');
374+
button.option('type', newIsSelected ? 'default' : 'normal');
373375
},
374376
});
375377
});
@@ -626,14 +628,4 @@ export class RecurrenceForm {
626628

627629
this.dxForm.endUpdate();
628630
}
629-
630-
private updateWeekDaysButtons(): void {
631-
Object.entries(this._weekDayButtons).forEach(([dayKey, button]) => {
632-
const isSelected = this.recurrenceRule.byDay.includes(dayKey);
633-
634-
button.option('stylingMode', isSelected ? 'contained' : 'outlined');
635-
button.option('type', isSelected ? 'default' : 'normal');
636-
// button.option('disabled', this._readOnly);
637-
});
638-
}
639631
}

0 commit comments

Comments
 (0)