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:
2026-04-24 02:23:47 +03:30
parent e58bcbef57
commit d857361cb7
41 changed files with 268 additions and 121 deletions
@@ -5,6 +5,17 @@
[showLabel]="!!label"
[showErrors]="showErrors"
>
@if (labelSuffix) {
<ng-template #labelView>
<div class="flex gap-1 items-center">
<uikit-label [name]="name">
{{ preparedLabel() }}
</uikit-label>
<ng-container [ngTemplateOutlet]="labelSuffix"></ng-container>
</div>
</ng-template>
}
<p-inputgroup>
@if (selectedType.value === "amount") {
<p-inputnumber
@@ -1,8 +1,18 @@
import { Maybe } from '@/core';
import { ToastService } from '@/core/services/toast.service';
import { UikitFieldComponent } from '@/uikit';
import { UikitFieldComponent, UikitLabelComponent } from '@/uikit';
import { formatWithCurrency } from '@/utils';
import { Component, EventEmitter, inject, Input, Output, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import {
Component,
ContentChild,
EventEmitter,
inject,
Input,
Output,
signal,
TemplateRef,
} from '@angular/core';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { InputGroup } from 'primeng/inputgroup';
import { InputGroupAddon } from 'primeng/inputgroupaddon';
@@ -27,6 +37,8 @@ interface IAmountPercentageInputSelect {
InputText,
Select,
InputNumberModule,
CommonModule,
UikitLabelComponent,
],
})
export class AmountPercentageInputComponent {
@@ -52,6 +64,8 @@ export class AmountPercentageInputComponent {
@Output() onTypeChange = new EventEmitter<TAmountPercentageInput>();
@Output() blur = new EventEmitter<void>();
@ContentChild('labelSuffix', { static: false }) labelSuffix!: TemplateRef<any> | null;
private readonly toastService = inject(ToastService);
readonly typeSelectOptions: IAmountPercentageInputSelect[] = [
@@ -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 '-';
}