Skip to content

Commit 70844dd

Browse files
Scheduler — Popup keep resource state between openings (#32915)
1 parent d2afacb commit 70844dd

7 files changed

Lines changed: 20 additions & 147 deletions

File tree

apps/demos/Demos/Scheduler/ResolveTimeConflicts/Angular/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class AppComponent {
6262
onInitialized: (e: DxPopupTypes.InitializedEvent) => { this.popup = e.component; },
6363
onHidden: () => {
6464
this.setConflictError(false);
65-
this.form?.updateData('assigneeId', []);
6665
},
6766
};
6867

apps/demos/Demos/Scheduler/ResolveTimeConflicts/React/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ const App = () => {
157157
},
158158
onHidden: () => {
159159
setConflictError(false);
160-
formRef.current?.updateData('assigneeId', []);
161160
},
162161
}), [setConflictError]);
163162

apps/demos/Demos/Scheduler/ResolveTimeConflicts/ReactJs/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ const App = () => {
130130
},
131131
onHidden: () => {
132132
setConflictError(false);
133-
formRef.current?.updateData('assigneeId', []);
134133
},
135134
}),
136135
[setConflictError],

apps/demos/Demos/Scheduler/ResolveTimeConflicts/Vue/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ const popupOptions = {
186186
},
187187
onHidden: () => {
188188
setConflictError(false);
189-
form?.updateData('assigneeId', []);
190189
},
191190
};
192191

