feat: Enhance customer and inventory components with new features and improvements
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { Component, Input, signal } from '@angular/core';
|
||||
import { Component, Input, model, signal } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
|
||||
export interface ISelectItem {
|
||||
@@ -12,7 +12,7 @@ export interface ISelectItem {
|
||||
template: '',
|
||||
})
|
||||
export abstract class AbstractSelectComponent<T = ISelectItem> {
|
||||
@Input() control!: FormControl<Maybe<number | T>>;
|
||||
@Input() control = new FormControl<Maybe<number | T>>(null);
|
||||
@Input() canInsert: boolean = false;
|
||||
@Input() showLabel: boolean = true;
|
||||
@Input() showErrors: boolean = true;
|
||||
@@ -22,20 +22,29 @@ export abstract class AbstractSelectComponent<T = ISelectItem> {
|
||||
loading = signal(false);
|
||||
items = signal<Maybe<T[]>>(null);
|
||||
isOpenFormDialog = signal(false);
|
||||
value = model<Maybe<T>>(null);
|
||||
|
||||
constructor() {
|
||||
if (this.value()) {
|
||||
this.control.setValue(this.value());
|
||||
}
|
||||
|
||||
this.control.valueChanges.subscribe((val) => {
|
||||
this.value.set(val as Maybe<T>);
|
||||
});
|
||||
}
|
||||
|
||||
abstract getData(): void;
|
||||
// abstract getLabel(): string;
|
||||
|
||||
refresh() {
|
||||
this.getData();
|
||||
}
|
||||
|
||||
onOpenForm() {
|
||||
// Override in subclass if needed
|
||||
this.isOpenFormDialog.set(true);
|
||||
}
|
||||
|
||||
get selectOptionValue() {
|
||||
if (!this.control) return undefined;
|
||||
if (this.isFullDataOptionValue) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user