From d857361cb70b8433dbf56e31d4d0d980624113e6 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Fri, 24 Apr 2026 02:23:47 +0330 Subject: [PATCH] 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. --- .../invoices/shared-saleInvoice.component.ts | 4 +- .../license-info-dialog.component.html | 4 +- .../license-info-dialog.component.ts | 7 +-- .../consumer/constants/components/pos/pos.ts | 9 ++- .../consumer/layouts/layout.component.html | 4 +- .../consumer/layouts/layout.component.ts | 9 ++- src/app/domains/consumer/models/io.d.ts | 10 ---- .../modules/accounts/views/list.component.ts | 14 ++++- .../components/complexes/list.component.ts | 1 + .../components/goods/list.component.ts | 7 ++- .../components/list.component.ts | 19 ++++++- .../modules/businessActivities/models/io.d.ts | 9 +++ .../views/complexes/single.component.html | 1 + .../components/saleInvoices/list.component.ts | 2 +- .../poses/components/list.component.ts | 4 +- .../saleInvoices/components/list.component.ts | 2 +- .../modules/accounts/views/list.component.ts | 14 ++++- .../components/accounts/list.component.ts | 6 +- .../businessActivities/list.component.ts | 19 ++++++- .../components/poses/form.component.html | 2 +- .../components/poses/form.component.ts | 9 +++ .../components/poses/list.component.ts | 11 +++- .../models/businessActivities_io.d.ts | 11 +++- .../businessActivities/single.component.html | 2 + .../views/complexes/single.component.html | 1 + .../consumers/views/single.component.html | 28 --------- .../payloads/gold/form.component.html | 15 ++++- .../payloads/gold/form.component.ts | 26 ++++++++- .../components/accounts/list.component.ts | 4 +- .../businessActivities/list.component.ts | 2 +- .../components/poses/list.component.ts | 11 +++- .../views/complexes/single.component.html | 1 + .../modules/devices/views/list.component.ts | 7 ++- .../guilds/components/goods/list.component.ts | 7 ++- .../components/accounts/list.component.ts | 4 +- .../amount-percentage-input.component.html | 11 ++++ .../amount-percentage-input.component.ts | 18 +++++- .../pageDataList/page-data-list.component.ts | 57 +++++++++++-------- src/app/uikit/uikit-field.component.html | 10 +++- src/app/uikit/uikit-field.component.ts | 4 +- src/app/utils/form-data.util.ts | 3 - 41 files changed, 268 insertions(+), 121 deletions(-) diff --git a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts index 8aa5fff..23c62ef 100644 --- a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts +++ b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts @@ -44,7 +44,9 @@ export class ConsumerSaleInvoiceSharedComponent { field: 'name', header: 'عنوان', type: 'nested', - nestedPath: 'good.name', + nestedOption: { + path: 'good.name', + }, }, { field: 'unit_price', diff --git a/src/app/domains/consumer/components/license-info-dialog.component.html b/src/app/domains/consumer/components/license-info-dialog.component.html index 448a83e..32055cd 100644 --- a/src/app/domains/consumer/components/license-info-dialog.component.html +++ b/src/app/domains/consumer/components/license-info-dialog.component.html @@ -6,7 +6,7 @@ [closable]="true" (onHide)="close()" > - @if (!licenseStatus()) { + diff --git a/src/app/domains/consumer/components/license-info-dialog.component.ts b/src/app/domains/consumer/components/license-info-dialog.component.ts index 3899fd2..5ef5f48 100644 --- a/src/app/domains/consumer/components/license-info-dialog.component.ts +++ b/src/app/domains/consumer/components/license-info-dialog.component.ts @@ -1,7 +1,6 @@ import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog'; import { KeyValueComponent } from '@/shared/components'; -import { getLicenseStatus } from '@/utils'; -import { Component, computed, inject } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { Dialog } from 'primeng/dialog'; import { Message } from 'primeng/message'; import { ConsumerStore } from '../store/main.store'; @@ -14,7 +13,7 @@ import { ConsumerStore } from '../store/main.store'; export class ConsumerLicenseInfoDialogComponent extends AbstractDialog { private readonly store = inject(ConsumerStore); - license = computed(() => this.store.entity()?.license_info); + // license = computed(() => this.store.entity()?.license_info); - licenseStatus = computed(() => getLicenseStatus(getLicenseStatus(this.license()?.expires_at))); + // licenseStatus = computed(() => getLicenseStatus(getLicenseStatus(this.license()?.expires_at))); } diff --git a/src/app/domains/consumer/constants/components/pos/pos.ts b/src/app/domains/consumer/constants/components/pos/pos.ts index 19c8ad1..20e7585 100644 --- a/src/app/domains/consumer/constants/components/pos/pos.ts +++ b/src/app/domains/consumer/constants/components/pos/pos.ts @@ -7,8 +7,13 @@ export const columns: IColumn[] = [ { field: 'name', header: 'عنوان' }, { field: 'serial', header: 'شماره سریال' }, { field: 'pos_type', header: 'نوع دستگاه' }, - { field: 'device', header: 'دستگاه', type: 'nested', nestedPath: 'device.name' }, - { field: 'provider', header: 'ارایه‌دهنده', type: 'nested', nestedPath: 'provider.name' }, + { field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } }, + { + field: 'provider', + header: 'ارایه‌دهنده', + type: 'nested', + nestedOption: { path: 'provider.name' }, + }, { field: 'status', header: 'وضعیت' }, { field: 'created_at', diff --git a/src/app/domains/consumer/layouts/layout.component.html b/src/app/domains/consumer/layouts/layout.component.html index e1c60a3..22f07b3 100644 --- a/src/app/domains/consumer/layouts/layout.component.html +++ b/src/app/domains/consumer/layouts/layout.component.html @@ -1,4 +1,4 @@ - + diff --git a/src/app/domains/consumer/layouts/layout.component.ts b/src/app/domains/consumer/layouts/layout.component.ts index 45d1628..795f970 100644 --- a/src/app/domains/consumer/layouts/layout.component.ts +++ b/src/app/domains/consumer/layouts/layout.component.ts @@ -1,6 +1,5 @@ import { LayoutService } from '@/layout/service/layout.service'; -import { getLicenseStatus } from '@/utils'; -import { Component, computed, inject, signal, TemplateRef, ViewChild } from '@angular/core'; +import { Component, inject, signal, TemplateRef, ViewChild } from '@angular/core'; import { RouterOutlet } from '@angular/router'; import { Button, ButtonIcon } from 'primeng/button'; import { ConsumerLicenseInfoDialogComponent } from '../components/license-info-dialog.component'; @@ -20,9 +19,9 @@ export class LayoutComponent { visibleLicenseInfo = signal(false); - licenseStatus = computed(() => - getLicenseStatus(getLicenseStatus(this.store.entity()?.license_info?.expires_at)), - ); + // licenseStatus = computed(() => + // getLicenseStatus(getLicenseStatus(this.store.entity()?.license_info?.expires_at)), + // ); ngOnInit() { this.layoutService.setMenuItems(CONSUMER_MENU_ITEMS); diff --git a/src/app/domains/consumer/models/io.d.ts b/src/app/domains/consumer/models/io.d.ts index 578bdd1..bd4bc85 100644 --- a/src/app/domains/consumer/models/io.d.ts +++ b/src/app/domains/consumer/models/io.d.ts @@ -5,15 +5,5 @@ export interface IConsumerInfoRawResponse { mobile_number: string; status: string; fullname: string; - license_info: LicenseInfo; } export interface IConsumerInfoResponse extends IConsumerInfoRawResponse {} - -interface LicenseInfo { - id: string; - starts_at: string; - expires_at: string; - partner: { - name: string; - }; -} diff --git a/src/app/domains/consumer/modules/accounts/views/list.component.ts b/src/app/domains/consumer/modules/accounts/views/list.component.ts index 714ee2b..62a5254 100644 --- a/src/app/domains/consumer/modules/accounts/views/list.component.ts +++ b/src/app/domains/consumer/modules/accounts/views/list.component.ts @@ -20,9 +20,19 @@ export class ConsumerAccountsComponent extends AbstractList { override setColumns(): void { this.columns = [ { field: 'id', header: 'شناسه', type: 'id' }, - { field: 'username', header: 'نام کاربری', type: 'nested', nestedPath: 'account.username' }, + { + field: 'username', + header: 'نام کاربری', + type: 'nested', + nestedOption: { path: 'account.username' }, + }, { field: 'role', header: 'نقش' }, - { field: 'status', header: 'وضعیت', type: 'nested', nestedPath: 'account.status' }, + { + field: 'status', + header: 'وضعیت', + type: 'nested', + nestedOption: { path: 'account.status' }, + }, { field: 'created_at', header: 'تاریخ ایجاد', diff --git a/src/app/domains/consumer/modules/businessActivities/components/complexes/list.component.ts b/src/app/domains/consumer/modules/businessActivities/components/complexes/list.component.ts index 5596eb5..f50dca0 100644 --- a/src/app/domains/consumer/modules/businessActivities/components/complexes/list.component.ts +++ b/src/app/domains/consumer/modules/businessActivities/components/complexes/list.component.ts @@ -22,6 +22,7 @@ export class ConsumerComplexListComponent extends AbstractList @Input() header: IColumn[] = [ { field: 'id', header: 'شناسه', type: 'id' }, { field: 'name', header: 'عنوان' }, + { field: 'branch_code', header: 'کد شعبه' }, { field: 'created_at', header: 'تاریخ ایجاد', diff --git a/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.ts b/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.ts index 86c5046..bb4cb41 100644 --- a/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.ts +++ b/src/app/domains/consumer/modules/businessActivities/components/goods/list.component.ts @@ -23,7 +23,12 @@ export class ConsumerComplexGoodsListComponent extends AbstractList
+
diff --git a/src/app/domains/consumer/modules/customers/components/saleInvoices/list.component.ts b/src/app/domains/consumer/modules/customers/components/saleInvoices/list.component.ts index 23c60fb..5fce05f 100644 --- a/src/app/domains/consumer/modules/customers/components/saleInvoices/list.component.ts +++ b/src/app/domains/consumer/modules/customers/components/saleInvoices/list.component.ts @@ -36,7 +36,7 @@ export class ConsumerCustomerSaleInvoiceListComponent extends AbstractList { field: 'complex.business_activity', header: 'عنوان کسب و کار', type: 'nested', - nestedPath: 'complex.business_activity.name', + nestedOption: { path: 'complex.business_activity.name' }, }, { field: 'complex', header: 'عنوان شعبه', type: 'nested', - nestedPath: 'complex.name', + nestedOption: { path: 'complex.name' }, }, { field: 'customAction', diff --git a/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts b/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts index 105b6d9..f0e470e 100644 --- a/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts +++ b/src/app/domains/consumer/modules/saleInvoices/components/list.component.ts @@ -35,7 +35,7 @@ export class ConsumerSaleInvoiceListComponent extends AbstractList { override setColumns(): void { this.columns = [ { field: 'id', header: 'شناسه', type: 'id' }, - { field: 'username', header: 'نام کاربری', type: 'nested', nestedPath: 'account.username' }, + { + field: 'username', + header: 'نام کاربری', + type: 'nested', + nestedOption: { path: 'account.username' }, + }, { field: 'role', header: 'نقش' }, - { field: 'status', header: 'وضعیت', type: 'nested', nestedPath: 'account.status' }, + { + field: 'status', + header: 'وضعیت', + type: 'nested', + nestedOption: { path: 'account.status' }, + }, { field: 'created_at', header: 'تاریخ ایجاد', diff --git a/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts b/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts index 12a7030..f7e7c7c 100644 --- a/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts +++ b/src/app/domains/partner/modules/consumers/components/accounts/list.component.ts @@ -20,17 +20,17 @@ export class ConsumerAccountListComponent extends AbstractList
- @if (form.controls.pos_type.value === "PSP") { + } diff --git a/src/app/domains/partner/modules/consumers/components/poses/form.component.ts b/src/app/domains/partner/modules/consumers/components/poses/form.component.ts index dc3c8bd..5b06fe4 100644 --- a/src/app/domains/partner/modules/consumers/components/poses/form.component.ts +++ b/src/app/domains/partner/modules/consumers/components/poses/form.component.ts @@ -43,6 +43,13 @@ export class ConsumerPosFormComponent extends AbstractFormDialog { if (value === 'PSP') { + form.addControl( + 'serial', + this.fb.control(this.initialValues?.serial ?? '', { + nonNullable: true, + validators: [Validators.required], + }), + ); form.addControl( 'device_id', this.fb.control(this.initialValues?.device?.id ?? '', { @@ -58,6 +65,8 @@ export class ConsumerPosFormComponent extends AbstractFormDialog { @Input() header: IColumn[] = [ { field: 'id', header: 'شناسه', type: 'id' }, { field: 'name', header: 'عنوان' }, - { field: 'serial', header: 'شماره سریال' }, - { field: 'device', header: 'دستگاه', type: 'nested', nestedPath: 'device.name' }, + { field: 'serial_number', header: 'شماره سریال' }, + { field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } }, { field: 'pos_type', header: 'نوع دستگاه' }, - { field: 'provider', header: 'ارایه‌دهنده', type: 'nested', nestedPath: 'provider.name' }, + { + field: 'provider', + header: 'ارایه‌دهنده', + type: 'nested', + nestedOption: { path: 'provider.name' }, + }, { field: 'status', header: 'وضعیت' }, { field: 'created_at', diff --git a/src/app/domains/partner/modules/consumers/models/businessActivities_io.d.ts b/src/app/domains/partner/modules/consumers/models/businessActivities_io.d.ts index 7ca3553..29c3708 100644 --- a/src/app/domains/partner/modules/consumers/models/businessActivities_io.d.ts +++ b/src/app/domains/partner/modules/consumers/models/businessActivities_io.d.ts @@ -1,10 +1,12 @@ import ISummary from '@/core/models/summary'; export interface IBusinessActivityRawResponse { + id: string; name: string; economic_code: string; guild: ISummary; - id: string; + created_at: string; + license_info: LicenseInfo; } export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {} @@ -13,3 +15,10 @@ export interface IBusinessActivityRequest { economic_code: string; guild_id: string; } + +interface LicenseInfo { + id: string; + starts_at: string; + expires_at: string; + accounts_limit: number; +} diff --git a/src/app/domains/partner/modules/consumers/views/businessActivities/single.component.html b/src/app/domains/partner/modules/consumers/views/businessActivities/single.component.html index e53c363..6603c20 100644 --- a/src/app/domains/partner/modules/consumers/views/businessActivities/single.component.html +++ b/src/app/domains/partner/modules/consumers/views/businessActivities/single.component.html @@ -5,6 +5,8 @@ + + diff --git a/src/app/domains/partner/modules/consumers/views/complexes/single.component.html b/src/app/domains/partner/modules/consumers/views/complexes/single.component.html index 68be6af..fc23176 100644 --- a/src/app/domains/partner/modules/consumers/views/complexes/single.component.html +++ b/src/app/domains/partner/modules/consumers/views/complexes/single.component.html @@ -3,6 +3,7 @@
+
diff --git a/src/app/domains/partner/modules/consumers/views/single.component.html b/src/app/domains/partner/modules/consumers/views/single.component.html index d3a48c6..55573ae 100644 --- a/src/app/domains/partner/modules/consumers/views/single.component.html +++ b/src/app/domains/partner/modules/consumers/views/single.component.html @@ -6,25 +6,6 @@ - @if (licenseStatus() === "EXPIRED") { - - - منقضی شده در - - - - } @else if (licenseStatus() === "ACTIVE") { - - - تا تاریخ - - - - } @else { - - ارایه نشده - - } @@ -39,13 +20,4 @@ [initialValues]="consumer() || undefined" (onSubmit)="getData()" /> - - diff --git a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html index 1aad815..6c7afc4 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html +++ b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html @@ -34,12 +34,21 @@ + > + + + +
diff --git a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts index 8baaa88..c4d34df 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts +++ b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.ts @@ -7,6 +7,7 @@ import { formatWithCurrency } from '@/utils'; import { Component, EventEmitter, Output, signal } from '@angular/core'; import { ReactiveFormsModule, Validators } from '@angular/forms'; import { Button } from 'primeng/button'; +import { SelectButton, SelectButtonChangeEvent } from 'primeng/selectbutton'; import { IGoldPayload, IPosOrderItem } from '../../../models'; import { PosFormDialogAmountCardTemplateComponent } from '../form-dialog-amount-card-template.component'; @@ -19,6 +20,7 @@ import { PosFormDialogAmountCardTemplateComponent } from '../form-dialog-amount- EnumSelectComponent, Button, PosFormDialogAmountCardTemplateComponent, + SelectButton, AmountPercentageInputComponent, ], }) @@ -29,9 +31,22 @@ export class PosGoldPayloadFormComponent extends AbstractForm< @Output() onSubmitForm = new EventEmitter(); @Output() onChangeTotalAmount = new EventEmitter(); + readonly discountTypeItems = [ + { + label: 'از سود', + value: 1, + }, + { + label: 'از کل', + value: 2, + }, + ]; + + discountType = signal(1); unitWithQuantity = signal(0); totalAmountBeforeProfit = signal(0); baseTotalAmount = signal(0); + baseAmountForDiscountCalculation = signal(0); taxAmount = signal(0); totalAmount = signal(0); @@ -94,7 +109,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm< updateCalculateAmount(payload: Partial>) { const commissionAmount = Number(payload.payload?.commission_amount ?? '0'); - const wageAmount = Number(payload.payload?.wages ?? '0'); + const wageAmount = Number(payload.payload?.wages_amount ?? '0'); const discountAmount = Number(payload.discount_amount ?? '0'); const profitAmount = Number(payload.payload?.profit_amount ?? '0'); const unitPrice = Number(payload.unit_price ?? '0'); @@ -103,6 +118,8 @@ export class PosGoldPayloadFormComponent extends AbstractForm< const unitWithQuantity = unitPrice * quantity; const totalAmountBeforeProfit = unitWithQuantity + wageAmount + commissionAmount; const baseTotalAmount = totalAmountBeforeProfit + profitAmount; + const baseAmountForDiscountCalculation = + this.discountType() === 1 ? profitAmount : baseTotalAmount; const taxAmount = (profitAmount + commissionAmount + wageAmount - discountAmount) * 0.1; const totalAmount = baseTotalAmount - discountAmount + taxAmount; @@ -111,6 +128,7 @@ export class PosGoldPayloadFormComponent extends AbstractForm< this.baseTotalAmount.set(baseTotalAmount); this.taxAmount.set(taxAmount); this.totalAmount.set(totalAmount); + this.baseAmountForDiscountCalculation.set(baseAmountForDiscountCalculation); this.onChangeTotalAmount.emit(totalAmount); } @@ -121,4 +139,10 @@ export class PosGoldPayloadFormComponent extends AbstractForm< } return `(${formatWithCurrency(amount)})`; } + + changeDiscountCalculation($event: SelectButtonChangeEvent) { + this.discountType.set($event.value); + + this.updateCalculateAmount(this.form.value as any); + } } diff --git a/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts b/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts index 876abd4..7ec7680 100644 --- a/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts +++ b/src/app/domains/superAdmin/modules/consumers/components/accounts/list.component.ts @@ -23,14 +23,14 @@ export class ConsumerAccountListComponent extends AbstractList { @Input() header: IColumn[] = [ { field: 'id', header: 'شناسه', type: 'id' }, { field: 'name', header: 'عنوان' }, - { field: 'serial', header: 'شماره سریال' }, - { field: 'device', header: 'دستگاه', type: 'nested', nestedPath: 'device.name' }, + { field: 'serial_number', header: 'شماره سریال' }, + { field: 'device', header: 'دستگاه', type: 'nested', nestedOption: { path: 'device.name' } }, { field: 'pos_type', header: 'نوع دستگاه' }, - { field: 'provider', header: 'ارایه‌دهنده', type: 'nested', nestedPath: 'provider.name' }, + { + field: 'provider', + header: 'ارایه‌دهنده', + type: 'nested', + nestedOption: { path: 'provider.name' }, + }, { field: 'status', header: 'وضعیت' }, { field: 'created_at', diff --git a/src/app/domains/superAdmin/modules/consumers/views/complexes/single.component.html b/src/app/domains/superAdmin/modules/consumers/views/complexes/single.component.html index 01192fb..1d2c588 100644 --- a/src/app/domains/superAdmin/modules/consumers/views/complexes/single.component.html +++ b/src/app/domains/superAdmin/modules/consumers/views/complexes/single.component.html @@ -3,6 +3,7 @@
+
diff --git a/src/app/domains/superAdmin/modules/devices/views/list.component.ts b/src/app/domains/superAdmin/modules/devices/views/list.component.ts index 05ed16d..da2bb11 100644 --- a/src/app/domains/superAdmin/modules/devices/views/list.component.ts +++ b/src/app/domains/superAdmin/modules/devices/views/list.component.ts @@ -18,7 +18,12 @@ export class DevicesComponent extends AbstractList { this.columns = [ { field: 'id', header: 'شناسه', type: 'id' }, { field: 'name', header: 'عنوان' }, - { field: 'brand', header: 'برند دستگاه', type: 'nested', nestedPath: 'name' }, + { + field: 'brand', + header: 'برند دستگاه', + type: 'nested', + nestedOption: { path: 'brand.name' }, + }, { field: 'created_at', header: 'تاریخ ایجاد', diff --git a/src/app/domains/superAdmin/modules/guilds/components/goods/list.component.ts b/src/app/domains/superAdmin/modules/guilds/components/goods/list.component.ts index aa58f1a..e6c5db6 100644 --- a/src/app/domains/superAdmin/modules/guilds/components/goods/list.component.ts +++ b/src/app/domains/superAdmin/modules/guilds/components/goods/list.component.ts @@ -21,7 +21,12 @@ export class GuildGoodsListComponent extends AbstractList { { field: 'image_url', header: 'تصویر', type: 'thumbnail' }, { field: 'name', header: 'عنوان' }, { field: 'sku', header: 'شناسه‌ی عمومی' }, - { field: 'category', header: 'دسته‌بندی', type: 'nested', nestedPath: 'category.name' }, + { + field: 'category', + header: 'دسته‌بندی', + type: 'nested', + nestedOption: { path: 'category.name' }, + }, { field: 'created_at', header: 'تاریخ ایجاد', diff --git a/src/app/domains/superAdmin/modules/partners/components/accounts/list.component.ts b/src/app/domains/superAdmin/modules/partners/components/accounts/list.component.ts index 28a9202..a198396 100644 --- a/src/app/domains/superAdmin/modules/partners/components/accounts/list.component.ts +++ b/src/app/domains/superAdmin/modules/partners/components/accounts/list.component.ts @@ -23,14 +23,14 @@ export class ConsumerAccountListComponent extends AbstractList + @if (labelSuffix) { + +
+ + {{ preparedLabel() }} + + +
+
+ } + @if (selectedType.value === "amount") { (); @Output() blur = new EventEmitter(); + @ContentChild('labelSuffix', { static: false }) labelSuffix!: TemplateRef | null; + private readonly toastService = inject(ToastService); readonly typeSelectOptions: IAmountPercentageInputSelect[] = [ diff --git a/src/app/shared/components/pageDataList/page-data-list.component.ts b/src/app/shared/components/pageDataList/page-data-list.component.ts index 11b0475..c8d3d2e 100644 --- a/src/app/shared/components/pageDataList/page-data-list.component.ts +++ b/src/app/shared/components/pageDataList/page-data-list.component.ts @@ -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 { 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 { getCell(item: Record, 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 '-'; } diff --git a/src/app/uikit/uikit-field.component.html b/src/app/uikit/uikit-field.component.html index 93c3cd3..3af1b53 100644 --- a/src/app/uikit/uikit-field.component.html +++ b/src/app/uikit/uikit-field.component.html @@ -3,9 +3,13 @@ @if (showLabel) {
- - {{ label }} - + @if (labelView) { + + } @else { + + {{ label }} + + }
} @else { diff --git a/src/app/uikit/uikit-field.component.ts b/src/app/uikit/uikit-field.component.ts index 38dfd4f..671d5be 100644 --- a/src/app/uikit/uikit-field.component.ts +++ b/src/app/uikit/uikit-field.component.ts @@ -1,6 +1,6 @@ import { FormErrorsService } from '@/core/services/form-errors.service'; import { CommonModule } from '@angular/common'; -import { Component, Input, inject } from '@angular/core'; +import { Component, ContentChild, Input, TemplateRef, inject } from '@angular/core'; import { AbstractControl } from '@angular/forms'; import { MessageModule } from 'primeng/message'; import { UikitLabelComponent } from './uikit-label.component'; @@ -25,6 +25,8 @@ export class UikitFieldComponent { @Input() showErrors: boolean = true; @Input() showLabel: boolean = true; + @ContentChild('labelView', { static: false }) labelView!: TemplateRef | null; + private errorsService = inject(FormErrorsService); get hasError(): boolean { diff --git a/src/app/utils/form-data.util.ts b/src/app/utils/form-data.util.ts index 5fe239f..c515548 100644 --- a/src/app/utils/form-data.util.ts +++ b/src/app/utils/form-data.util.ts @@ -4,9 +4,6 @@ export function buildFormData( ): FormData { const formData = new FormData(); - console.log(formGroup); - console.log(formGroup.controls); - Object.keys(formGroup.controls).forEach((key) => { const control = formGroup.get(key); if (control && control.value !== null && control.value !== undefined) {