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

Feature/designators component #103

Merged
merged 14 commits into from
Aug 6, 2024
Merged

Conversation

lukavdplas
Copy link
Contributor

@lukavdplas lukavdplas commented Aug 2, 2024

This adds a DesignatorsControlComponent, which contains the form widget for the designators of people, places, and things.

Screenshot:
screenshot showing a list of names with a "remove" button for each, and an input field to add a new name

Copy link
Contributor

@XanderVertegaal XanderVertegaal left a comment

Choose a reason for hiding this comment

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

Kudos on getting this ControlValueAccessor to work (and so quickly)! I will make sure to steal parts of this for my LabelSelectComponent.

As far as I can see, the component works fine, so none of my comments here prevent merger.

<button class="btn btn-primary" type="submit"
[disabled]="disabled"
(blur)="blur$.next()">
<lc-icon [icon]="actionIcons.add" aria-label="add" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<lc-icon [icon]="actionIcons.add" aria-label="add" />
<lc-icon [icon]="actionIcons.add" aria-label="add designator" />

(I'm not sure how specific these aria-labels are expected to be.)

}

registerOnChange(fn: (_: any) => void): void {
this.designators$.subscribe(fn);
Copy link
Contributor

Choose a reason for hiding this comment

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

These subscriptions are not closed at the moment. For bonus points, please make sure they are canceled upon component destruction.

Comment on lines +59 to +65
onAddFormSubmit() {
if (this.addForm.valid) {
const designator = this.addForm.controls.designator.value;
this.designators$.next(this.designators$.value.concat([designator]));
this.addForm.reset({ designator: '' });
}
}
Copy link
Contributor

@XanderVertegaal XanderVertegaal Aug 6, 2024

Choose a reason for hiding this comment

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

Suggested change
onAddFormSubmit() {
if (this.addForm.valid) {
const designator = this.addForm.controls.designator.value;
this.designators$.next(this.designators$.value.concat([designator]));
this.addForm.reset({ designator: '' });
}
}
onAddFormSubmit(): void {
if (this.addForm.invalid) {
return;
}
const designator = this.addForm.controls.designator.value;
this.designators$.next(this.designators$.value.concat([designator]));
this.addForm.reset({ designator: '' });
}

}

removeDesignator(index: number) {
const spliced = _.clone(this.designators$.value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is deep cloning necessary here? The control seems to continue working if I remove it.

this.designators$.subscribe(fn);
}

registerOnTouched(fn: (_: any) => void): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using any here, you can use unknown, which does not give a type warning.

@lukavdplas lukavdplas merged commit 520a0ae into develop Aug 6, 2024
2 checks passed
@lukavdplas lukavdplas deleted the feature/designators-component branch August 6, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants