Skip to content
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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

RehanY147
Copy link
Contributor

Changes:

Introduces configurable full-page form with glossary section and help

Testing:

Test the containers wizard. It should work correctly

@bugclerk
Copy link
Contributor

@bugclerk bugclerk changed the title Create a configurable full-page form with glossary section and help NAS-132300 / 25.04 / Create a configurable full-page form with glossary section and help Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 23.71134% with 148 lines in your changes missing coverage. Please review.

Project coverage is 82.19%. Comparing base (8f8ac70) to head (b8c7526).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/ix-full-page-form/ix-full-page-form.component.ts 0.00% 62 Missing ⚠️
...m-with-glossary/ix-form-with-glossary.component.ts 0.00% 47 Missing ⚠️
...modules/forms/ix-forms/services/ix-form.service.ts 4.54% 21 Missing ⚠️
...rms/ix-forms/directives/with-glossary.directive.ts 0.00% 11 Missing ⚠️
...orm-section/ix-full-page-form-section.component.ts 0.00% 7 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@undsoft undsoft self-requested a review November 25, 2024 15:52
Copy link
Collaborator

@undsoft undsoft left a 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>();
Copy link
Collaborator

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();
Copy link
Collaborator

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>();
Copy link
Collaborator

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>([
Copy link
Collaborator

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(
Copy link
Collaborator

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.

@RehanY147 RehanY147 requested a review from undsoft December 4, 2024 01:13
@@ -41,6 +41,8 @@ export class IxButtonGroupComponent implements ControlValueAccessor {
@HostBinding('class.inlineFields')
@Input() inlineFields = false;

formControlName = input<string>();
Copy link
Collaborator

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',
Copy link
Collaborator

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 {
Copy link
Collaborator

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[] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't think IxFormService should care about searching within set of controls. Seems like a job for the component where it's needed.
  2. What is elementsWithIds?
  3. 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 {
Copy link
Collaborator

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]',
Copy link
Collaborator

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() || '';
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@undsoft undsoft self-requested a review December 7, 2024 08:05
@@ -22,7 +22,7 @@ export class NavigateAndInteractService {
});
}

private handleHashScrollIntoView(htmlElement: HTMLElement): void {
handleHashScrollIntoView(htmlElement: HTMLElement): void {
Copy link
Collaborator

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[]>([]);
Copy link
Collaborator

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
Copy link
Collaborator

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?

@RehanY147 RehanY147 marked this pull request as ready for review December 12, 2024 05:36
@RehanY147 RehanY147 requested a review from a team as a code owner December 12, 2024 05:36
@RehanY147 RehanY147 requested review from denysbutenko and removed request for a team December 12, 2024 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants