-
Notifications
You must be signed in to change notification settings - Fork 667
Scheduler: Appointment Form - fix paddings #32865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
Changes from all commits
6a7fb5d
7cbc547
81d046f
a878728
abcfc78
819e011
c327505
899a57a
fd28978
6a7e7f4
8d39503
0bc2283
37f2254
fad4c02
e175347
fb1e061
ca225a8
be7b7eb
0b3d93e
85c6b28
6fb0d16
2b689ff
3202178
c605cd8
6cc7304
73e220b
3d63876
9e6d517
31cf255
ee87797
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,17 +219,18 @@ export class AppointmentForm { | |
| create(popup: any): void { | ||
| this._popup = popup; | ||
|
|
||
| const iconsShowMode = this.getIconsShowMode(); | ||
| const showMainGroupIcons = ['main', 'both'].includes(iconsShowMode); | ||
| const showRecurrenceGroupIcons = ['recurrence', 'both'].includes(iconsShowMode); | ||
|
|
||
| const mainGroup = this.createMainFormGroup(); | ||
|
|
||
| this._recurrenceForm = new RecurrenceForm(this.scheduler); | ||
| const recurrenceGroup = this._recurrenceForm.createRecurrenceFormGroup(); | ||
| const recurrenceGroup = this._recurrenceForm | ||
| .createRecurrenceFormGroup(); | ||
|
|
||
| const items = [mainGroup, recurrenceGroup]; | ||
|
|
||
| const iconsShowMode = this.getIconsShowMode(); | ||
| const showMainGroupIcons = ['main', 'both'].includes(iconsShowMode); | ||
| const showRecurrenceGroupIcons = ['recurrence', 'both'].includes(iconsShowMode); | ||
|
Comment on lines
-229
to
-231
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your solution: propagate showIcon parameter through each function and duplicate logic of selecting colSpan: While this works, the problem is that the logic is duplicated and we can easily forget to update some item's colSpan. Here's the alternative approach by using private setStylingModeToEditors(item: FormItem, showIcon: boolean): void {
const itemClasses = (item.cssClass ?? '').split(' ');
const isIconItem = itemClasses.includes(CLASSES.formIcon);
if (isIconItem) {
return;
}
if (item.itemType === 'simple') {
// ...
return;
}
if (item.itemType === 'group') {
const groupItem = item as GroupItem;
const colCount = showIcon ? 2 : 1;
groupItem.colCount = colCount;
groupItem.colCountByScreen = { xs: colCount };
groupItem.items?.forEach((child) => {
this.setStylingModeToEditors(child, showIcon);
});
}
}This way we can remove:
What do you think? P.S. the codesnippet is for ref only, I haven't tested it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the solution based on your suggestion |
||
|
|
||
| this.setStylingModeToEditors(mainGroup, showMainGroupIcons); | ||
| this.setStylingModeToEditors(recurrenceGroup, showRecurrenceGroupIcons); | ||
|
|
||
|
|
@@ -348,9 +349,7 @@ export class AppointmentForm { | |
| itemType: 'group', | ||
| cssClass: `${CLASSES.subjectGroup} ${CLASSES.groupWithIcon}`, | ||
| colCount: 2, | ||
| colCountByScreen: { | ||
| xs: 2, | ||
| }, | ||
| colCountByScreen: { xs: 2 }, | ||
| items: [ | ||
| { | ||
| name: SUBJECT_ICON_NAME, | ||
|
|
@@ -379,9 +378,7 @@ export class AppointmentForm { | |
| itemType: 'group', | ||
| cssClass: `${CLASSES.dateRangeGroup} ${CLASSES.groupWithIcon}`, | ||
| colCount: 2, | ||
| colCountByScreen: { | ||
| xs: 2, | ||
| }, | ||
| colCountByScreen: { xs: 2 }, | ||
| items: [ | ||
| { | ||
| name: DATE_ICON_NAME, | ||
|
|
@@ -660,9 +657,7 @@ export class AppointmentForm { | |
| name: REPEAT_GROUP_NAME, | ||
| itemType: 'group', | ||
| colCount: 2, | ||
| colCountByScreen: { | ||
| xs: 2, | ||
| }, | ||
| colCountByScreen: { xs: 2 }, | ||
| cssClass: `${CLASSES.repeatGroup} ${CLASSES.groupWithIcon}`, | ||
| items: [ | ||
| { | ||
|
|
@@ -716,9 +711,7 @@ export class AppointmentForm { | |
| name: DESCRIPTION_GROUP_NAME, | ||
| itemType: 'group', | ||
| colCount: 2, | ||
| colCountByScreen: { | ||
| xs: 2, | ||
| }, | ||
| colCountByScreen: { xs: 2 }, | ||
| cssClass: `${CLASSES.descriptionGroup} ${CLASSES.groupWithIcon}`, | ||
| items: [ | ||
| { | ||
|
|
@@ -778,9 +771,7 @@ export class AppointmentForm { | |
| itemType: 'group', | ||
| visible: resourcesItems.length > 0, | ||
| colCount: 2, | ||
| colCountByScreen: { | ||
| xs: 2, | ||
| }, | ||
| colCountByScreen: { xs: 2 }, | ||
| cssClass: `${CLASSES.resourcesGroup} ${CLASSES.groupWithIcon}`, | ||
| items: [ | ||
| { | ||
|
|
@@ -807,9 +798,7 @@ export class AppointmentForm { | |
| itemType: 'group', | ||
| name: `${dataField}Group`, | ||
| colCount: 2, | ||
| colCountByScreen: { | ||
| xs: 2, | ||
| }, | ||
| colCountByScreen: { xs: 2 }, | ||
| cssClass: CLASSES.groupWithIcon, | ||
| items: [ | ||
| { | ||
|
|
@@ -818,7 +807,7 @@ export class AppointmentForm { | |
| cssClass: CLASSES.formIcon, | ||
| template: createFormIconTemplate(icon), | ||
| }, | ||
| item, | ||
| { ...item }, | ||
| ], | ||
| } as GroupItem; | ||
| }); | ||
|
|
@@ -840,12 +829,6 @@ export class AppointmentForm { | |
| const isIconItem = itemClasses.includes(CLASSES.formIcon); | ||
|
|
||
| if (isIconItem) { | ||
| const isHidden = itemClasses.includes(CLASSES.hidden); | ||
|
|
||
| if (!showIcon && !isHidden) { | ||
| item.cssClass += ` ${CLASSES.hidden}`; | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
|
|
@@ -862,6 +845,19 @@ export class AppointmentForm { | |
|
|
||
| if (item.itemType === 'group') { | ||
| const groupItem = item as GroupItem; | ||
|
|
||
| if (itemClasses.includes(CLASSES.groupWithIcon)) { | ||
| groupItem.items?.forEach((child) => { | ||
| const childClasses = (child.cssClass ?? '').split(' '); | ||
|
|
||
| if (childClasses.includes(CLASSES.formIcon)) { | ||
| (child as SimpleItem).visible = showIcon; | ||
| } else { | ||
| (child as SimpleItem).colSpan = showIcon ? 1 : 2; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| groupItem.items?.forEach((child) => { | ||
| this.setStylingModeToEditors(child, showIcon); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add a test for a case when main group doesn't have icons. Since we made icons invisible when they are disabled, some paddings will not appear, so the main group visual is changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Will write them soon