-
Notifications
You must be signed in to change notification settings - Fork 311
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
NAS-132300 / 25.04 / Create a configurable full-page form with glossary section and help #11091
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #11091 +/- ##
==========================================
- Coverage 82.39% 82.19% -0.20%
==========================================
Files 1648 1653 +5
Lines 57884 58082 +198
Branches 5955 6002 +47
==========================================
+ Hits 47691 47738 +47
- Misses 10193 10344 +151 ☔ View full report in Codecov by Sentry. |
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.
Also Save button is not clickable for me when I fill in the form. (I don't see any validation errors).
searchControl = this.formBuilder.control(''); | ||
searchOptions = signal<Option[]>([]); | ||
onSubmit = output(); | ||
buttonText = input.required<string>(); |
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.
This part is a bit hard to read. Let's group inputs and outputs and add protected/private for other fields.
searchMap = input<Map<string, string>>(); | ||
pageTitle = input.required<string>(); | ||
isLoading = input.required<boolean>(); | ||
subscription = new Subscription(); |
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.
Not used.
formGroup = input.required<FormGroup>(); | ||
requiredRoles = input<Role[]>(); | ||
searchMap = input<Map<string, string>>(); | ||
pageTitle = input.required<string>(); |
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.
I think this component is trying to have too much responsibility. I don't think it needs to take care of page header or save button. It could just be a component responsible for form glossary that can be included on other pages.
@@ -89,6 +96,19 @@ export class InstanceWizardComponent implements OnInit { | |||
}))), | |||
); | |||
|
|||
protected searchMap = new Map<string, string>([ |
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.
For this pull master and see ixRegisteredControl
and NavigateAndInteractService
. We could extend the former to also include control labels.
}), | ||
)); | ||
|
||
protected isEnvironmentValid = toSignal(this.form.controls.environmentVariables.valueChanges.pipe( |
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.
Would be good to come with a way to avoid this. Maybe you could come up with a way for a section to figure out which fields are rendered underneath it via contentChildren
or some sort of injection.
@@ -41,6 +41,8 @@ export class IxButtonGroupComponent implements ControlValueAccessor { | |||
@HostBinding('class.inlineFields') | |||
@Input() inlineFields = false; | |||
|
|||
formControlName = input<string>(); |
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.
Did you want to use this.controlDirective.name
or label
input?
|
||
@UntilDestroy() | ||
@Component({ | ||
selector: 'ix-full-page-form', |
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.
If this is not used, it needs to be removed.
this.handleSearchControl(); | ||
} | ||
|
||
protected onSectionClick(id: string, label: string = null): void { |
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.
You can update NavigateAndInteractService
to have a separate method for navigating to something by id and move this code there.
@@ -13,20 +17,79 @@ export class IxFormService { | |||
return this.getControls().map((ctrl) => ctrl.name); | |||
} | |||
|
|||
private getControlsOptions(query = ''): Option[] { |
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.
- I don't think
IxFormService
should care about searching within set of controls. Seems like a job for the component where it's needed. - What is
elementsWithIds
? - The code in two blocks is similar.
} | ||
|
||
registerControl(control: NgControl, elementRef: ElementRef<HTMLElement>): void { | ||
this.controls.set(control, elementRef.nativeElement); | ||
this.controlsOptions.set(this.getControlsOptions()); | ||
} | ||
|
||
unregisterControl(control: NgControl): void { |
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.
This is unused now, but it was used some time before. We should have ngOnDestroy
in registeredControl
and call this.
import { IxFormWithGlossaryComponent } from 'app/modules/forms/ix-forms/components/ix-form-with-glossary/ix-form-with-glossary.component'; | ||
|
||
@Directive({ | ||
selector: '[withGlossary]', |
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.
What's the advantage of making this a directive?
Could we not make it an ordinary component instead and let people place glossary in their forms themselve?
@@ -51,6 +53,10 @@ export class IxButtonGroupComponent implements ControlValueAccessor { | |||
this.controlDirective.valueAccessor = this; | |||
} | |||
|
|||
@HostBinding('attr.id') get id(): string { | |||
return this.formControlName() || ''; |
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.
Also you set id here, but also set ix-label
in ixRegisteredControl
. Can you use one of these?
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.
In some cases, label might not be set. In other cases, id might not be set. So, these give more of a chance that at least one will be set and allow usage for the ixRegisteredControl
directive.
@@ -22,7 +22,7 @@ export class NavigateAndInteractService { | |||
}); | |||
} | |||
|
|||
private handleHashScrollIntoView(htmlElement: HTMLElement): void { | |||
handleHashScrollIntoView(htmlElement: HTMLElement): void { |
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.
Method needs to be renamed if it's going to be public.
private controls = new Map<NgControl, HTMLElement>(); | ||
private controls = new Map<string, HTMLElement>(); | ||
private sections = new Map<IxFormSectionComponent, Map<string, NgControl | null>>(); | ||
controlNamesWithlabels$ = new BehaviorSubject<ControlNameWithLabel[]>([]); |
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.
controlNamesWithLabels
[required]="true" | ||
></ix-input> | ||
|
||
<ix-checkbox | ||
ixRegisteredControl |
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.
The original intent was to have this directive in ix form controls and not to expose it in other places. Can't we keep doing that instead of having registeredControl here?
Changes:
Introduces configurable full-page form with glossary section and help
Testing:
Test the containers wizard. It should work correctly