Browse Source

feat(lib): type safety of tags selector

pull/6497/head
KenTandrian 3 weeks ago
parent
commit
b49b89fde9
  1. 21
      libs/ui/src/lib/tags-selector/tags-selector.component.ts

21
libs/ui/src/lib/tags-selector/tags-selector.component.ts

@ -77,7 +77,7 @@ export class GfTagsSelectorComponent
this.tagInputControl.valueChanges this.tagInputControl.valueChanges
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe((value) => { .subscribe((value) => {
this.filteredOptions.next(this.filterTags(value)); this.filteredOptions.next(this.filterTags(value ?? ''));
}); });
addIcons({ addCircleOutline, closeOutline }); addIcons({ addCircleOutline, closeOutline });
@ -100,21 +100,24 @@ export class GfTagsSelectorComponent
if (!tag && this.hasPermissionToCreateTag) { if (!tag && this.hasPermissionToCreateTag) {
tag = { tag = {
id: undefined, id: '',
name: event.option.value as string, name: event.option.value as string,
userId: null userId: null
}; };
} }
this.tagsSelected.update((tags) => { if (tag) {
return [...(tags ?? []), tag]; this.tagsSelected.update((tags) => {
}); return [...(tags ?? []), tag];
});
const newTags = this.tagsSelected();
this.onChange(newTags);
this.onTouched();
}
const newTags = this.tagsSelected();
this.onChange(newTags);
this.onTouched();
this.tagInput.nativeElement.value = ''; this.tagInput.nativeElement.value = '';
this.tagInputControl.setValue(undefined); this.tagInputControl.setValue(null);
} }
public onRemoveTag(tag: Tag) { public onRemoveTag(tag: Tag) {

Loading…
Cancel
Save