Fehler Hamburger Menu, Backend requests
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Component, forwardRef, Input } from '@angular/core';
|
||||
import { Component, forwardRef, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { NgxCurrencyDirective } from 'ngx-currency';
|
||||
import { Subject } from 'rxjs';
|
||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||
import { BaseInputComponent } from '../base-input/base-input.component';
|
||||
import { TooltipComponent } from '../tooltip/tooltip.component';
|
||||
import { ValidationMessagesService } from '../validation-messages.service';
|
||||
@@ -20,15 +22,39 @@ import { ValidationMessagesService } from '../validation-messages.service';
|
||||
templateUrl: './validated-price.component.html',
|
||||
styles: `:host{width:100%}`,
|
||||
})
|
||||
export class ValidatedPriceComponent extends BaseInputComponent {
|
||||
export class ValidatedPriceComponent extends BaseInputComponent implements OnInit, OnDestroy {
|
||||
@Input() inputClasses: string;
|
||||
@Input() placeholder: string = '';
|
||||
@Input() debounceTimeMs: number = 400; // Configurable debounce time in milliseconds
|
||||
|
||||
private inputChange$ = new Subject<any>();
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(validationMessagesService: ValidationMessagesService) {
|
||||
super(validationMessagesService);
|
||||
}
|
||||
|
||||
override ngOnInit(): void {
|
||||
// Setup debounced onChange
|
||||
this.inputChange$
|
||||
.pipe(
|
||||
debounceTime(this.debounceTimeMs),
|
||||
takeUntil(this.destroy$)
|
||||
)
|
||||
.subscribe(value => {
|
||||
this.value = value;
|
||||
this.onChange(this.value);
|
||||
});
|
||||
}
|
||||
|
||||
override ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
onInputChange(event: Event): void {
|
||||
this.value = !event ? null : event;
|
||||
this.onChange(this.value);
|
||||
const newValue = !event ? null : event;
|
||||
// Send signal to Subject instead of calling onChange directly
|
||||
this.inputChange$.next(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user