|
@ -4,10 +4,10 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
Component, |
|
|
Component, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
effect, |
|
|
|
|
|
ElementRef, |
|
|
ElementRef, |
|
|
EventEmitter, |
|
|
EventEmitter, |
|
|
Input, |
|
|
Input, |
|
|
|
|
|
OnChanges, |
|
|
OnDestroy, |
|
|
OnDestroy, |
|
|
OnInit, |
|
|
OnInit, |
|
|
Output, |
|
|
Output, |
|
@ -41,7 +41,7 @@ import { BehaviorSubject, Subject, takeUntil } from 'rxjs'; |
|
|
styleUrls: ['./tags-selector.component.scss'], |
|
|
styleUrls: ['./tags-selector.component.scss'], |
|
|
templateUrl: 'tags-selector.component.html' |
|
|
templateUrl: 'tags-selector.component.html' |
|
|
}) |
|
|
}) |
|
|
export class GfTagsSelectorComponent implements OnInit, OnDestroy { |
|
|
export class GfTagsSelectorComponent implements OnInit, OnChanges, OnDestroy { |
|
|
@Input() tags: Tag[]; |
|
|
@Input() tags: Tag[]; |
|
|
@Input() tagsAvailable: Tag[]; |
|
|
@Input() tagsAvailable: Tag[]; |
|
|
|
|
|
|
|
@ -57,12 +57,6 @@ export class GfTagsSelectorComponent implements OnInit, OnDestroy { |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
public constructor() { |
|
|
public constructor() { |
|
|
effect(() => { |
|
|
|
|
|
if (this.tagsSelected()) { |
|
|
|
|
|
this.tagsChanged.emit(this.tagsSelected()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.tagInputControl.valueChanges |
|
|
this.tagInputControl.valueChanges |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.subscribe((value) => { |
|
|
.subscribe((value) => { |
|
@ -75,6 +69,11 @@ export class GfTagsSelectorComponent implements OnInit, OnDestroy { |
|
|
this.updateFilters(); |
|
|
this.updateFilters(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
|
|
|
this.tagsSelected.set(this.tags); |
|
|
|
|
|
this.updateFilters(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
public ngOnDestroy() { |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
this.unsubscribeSubject.complete(); |
|
@ -89,6 +88,7 @@ export class GfTagsSelectorComponent implements OnInit, OnDestroy { |
|
|
return [...(tags ?? []), tag]; |
|
|
return [...(tags ?? []), tag]; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.tagsChanged.emit(this.tagsSelected()); |
|
|
this.tagInput.nativeElement.value = ''; |
|
|
this.tagInput.nativeElement.value = ''; |
|
|
this.tagInputControl.setValue(undefined); |
|
|
this.tagInputControl.setValue(undefined); |
|
|
} |
|
|
} |
|
@ -100,6 +100,7 @@ export class GfTagsSelectorComponent implements OnInit, OnDestroy { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.tagsChanged.emit(this.tagsSelected()); |
|
|
this.updateFilters(); |
|
|
this.updateFilters(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|