From 4c26d6255b3fbe10a2ea714904a8d0b2f2bfdde1 Mon Sep 17 00:00:00 2001 From: Filip Leitner Date: Wed, 13 Nov 2024 13:48:30 +0100 Subject: [PATCH] feat(filters): Attribute selector component --- .../attribute-selector.component.ts | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 projects/hslayers/common/filters/comparison-filter/attribute-selector/attribute-selector.component.ts diff --git a/projects/hslayers/common/filters/comparison-filter/attribute-selector/attribute-selector.component.ts b/projects/hslayers/common/filters/comparison-filter/attribute-selector/attribute-selector.component.ts new file mode 100644 index 0000000000..29ba10f40c --- /dev/null +++ b/projects/hslayers/common/filters/comparison-filter/attribute-selector/attribute-selector.component.ts @@ -0,0 +1,63 @@ +import {Component, forwardRef, input} from '@angular/core'; +import { + ControlValueAccessor, + FormsModule, + NG_VALUE_ACCESSOR, + ReactiveFormsModule, +} from '@angular/forms'; +import {TranslateCustomPipe} from 'hslayers-ng/services/language'; + +@Component({ + selector: 'hs-attribute-selector', + standalone: true, + imports: [FormsModule, ReactiveFormsModule, TranslateCustomPipe], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + // eslint-disable-next-line no-use-before-define + useExisting: forwardRef(() => HsAttributeSelectorComponent), + multi: true, + }, + ], + template: ` + + `, +}) +export class HsAttributeSelectorComponent implements ControlValueAccessor { + attributes = input.required(); + + value: string = null; + disabled = false; + + onChange: (value: string) => void = () => {}; + onTouched: () => void = () => {}; + + writeValue(value: string): void { + this.value = value; + } + + registerOnChange(fn: (value: string) => void): void { + this.onChange = fn; + } + + registerOnTouched(fn: () => void): void { + this.onTouched = fn; + } + + setDisabledState(isDisabled: boolean): void { + this.disabled = isDisabled; + } +}