Browse Source

Fixed current tag typo

pull/3708/head
Daniel Idem 12 months ago
parent
commit
fe4b434ed1
  1. 2
      libs/ui/src/lib/tags-selector/tags-selector.component.html
  2. 12
      libs/ui/src/lib/tags-selector/tags-selector.component.ts

2
libs/ui/src/lib/tags-selector/tags-selector.component.html

@ -16,7 +16,7 @@
name="close-outline" name="close-outline"
[matAutocomplete]="autocompleteTags" [matAutocomplete]="autocompleteTags"
[matChipInputFor]="tagsChipList" [matChipInputFor]="tagsChipList"
[(ngModel)]="currentFruit" [(ngModel)]="currentTag"
/> />
</mat-chip-grid> </mat-chip-grid>
<mat-autocomplete <mat-autocomplete

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

@ -51,15 +51,15 @@ export class GfTagsSelectorComponent implements OnInit {
@ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>; @ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>;
readonly tagsSignal = signal([{ id: '', name: '' }]); readonly tagsSignal = signal([{ id: '', name: '' }]);
readonly currentFruit = model(''); readonly currentTag = model('');
readonly filteredTags = computed(() => { readonly filteredTags = computed(() => {
const currentFruit = this.currentFruit().toLowerCase(); const currentTag = this.currentTag().toLowerCase();
const aTags = this.tagsAvailable ?? [{ id: '', name: '' }]; const aTags = this.tagsAvailable ?? [{ id: '', name: '' }];
const bTags = this.tagsSignal() ?? [{ id: '', name: '' }]; const bTags = this.tagsSignal() ?? [{ id: '', name: '' }];
const cTags = aTags.filter((value) => !bTags.includes(value)); const cTags = aTags.filter((value) => !bTags.includes(value));
return currentFruit return currentTag
? cTags.filter((tag) => tag.name.toLowerCase().includes(currentFruit)) ? cTags.filter((tag) => tag.name.toLowerCase().includes(currentTag))
: cTags; : cTags;
}); });
@ -80,7 +80,7 @@ export class GfTagsSelectorComponent implements OnInit {
const newTag = this.tagsAvailable.find(({ id }) => id === tagId); const newTag = this.tagsAvailable.find(({ id }) => id === tagId);
if (this.tagsSignal()?.some((el) => el.id === tagId)) { if (this.tagsSignal()?.some((el) => el.id === tagId)) {
this.currentFruit.set(''); this.currentTag.set('');
event.option.deselect(); event.option.deselect();
return; return;
} }
@ -88,7 +88,7 @@ export class GfTagsSelectorComponent implements OnInit {
this.tagsSignal() this.tagsSignal()
? this.tagsSignal.update((tags) => [...tags, newTag]) ? this.tagsSignal.update((tags) => [...tags, newTag])
: this.tagsSignal.update(() => [newTag]); : this.tagsSignal.update(() => [newTag]);
this.currentFruit.set(''); this.currentTag.set('');
event.option.deselect(); event.option.deselect();
} }

Loading…
Cancel
Save