apps/demos/Demos/Scheduler/ResolveTimeConflicts/jQuery/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ $(() => {
2929
},
3030
onHidden: () => {
3131
setConflictError(false);
32-
form?.updateData('assigneeId', []);
3332
},
3433
},
3534
form: {

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

Lines changed: 5 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -377,79 +377,18 @@ describe('Appointment Form', () => {
377377
});
378378

379379
describe('State', () => {
380-
it('should have empty description, subject and timezone inputs when opening second common appointment', async () => {
381-
const { scheduler, POM } = await createScheduler({
382-
...getDefaultConfig(),
383-
editing: {
384-
allowUpdating: true,
385-
allowTimeZoneEditing: true,
386-
},
387-
});
388-
389-
scheduler.showAppointmentPopup({ ...commonAppointment });
390-
391-
POM.popup.setInputValue('descriptionEditor', 'temp');
392-
POM.popup.setInputValue('startDateTimeZoneEditor', 'America/Los_Angeles');
393-
POM.popup.setInputValue('endDateTimeZoneEditor', 'America/Anchorage');
394-
POM.popup.saveButton.click();
395-
396-
scheduler.showAppointmentPopup();
397-
398-
expect(POM.popup.getInputValue('subjectEditor')).toBe('');
399-
expect(POM.popup.getInputValue('descriptionEditor')).toBe('');
400-
expect(POM.popup.getInputValue('startDateTimeZoneEditor')).toBe('');
401-
expect(POM.popup.getInputValue('endDateTimeZoneEditor')).toBe('');
402-
});
403-
404-
it('should have correct form data when opening second appointment', async () => {
380+
it('should create a new form instance on each popup opening', async () => {
405381
const { scheduler, POM } = await createScheduler(getDefaultConfig());
406382

407383
scheduler.showAppointmentPopup(commonAppointment);
408-
409-
expect(POM.popup.dxForm.option('formData')).toMatchObject({ ...commonAppointment });
384+
const firstFormInstance = POM.popup.dxForm;
410385

411386
POM.popup.cancelButton.click();
412387

413-
scheduler.showAppointmentPopup(allDayAppointment);
414-
415-
expect(POM.popup.dxForm.option('formData')).toMatchObject({ ...allDayAppointment });
416-
});
417-
418-
it('should have empty resource editor value when opening second appointment', async () => {
419-
const { scheduler, POM } = await createScheduler({
420-
...getDefaultConfig(),
421-
resources: [{
422-
fieldExpr: 'roomId',
423-
dataSource: [
424-
{ text: 'Room 1', id: 1, color: '#00af2c' },
425-
{ text: 'Room 2', id: 2, color: '#56ca85' },
426-
{ text: 'Room 3', id: 3, color: '#8ecd3c' },
427-
],
428-
}],
429-
});
430-
431-
scheduler.showAppointmentPopup({
432-
text: 'Resource test app',
433-
startDate: new Date(2017, 4, 9, 9, 30),
434-
endDate: new Date(2017, 4, 9, 11),
435-
roomId: 1,
436-
});
437-
POM.popup.setInputValue('roomId', 2);
438-
scheduler.hideAppointmentPopup(true);
439-
440-
scheduler.showAppointmentPopup();
441-
expect(POM.popup.getInputValue('roomId')).toBe('');
442-
});
443-
444-
it('should have correct repeat editor value when opening recurring appointment after common appointment', async () => {
445-
const { scheduler, POM } = await createScheduler(getDefaultConfig());
446-
447-
scheduler.showAppointmentPopup({ ...commonAppointment });
448-
POM.popup.saveButton.click();
388+
scheduler.showAppointmentPopup(commonAppointment);
389+
const secondFormInstance = POM.popup.dxForm;
449390

450-
scheduler.showAppointmentPopup({ ...recurringAppointment });
451-
POM.popup.editSeriesButton.click();
452-
expect(POM.popup.getInputValue('repeatEditor')).toBe('Daily');
391+
expect(secondFormInstance).not.toBe(firstFormInstance);
453392
});
454393

455394
it('should have correct editor values when opening for empty date cell - 1', async () => {
@@ -939,36 +878,6 @@ describe('Appointment Form', () => {
939878
expect(POM.popup.getInputValue('endDateEditor')).toBe('5/1/2017');
940879
expect(POM.popup.isInputVisible('endTimeEditor')).toBeFalsy();
941880
});
942-
943-
it('should show correct dates after switching off allDay and canceling changes (T832711)', async () => {
944-
const { scheduler, POM } = await createScheduler(undefined);
945-
946-
scheduler.showAppointmentPopup(allDayAppointment);
947-
POM.popup.getInput('allDayEditor').click();
948-
POM.popup.cancelButton.click();
949-
950-
scheduler.showAppointmentPopup(allDayAppointment);
951-
952-
expect(POM.popup.getInputValue('startDateEditor')).toBe('5/1/2017');
953-
expect(POM.popup.isInputVisible('startTimeEditor')).toBeFalsy();
954-
expect(POM.popup.getInputValue('endDateEditor')).toBe('5/1/2017');
955-
expect(POM.popup.isInputVisible('endTimeEditor')).toBeFalsy();
956-
});
957-
958-
it('should show correct dates after switching on allDay and canceling changes (T832711)', async () => {
959-
const { scheduler, POM } = await createScheduler(getDefaultConfig());
960-
961-
scheduler.showAppointmentPopup(commonAppointment);
962-
POM.popup.getInput('allDayEditor').click();
963-
POM.popup.cancelButton.click();
964-
965-
scheduler.showAppointmentPopup(commonAppointment);
966-
967-
expect(POM.popup.getInputValue('startDateEditor')).toBe('5/9/2017');
968-
expect(POM.popup.getInputValue('startTimeEditor')).toBe('9:30 AM');
969-
expect(POM.popup.getInputValue('endDateEditor')).toBe('5/9/2017');
970-
expect(POM.popup.getInputValue('endTimeEditor')).toBe('11:00 AM');
971-
});
972881
});
973882

974883
describe('Timezone Editors', () => {
@@ -1527,45 +1436,6 @@ describe('Appointment Form', () => {
15271436
expect(POM.popup.getInputValue('recurrenceRepeatEndEditor')).toBe('count');
15281437
expect(POM.popup.getInputValue('recurrenceEndCountEditor')).toBe('10 occurrence(s)');
15291438
});
1530-
1531-
it('should have correct input values when opening second weekly recurring appointment', async () => {
1532-
const { scheduler, POM } = await createScheduler(getDefaultConfig());
1533-
1534-
const appointment1 = {
1535-
text: 'Meeting',
1536-
startDate: new Date(2017, 4, 1, 10, 30),
1537-
endDate: new Date(2017, 4, 1, 11),
1538-
recurrenceRule: 'FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR;COUNT=5',
1539-
repeatEnd: 'count',
1540-
};
1541-
const appointment2 = {
1542-
text: 'Meeting',
1543-
startDate: new Date(2017, 4, 2, 10, 30),
1544-
endDate: new Date(2017, 4, 2, 11),
1545-
recurrenceRule: 'FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH;COUNT=5',
1546-
repeatEnd: 'count',
1547-
};
1548-
1549-
scheduler.showAppointmentPopup(appointment1);
1550-
POM.popup.editSeriesButton.click();
1551-
POM.popup.recurrenceSettingsButton.click();
1552-
1553-
scheduler.hideAppointmentPopup();
1554-
1555-
scheduler.showAppointmentPopup(appointment2);
1556-
POM.popup.editSeriesButton.click();
1557-
POM.popup.recurrenceSettingsButton.click();
1558-
1559-
expect(POM.popup.getInputValue('repeatEditor')).toBe('Weekly');
1560-
expect(POM.popup.getInputValue('recurrenceStartDateEditor')).toBe('5/2/2017');
1561-
expect(POM.popup.getInputValue('recurrenceCountEditor')).toBe('1');
1562-
expect(POM.popup.getInputValue('recurrencePeriodEditor')).toBe('Week(s)');
1563-
1564-
const expectedWeekDaysSelection = [false, true, false, true, false, false, false];
1565-
expect(POM.popup.getWeekDaysSelection()).toEqual(expectedWeekDaysSelection);
1566-
1567-
expect(POM.popup.getInputValue('recurrenceEndCountEditor')).toBe('5 occurrence(s)');
1568-
});
15691439
});
15701440

15711441
describe('Repeat End Values Preservation', () => {

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ export class AppointmentPopup {
6969
this.state.allowSaving = config.allowSaving;
7070
this.state.excludeInfo = config.excludeInfo;
7171

72-
if (!this._popup) {
73-
const popupConfig = this._createPopupConfig();
74-
this._createPopup(popupConfig);
75-
}
72+
this._disposePopup();
73+
74+
const popupConfig = this._createPopupConfig();
75+
this._createPopup(popupConfig);
7676

7777
this._popup!.show();
7878
}
@@ -82,9 +82,17 @@ export class AppointmentPopup {
8282
}
8383

8484
dispose() {
85-
this.form.dispose();
86-
this._popup?.dispose();
87-
this._popup = undefined;
85+
this._disposePopup();
86+
}
87+
88+
private _disposePopup(): void {
89+
if (this._popup) {
90+
const $element = this._popup.$element();
91+
this.form.dispose();
92+
this._popup.dispose();
93+
$element.remove();
94+
this._popup = undefined;
95+
}
8896
}
8997

9098
_createPopup(options): void {

0 commit comments

Comments
 (0)