Refactor nested column definitions and improve license info handling
- Updated column definitions in various components to use `nestedOption` instead of `nestedPath` for better clarity and consistency. - Removed commented-out license status checks and related UI elements from the layout component. - Simplified license info interface by removing unnecessary properties. - Enhanced consumer accounts and business activities components to display additional license information. - Adjusted form components to conditionally include fields based on selected device type. - Improved the handling of discount calculations in the gold payload form component. - Added new fields for branch code in complex components and adjusted related views. - Cleaned up unused console logs in form data utility.
This commit is contained in:
@@ -22,14 +22,19 @@ import { TableModule } from 'primeng/table';
|
||||
import { KeyValueComponent } from '../key-value.component/key-value.component';
|
||||
import { TableActionRowComponent } from '../table-action-row.component';
|
||||
|
||||
type TDataType = 'simple' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id' | 'thumbnail';
|
||||
export interface IColumn<T = any> {
|
||||
field: T extends object ? keyof T | string : string;
|
||||
header: string;
|
||||
width?: string;
|
||||
minWidth?: string;
|
||||
canCopy?: boolean;
|
||||
type?: 'simple' | 'price' | 'boolean' | 'date' | 'nested' | 'index' | 'id' | 'thumbnail';
|
||||
nestedPath?: string;
|
||||
type?: TDataType;
|
||||
|
||||
nestedOption?: {
|
||||
path: string;
|
||||
type?: TDataType;
|
||||
};
|
||||
thumbnailOptions?: {
|
||||
editable: boolean;
|
||||
deletable: boolean;
|
||||
@@ -179,36 +184,38 @@ export class PageDataListComponent<I> {
|
||||
getCell(item: Record<string, any>, column: IColumn): any {
|
||||
if (!item || !column) return '';
|
||||
try {
|
||||
const { field } = column;
|
||||
let { field, type } = column;
|
||||
|
||||
if (column.customDataModel) {
|
||||
return this.renderCustom(column, item);
|
||||
}
|
||||
const data = item[String(field)];
|
||||
switch (column.type) {
|
||||
case 'id':
|
||||
if (!data) return '-';
|
||||
return `${data.slice(0, 5)}...${data.slice(data.length - 5, data.length)}`;
|
||||
case 'date':
|
||||
if (!data) return '-';
|
||||
return formatJalali(data);
|
||||
case 'boolean':
|
||||
return data ? 'بله' : 'خیر';
|
||||
case 'price':
|
||||
return formatWithCurrency(data, false, 'ریال');
|
||||
case 'nested': {
|
||||
const path = column.nestedPath;
|
||||
if (!path) return '-';
|
||||
const nestedData = path
|
||||
.split('.')
|
||||
.reduce((obj, key) => (obj && obj[key] !== undefined ? obj[key] : null), item);
|
||||
|
||||
return nestedData || '-';
|
||||
}
|
||||
default:
|
||||
break;
|
||||
let data = item[String(field)];
|
||||
if (column.type === 'nested') {
|
||||
const path = column.nestedOption?.path;
|
||||
if (!path) return '-';
|
||||
data = path
|
||||
.split('.')
|
||||
.reduce((obj, key) => (obj && obj[key] !== undefined ? obj[key] : null), item);
|
||||
type = column.nestedOption?.type || 'simple';
|
||||
}
|
||||
|
||||
if (type) {
|
||||
switch (type) {
|
||||
case 'id':
|
||||
if (!data) return '-';
|
||||
return `${data.slice(0, 5)}...${data.slice(data.length - 5, data.length)}`;
|
||||
case 'date':
|
||||
if (!data) return '-';
|
||||
return formatJalali(data);
|
||||
case 'boolean':
|
||||
return data ? 'بله' : 'خیر';
|
||||
case 'price':
|
||||
return formatWithCurrency(data, false, 'ریال');
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (data === undefined || data === null) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user