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:
@@ -44,7 +44,9 @@ export class ConsumerSaleInvoiceSharedComponent {
|
||||
field: 'name',
|
||||
header: 'عنوان',
|
||||
type: 'nested',
|
||||
nestedPath: 'good.name',
|
||||
nestedOption: {
|
||||
path: 'good.name',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'unit_price',
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[closable]="true"
|
||||
(onHide)="close()"
|
||||
>
|
||||
@if (!licenseStatus()) {
|
||||
<!-- @if (!licenseStatus()) {
|
||||
<p-message severity="warn" [closable]="false" variant="text" icon="pi pi-info-circle" class="mb-5">
|
||||
برای کاربر شما لایسنسی در نظر گرفته نشده است. برای پیگیری با پشتیبانی تماس بگیرید.
|
||||
</p-message>
|
||||
@@ -21,5 +21,5 @@
|
||||
<app-key-value label="انقضای لایسنس" [value]="license()?.expires_at!" type="date" />
|
||||
<app-key-value label="ارایه شده توسط" [value]="license()?.partner?.name || 'برند نرمافزار'" />
|
||||
</div>
|
||||
}
|
||||
} -->
|
||||
</p-dialog>
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ng-template #topBarMoreAction>
|
||||
<!-- <ng-template #topBarMoreAction>
|
||||
@if (licenseStatus() === "ACTIVE") {
|
||||
<p-button outlined severity="success" size="small" (click)="showLicenseInfo()">لایسنس فعال</p-button>
|
||||
} @else if (licenseStatus() === "EXPIRED") {
|
||||
@@ -12,7 +12,7 @@
|
||||
<i class="pi pi-question-circle" pButtonIcon></i>
|
||||
</p-button>
|
||||
}
|
||||
</ng-template>
|
||||
</ng-template> -->
|
||||
|
||||
<consumer-license-info-dialog [(visible)]="visibleLicenseInfo" />
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
-10
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,9 +20,19 @@ export class ConsumerAccountsComponent extends AbstractList<IAccountResponse> {
|
||||
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: 'تاریخ ایجاد',
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ export class ConsumerComplexListComponent extends AbstractList<IComplexResponse>
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'branch_code', header: 'کد شعبه' },
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
|
||||
+6
-1
@@ -23,7 +23,12 @@ export class ConsumerComplexGoodsListComponent extends AbstractList<IConsumerCom
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ 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: 'تاریخ ایجاد',
|
||||
|
||||
@@ -21,7 +21,24 @@ export class ConsumerBusinessActivityListComponent extends AbstractList<IBusines
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه', type: 'id' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'guild', header: 'صنف', type: 'nested', nestedPath: 'guild.name' },
|
||||
{ field: 'guild', header: 'صنف', type: 'nested', nestedOption: { path: 'guild.name' } },
|
||||
{
|
||||
field: 'license_info',
|
||||
header: 'محدودیت کاربر',
|
||||
customDataModel(item) {
|
||||
const licenseInfo = (item as IBusinessActivityResponse).license_info;
|
||||
if (!licenseInfo) {
|
||||
return 'بدون مجوز';
|
||||
}
|
||||
return `${licenseInfo.accounts_limit} کاربر`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'license_info',
|
||||
header: 'انقضای مجوز',
|
||||
type: 'nested',
|
||||
nestedOption: { path: 'license_info.expires_at', type: 'date' },
|
||||
},
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
|
||||
@@ -5,6 +5,8 @@ export interface IBusinessActivityRawResponse {
|
||||
name: string;
|
||||
economic_code: string;
|
||||
guild: ISummary;
|
||||
created_at: string;
|
||||
license_info: LicenseInfo;
|
||||
}
|
||||
export interface IBusinessActivityResponse extends IBusinessActivityRawResponse {}
|
||||
|
||||
@@ -12,3 +14,10 @@ export interface IBusinessActivityRequest {
|
||||
economic_code: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface LicenseInfo {
|
||||
id: string;
|
||||
starts_at: string;
|
||||
expires_at: string;
|
||||
accounts_limit: number;
|
||||
}
|
||||
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="grid grid-cols-3 gap-4 items-center">
|
||||
<app-key-value label="عنوان" [value]="complex()?.name" />
|
||||
<app-key-value label="کد شعبه" [value]="complex()?.branch_code" />
|
||||
<app-key-value label="آدرس" [value]="complex()?.address" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ export class ConsumerCustomerSaleInvoiceListComponent extends AbstractList<ICust
|
||||
field: 'account',
|
||||
header: 'ایجاد شده توسط',
|
||||
type: 'nested',
|
||||
nestedPath: 'account.account.username',
|
||||
nestedOption: { path: 'account.account.username' },
|
||||
},
|
||||
{
|
||||
field: 'invoice_date',
|
||||
|
||||
@@ -39,13 +39,13 @@ export class ConsumerPosListComponent extends AbstractList<IPosResponse> {
|
||||
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',
|
||||
|
||||
@@ -35,7 +35,7 @@ export class ConsumerSaleInvoiceListComponent extends AbstractList<IConsumerSale
|
||||
field: 'account',
|
||||
header: 'ایجاد شده توسط',
|
||||
type: 'nested',
|
||||
nestedPath: 'account.account.username',
|
||||
nestedOption: { path: 'account.account.username' },
|
||||
},
|
||||
{
|
||||
field: 'invoice_date',
|
||||
|
||||
Reference in New Issue
Block a user