feat: implement product creation and update features with form handling and routing
This commit is contained in:
@@ -4,11 +4,9 @@ import {
|
||||
Component,
|
||||
computed,
|
||||
ContentChild,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Input,
|
||||
Output,
|
||||
Renderer2,
|
||||
signal,
|
||||
TemplateRef,
|
||||
} from '@angular/core';
|
||||
@@ -25,6 +23,7 @@ export interface IColumn {
|
||||
width?: string;
|
||||
minWidth?: string;
|
||||
canCopy?: boolean;
|
||||
type?: 'text' | 'price' | 'boolean' | 'date';
|
||||
customDataModel?: TemplateRef<any> | ((item: any) => string | number | boolean);
|
||||
}
|
||||
|
||||
@@ -45,10 +44,7 @@ export interface IColumn {
|
||||
],
|
||||
})
|
||||
export class PageDataListComponent<I> {
|
||||
constructor(
|
||||
private host: ElementRef,
|
||||
private renderer: Renderer2,
|
||||
) {}
|
||||
constructor() {}
|
||||
|
||||
@Input() pageTitle!: string;
|
||||
@Input() addNewCtaLabel?: string;
|
||||
@@ -125,6 +121,19 @@ export class PageDataListComponent<I> {
|
||||
return this.renderCustom(column, item);
|
||||
}
|
||||
const data = item[field];
|
||||
switch (column.type) {
|
||||
case 'date':
|
||||
if (!data) return '-';
|
||||
const date = new Date(data);
|
||||
return isNaN(date.getTime()) ? '-' : date.toLocaleDateString();
|
||||
case 'boolean':
|
||||
return data ? 'بله' : 'خیر';
|
||||
case 'price':
|
||||
return typeof data === 'number' ? data.toLocaleString() : '-';
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (data === undefined || data === null) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user