feat(purchases): update terminology from "محصول" to "کالا" in purchase forms and templates
refactor(purchases): remove unused purchase receipt components and consolidate receipt template logic fix(suppliers): enhance suppliers select component to support full data option values style(tailwind): improve theme variables for better customization and consistency feat(shared): introduce abstract select component for reusable select field logic chore(purchases): clean up imports and improve component structure for better maintainability
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { Component, Input, signal } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
|
||||
export interface ISelectItem {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'abstract-select-field',
|
||||
template: '',
|
||||
})
|
||||
export abstract class AbstractSelectComponent<T = ISelectItem> {
|
||||
@Input() control!: FormControl<Maybe<number | T>>;
|
||||
@Input() canInsert: boolean = false;
|
||||
@Input() showLabel: boolean = true;
|
||||
@Input() showErrors: boolean = true;
|
||||
@Input() isFullDataOptionValue: boolean = false;
|
||||
@Input() optionValue = 'id';
|
||||
|
||||
loading = signal(false);
|
||||
items = signal<Maybe<T[]>>(null);
|
||||
isOpenFormDialog = signal(false);
|
||||
|
||||
abstract getData(): void;
|
||||
// abstract getLabel(): string;
|
||||
|
||||
refresh() {
|
||||
this.getData();
|
||||
}
|
||||
|
||||
onOpenForm() {
|
||||
// Override in subclass if needed
|
||||
}
|
||||
|
||||
get selectOptionValue() {
|
||||
if (!this.control) return undefined;
|
||||
if (this.isFullDataOptionValue) {
|
||||
return undefined;
|
||||
}
|
||||
return this.optionValue;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './abstract-select.component';
|
||||
export * from './breadcrumb.component';
|
||||
export * from './card-data.component';
|
||||
export * from './inlineConfirmation/inline-confirmation.component';
|
||||
|
||||
Reference in New Issue
Block a user