Skip to content

Commit 0974360

Browse files
committed
feat: make changes to readonly appointment form
1 parent eeee8a1 commit 0974360

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

packages/devextreme-scss/scss/widgets/base/scheduler/_index.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,15 @@ $scheduler-appointment-form-label-padding: 20px;
641641
}
642642
}
643643

644+
&.dx-scheduler-form-readonly {
645+
.dx-scheduler-form-repeat-editor .dx-scheduler-form-recurrence-settings-button {
646+
margin-right: 0;
647+
&::after {
648+
content: none;
649+
}
650+
}
651+
}
652+
644653
/* Recurrence Day Buttons */
645654
.dx-scheduler-days-of-week-buttons {
646655
display: flex;

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ export class AppointmentForm {
131131
set readOnly(value: boolean) {
132132
this.dxForm.option('readOnly', value);
133133
this._recurrenceForm.setReadOnly(value);
134+
this.updateReadOnlyCssClass();
135+
this.updateRepeatEditor();
134136
}
135137

136138
get formData(): Record<string, any> {
@@ -256,6 +258,7 @@ export class AppointmentForm {
256258
onInitialized: (e): void => {
257259
this._dxForm = e.component;
258260
this._recurrenceForm.dxForm = this.dxForm;
261+
this.updateReadOnlyCssClass();
259262
},
260263
} as FormProperties) as dxForm;
261264
}
@@ -840,6 +843,8 @@ export class AppointmentForm {
840843
}
841844

842845
repeatEditor.option('buttons', this.getRepeatEditorButtons());
846+
847+
this.enableRecurrenceSettingsButton();
843848
}
844849

845850
private getRepeatEditorButtons(): TextEditorButton[] {
@@ -872,6 +877,22 @@ export class AppointmentForm {
872877
return buttons;
873878
}
874879

880+
private enableRecurrenceSettingsButton(): void {
881+
const $settingsButton = $(this.dxForm.element())
882+
.find(`.${CLASSES.recurrenceSettingsButton}`)
883+
.closest('.dx-button');
884+
885+
if ($settingsButton && $settingsButton.length) {
886+
const buttonInstance = ($settingsButton as any).dxButton?.('instance');
887+
buttonInstance?.option?.('disabled', false);
888+
}
889+
}
890+
891+
private updateReadOnlyCssClass(): void {
892+
const $formElement = $(this.dxForm.element());
893+
$formElement.toggleClass('dx-scheduler-form-readonly', this.readOnly);
894+
}
895+
875896
private updateDateTimeEditorsVisibility(): void {
876897
const { allDayExpr } = this.scheduler.getDataAccessors().expr;
877898
const visible = !this.formData[allDayExpr];

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export class RecurrenceForm {
102102

103103
private _weekDayButtons: Record<string, dxButton> = {};
104104

105+
private _readOnly = false;
106+
105107
constructor(scheduler: Scheduler) {
106108
this.scheduler = scheduler;
107109
this.weekDayItems = this.createWeekDayItems();
@@ -161,9 +163,7 @@ export class RecurrenceForm {
161163
}
162164

163165
setReadOnly(value: boolean): void {
164-
Object.values(this._weekDayButtons).forEach((button) => {
165-
button?.option('disabled', value);
166-
});
166+
this._readOnly = value;
167167
}
168168

169169
get recurrenceRule(): RecurrenceRule {
@@ -333,6 +333,7 @@ export class RecurrenceForm {
333333

334334
this._weekDayButtons[item.key] = this.scheduler.createComponent(buttonContainer, Button, {
335335
text: item.text,
336+
disabled: this._readOnly,
336337
onClick: (): void => {
337338
const isSelected = this.recurrenceRule.byDay.includes(item.key);
338339

0 commit comments

Comments
 (0)