From cb6be84cb91d512f8803f3b8da684bd810c79988 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Sun, 10 May 2026 17:55:30 +0330 Subject: [PATCH] feat: remove AGENT.md and add new agents.md with updated repository-specific instructions refactor: update shared-saleInvoice.component.ts to simplify SKU code handling refactor: modify goods.component.html to optimize payload form dialog rendering fix: adjust goods.component.ts to ensure payload form visibility logic is correct fix: update order-section.component.ts to improve customer dialog and payment form visibility style: enhance form.component.html button styling for better responsiveness fix: change abstract-form.ts to reset form with default values on initialization refactor: streamline page-data-list-grid-view.component.html for better caption handling refactor: update page-data-list-grid-view.component.ts to remove unused methods and improve readability refactor: simplify page-data-list-table-view.component.html and remove redundant code refactor: clean up page-data-list-table-view.component.ts by removing unnecessary methods feat: enhance page-data-list.component.html with new caption and paginator templates feat: create page-data-value.component.ts to encapsulate data rendering logic for grid and table views style: update presets.ts to modify color palette for better UI consistency --- AGENT.md => agents.md | 0 .../invoices/shared-saleInvoice.component.ts | 8 +- .../landing/components/goods.component.html | 8 +- .../landing/components/goods.component.ts | 8 +- .../order/order-section.component.ts | 8 +- .../payloads/standard/form.component.html | 2 +- .../shared/abstractClasses/abstract-form.ts | 4 +- .../page-data-list-grid-view.component.html | 30 +-- .../page-data-list-grid-view.component.ts | 101 +--------- .../page-data-list-table-view.component.html | 50 +---- .../page-data-list-table-view.component.ts | 104 +--------- .../page-data-list.component.html | 180 ++++++++---------- .../pageDataList/page-data-value.component.ts | 100 ++++++++++ src/presets.ts | 25 ++- 14 files changed, 243 insertions(+), 385 deletions(-) rename AGENT.md => agents.md (100%) create mode 100644 src/app/shared/components/pageDataList/page-data-value.component.ts diff --git a/AGENT.md b/agents.md similarity index 100% rename from AGENT.md rename to agents.md 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 c0fffc4..64b87de 100644 --- a/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts +++ b/src/app/domains/consumer/components/invoices/shared-saleInvoice.component.ts @@ -10,7 +10,7 @@ import { } from '@/shared/components/pageDataList/page-data-list.component'; import { PriceMaskDirective } from '@/shared/directives'; import { UikitEmptyStateComponent } from '@/uikit'; -import { formatJalali, getGoodUnitTypeProperties } from '@/utils'; +import { formatJalali } from '@/utils'; import { Component, computed, @@ -91,6 +91,10 @@ export class ConsumerSaleInvoiceSharedComponent { path: 'good.name', }, }, + { + field: 'sku_code', + header: 'شناسه کالا', + }, { field: 'unit_price', header: 'قیمت واحد', @@ -100,7 +104,7 @@ export class ConsumerSaleInvoiceSharedComponent { field: 'quantity', header: 'مقدار', customDataModel(item) { - return `${item.quantity} ${getGoodUnitTypeProperties(item.good.unit_type).quantitySymbolText}`; + return `${item.quantity} ${item.measure_unit_text}`; }, }, { diff --git a/src/app/domains/pos/modules/landing/components/goods.component.html b/src/app/domains/pos/modules/landing/components/goods.component.html index 0fcb068..39d9086 100644 --- a/src/app/domains/pos/modules/landing/components/goods.component.html +++ b/src/app/domains/pos/modules/landing/components/goods.component.html @@ -36,11 +36,7 @@ } - @defer (when showPayloadForm()) { - + @if (showPayloadForm() && selectedGoodToAdd(); as selectedGood) { + } diff --git a/src/app/domains/pos/modules/landing/components/goods.component.ts b/src/app/domains/pos/modules/landing/components/goods.component.ts index bce90b4..a5686a0 100644 --- a/src/app/domains/pos/modules/landing/components/goods.component.ts +++ b/src/app/domains/pos/modules/landing/components/goods.component.ts @@ -67,14 +67,14 @@ export class PosGoodsComponent { } addGood(good: IGoodResponse) { - this.showPayloadForm.set(true); - - console.log('good', good); - + this.showPayloadForm.set(false); + this.selectedGoodToAdd.set(null); this.selectedGoodToAdd.set(good); + queueMicrotask(() => this.showPayloadForm.set(true)); } onClosePayloadForm() { + this.showPayloadForm.set(false); this.selectedGoodToAdd.set(null); } } diff --git a/src/app/domains/pos/modules/landing/components/order/order-section.component.ts b/src/app/domains/pos/modules/landing/components/order/order-section.component.ts index d33cd74..e8b0be0 100644 --- a/src/app/domains/pos/modules/landing/components/order/order-section.component.ts +++ b/src/app/domains/pos/modules/landing/components/order/order-section.component.ts @@ -72,13 +72,13 @@ export class PosOrderSectionComponent { } openCustomerDialog() { - // this.this.store.submitOrder(); - this.isVisibleCustomerForm.set(true); + this.isVisibleCustomerForm.set(false); + queueMicrotask(() => this.isVisibleCustomerForm.set(true)); } submitAndPay() { - // this.this.store.submitOrder(); - this.isVisiblePaymentForm.set(true); + this.isVisiblePaymentForm.set(false); + queueMicrotask(() => this.isVisiblePaymentForm.set(true)); } addMoreGoods() { diff --git a/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.html b/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.html index ddce49b..2e60f0b 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.html +++ b/src/app/domains/pos/modules/landing/components/payloads/standard/form.component.html @@ -27,6 +27,6 @@ [discountAmount]="discountAmount()" [taxAmount]="taxAmount()" /> - {{ preparedCTAText() }} + {{ preparedCTAText() }} diff --git a/src/app/shared/abstractClasses/abstract-form.ts b/src/app/shared/abstractClasses/abstract-form.ts index c8916f2..88feecf 100644 --- a/src/app/shared/abstractClasses/abstract-form.ts +++ b/src/app/shared/abstractClasses/abstract-form.ts @@ -37,14 +37,14 @@ export abstract class AbstractForm< } ngOnInit() { - this.form.patchValue(this.initialValues ?? {}); + this.form.reset(this.initialValues ?? this.defaultValues); // Object.entries(this.form.controls).forEach(([key, control]) => { // console.log(key, control); // }); } ngOnChanges() { - this.form.patchValue(this.initialValues ?? {}); + this.form.reset(this.initialValues ?? this.defaultValues); } onSuccess(response: Response): void {} diff --git a/src/app/shared/components/pageDataList/page-data-list-grid-view.component.html b/src/app/shared/components/pageDataList/page-data-list-grid-view.component.html index e06cc1b..066929c 100644 --- a/src/app/shared/components/pageDataList/page-data-list-grid-view.component.html +++ b/src/app/shared/components/pageDataList/page-data-list-grid-view.component.html @@ -1,46 +1,24 @@
- @if (captionBox) { + @if (hasCaption && captionBox) {

} -
+
@for (item of items; track `gridView_${$index}`) {
@for (col of columns; track `gridView_${col.field.toString()}_${$index}`) { @if (col.type !== "index") { - @if (col.type === "thumbnail") { -
- @if (item && col?.field && item[col!.field!]) { - - } -
- } @else if (col.variant === "tag") { - - } @else if (getTemplate(col)) { - - } @else if (col.canCopy) { - - } @else { - - {{ getCell(item, col) }} - - } +
} } diff --git a/src/app/shared/components/pageDataList/page-data-list-grid-view.component.ts b/src/app/shared/components/pageDataList/page-data-list-grid-view.component.ts index 52516bf..2f15ec2 100644 --- a/src/app/shared/components/pageDataList/page-data-list-grid-view.component.ts +++ b/src/app/shared/components/pageDataList/page-data-list-grid-view.component.ts @@ -1,6 +1,4 @@ import { Maybe } from '@/core'; -import { UikitCopyComponent } from '@/uikit'; -import { formatJalali, formatWithCurrency, jalaliDiff } from '@/utils'; import { CommonModule } from '@angular/common'; import { Component, @@ -17,8 +15,8 @@ import { DrawerModule } from 'primeng/drawer'; import { PaginatorModule } from 'primeng/paginator'; import { SkeletonModule } from 'primeng/skeleton'; import { TableModule } from 'primeng/table'; -import { Tag } from 'primeng/tag'; import { KeyValueComponent } from '../key-value.component/key-value.component'; +import { PageDataValueComponent } from './page-data-value.component'; import { IColumn } from './page-data-list.component'; @Component({ @@ -34,9 +32,8 @@ import { IColumn } from './page-data-list.component'; SkeletonModule, PaginatorModule, DrawerModule, - UikitCopyComponent, KeyValueComponent, - Tag, + PageDataValueComponent, ], }) export class AppPageDataListGridView { @@ -62,6 +59,7 @@ export class AppPageDataListGridView { @Input() expandColumns?: Maybe = null; @Input() dataKey?: string = 'items'; @Input() showPaginator?: boolean; + @Input() hasCaption: boolean = false; @ContentChild('filter', { static: true }) filter!: TemplateRef | null; @ContentChild('moreActions', { static: true }) moreActions!: TemplateRef | null; @@ -113,99 +111,6 @@ export class AppPageDataListGridView { // this. }; - getPreviewClasses(item: Record, column: IColumn): any { - if (!item || !column || column.customDataModel) return ''; - try { - const { field } = column; - - const data = item[String(field)]; - switch (column.type) { - case 'date': - if (column.dateOption?.expiredMode) { - if (jalaliDiff(new Date(), data) > 0) { - return 'text-error'; - } - } - return ''; - default: - return; - } - } catch (e) { - return ''; - } - } - - getCell(item: Record, column: IColumn): any { - if (!item || !column) return ''; - try { - let { field, type } = column; - - if (column.customDataModel) { - return this.renderCustom(column, item); - } - - 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, 'ریال'); - case 'number': - return data || 0; - default: - break; - } - } - if (data === undefined || data === null) { - return '-'; - } - if (typeof data === 'object') { - return data.title || '-'; - } - return data || '-'; - } catch (e) { - return '-'; - } - } - - getTemplate(col: IColumn): TemplateRef | null { - const v = col.customDataModel; - return v instanceof TemplateRef ? (v as TemplateRef) : null; - } - - renderCustom(column: IColumn, item: any): any { - const v = column.customDataModel; - - if (!v) { - return null; - } - if (typeof v === 'function') { - try { - return (v as (item: any) => any)(item); - } catch { - return '-'; - } - } - if (typeof v === 'string') return v; - return null; - } - actionsCount = computed(() => { let totalCount = 0; if (this.showEdit) totalCount += 1; diff --git a/src/app/shared/components/pageDataList/page-data-list-table-view.component.html b/src/app/shared/components/pageDataList/page-data-list-table-view.component.html index db480eb..5b1579f 100644 --- a/src/app/shared/components/pageDataList/page-data-list-table-view.component.html +++ b/src/app/shared/components/pageDataList/page-data-list-table-view.component.html @@ -50,29 +50,7 @@ } @for (col of columns; track col.field) { - @if (col.type === "thumbnail") { -
- @if (item[col.field]) { - - } -
- } @else if (col.variant === "tag") { - - } @else if (getTemplate(col)) { - - } @else if (col.canCopy) { - - } @else { - - {{ getCell(item, col) }} - - } + } @if (actionsCount()) { @@ -97,7 +75,7 @@ [text]="true" [rounded]="true" [plain]="true" - [icon]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-right'" + [icon]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-left'" /> } @@ -145,26 +123,12 @@ {{ item.name }} @if (col.type === "index") { {{ i * (currentPage || 1) + 1 }} - } @else if (col.type === "thumbnail") { -
- @if (item[col.field]) { - - } -
- } @else if (getTemplate(col)) { - - } @else if (col.canCopy) { - } @else { - - {{ getCell(item, col) }} - + } } diff --git a/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts b/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts index 6eedbf1..02c4f26 100644 --- a/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts +++ b/src/app/shared/components/pageDataList/page-data-list-table-view.component.ts @@ -1,6 +1,5 @@ import { Maybe } from '@/core'; -import { UikitCopyComponent, UikitEmptyStateComponent } from '@/uikit'; -import { formatJalali, formatWithCurrency, jalaliDiff } from '@/utils'; +import { UikitEmptyStateComponent } from '@/uikit'; import { CommonModule } from '@angular/common'; import { Component, @@ -17,9 +16,9 @@ import { DrawerModule } from 'primeng/drawer'; import { PaginatorModule } from 'primeng/paginator'; import { SkeletonModule } from 'primeng/skeleton'; import { TableModule } from 'primeng/table'; -import { Tag } from 'primeng/tag'; import { KeyValueComponent } from '../key-value.component/key-value.component'; import { TableActionRowComponent } from '../table-action-row.component'; +import { PageDataValueComponent } from './page-data-value.component'; import { IColumn } from './page-data-list.component'; @Component({ @@ -37,9 +36,8 @@ import { IColumn } from './page-data-list.component'; SkeletonModule, PaginatorModule, DrawerModule, - UikitCopyComponent, KeyValueComponent, - Tag, + PageDataValueComponent, ], }) export class AppPageDataListTableView { @@ -66,12 +64,13 @@ export class AppPageDataListTableView { @Input() dataKey?: string = 'items'; @Input() showPaginator?: boolean; @Input() showIndex?: boolean = true; + @Input() hasCaption: boolean = false; @ContentChild('filter', { static: true }) filter!: TemplateRef | null; @ContentChild('paginator', { static: true }) paginator!: TemplateRef | null; @ContentChild('moreActions', { static: true }) moreActions!: TemplateRef | null; @ContentChild('expandableTemp', { static: false }) expandableTemp!: TemplateRef | null; - @ContentChild('captionBox', { static: true }) captionBox!: TemplateRef | null; + @ContentChild('captionBox', { static: false }) captionBox!: TemplateRef | null; @ContentChild('emptyMessageCard', { static: true }) emptyMessageCard!: TemplateRef | null; @Output() onEdit = new EventEmitter(); @@ -117,99 +116,6 @@ export class AppPageDataListTableView { // this. }; - getPreviewClasses(item: Record, column: IColumn): any { - if (!item || !column || column.customDataModel) return ''; - try { - const { field } = column; - - const data = item[String(field)]; - switch (column.type) { - case 'date': - if (column.dateOption?.expiredMode) { - if (jalaliDiff(new Date(), data) > 0) { - return 'text-error'; - } - } - return ''; - default: - return; - } - } catch (e) { - return ''; - } - } - - getCell(item: Record, column: IColumn): any { - if (!item || !column) return ''; - try { - let { field, type } = column; - - if (column.customDataModel) { - return this.renderCustom(column, item); - } - - 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, 'ریال'); - case 'number': - return data || 0; - default: - break; - } - } - if (data === undefined || data === null) { - return '-'; - } - if (typeof data === 'object') { - return data.title || '-'; - } - return data || '-'; - } catch (e) { - return '-'; - } - } - - getTemplate(col: IColumn): TemplateRef | null { - const v = col.customDataModel; - return v instanceof TemplateRef ? (v as TemplateRef) : null; - } - - renderCustom(column: IColumn, item: any): any { - const v = column.customDataModel; - - if (!v) { - return null; - } - if (typeof v === 'function') { - try { - return (v as (item: any) => any)(item); - } catch { - return '-'; - } - } - if (typeof v === 'string') return v; - return null; - } - actionsCount = computed(() => { let totalCount = 0; if (this.showEdit) totalCount += 1; diff --git a/src/app/shared/components/pageDataList/page-data-list.component.html b/src/app/shared/components/pageDataList/page-data-list.component.html index 873a9a3..6b45531 100644 --- a/src/app/shared/components/pageDataList/page-data-list.component.html +++ b/src/app/shared/components/pageDataList/page-data-list.component.html @@ -1,4 +1,70 @@
+ + @if (pageTitle || showAdd || filter || showRefresh || moreActions) { + +
+
{{ pageTitle }}
+ @if (showAdd || filter || showRefresh || moreActions) { +
+ + @if (filter) { + + } + @if (showRefresh) { + + } + @if (showAll && allItemsPageRoute) { + @if (isMobileView) { + + } @else { + نمایش همه + } + } + @if (showAdd) { + @if (isMobileView) { + + } @else { + + } + } +
+ } +
+
+ } +
+ + + + + + + @if (!isMobile) { - - @if (pageTitle || showAdd || filter || caption || showRefresh || moreActions) { - -
-
{{ pageTitle }}
- @if (showAdd || filter || showRefresh || moreActions) { -
- - @if (filter) { - - } - @if (showRefresh) { - - } - @if (showAll && allItemsPageRoute) { - نمایش همه - } - @if (showAdd) { - - } -
- } -
-
- } -
+ @if (pageTitle || showAdd || filter || showRefresh || moreActions) { + + + + } - + - +
} @else { @@ -90,61 +114,21 @@ [showEdit]="showEdit" [showDelete]="showDelete" [showDetails]="showDetails" + [hasCaption]="!!(pageTitle || showAdd || filter || showRefresh || moreActions)" (onEdit)="edit($event)" (onDelete)="remove($event)" (onDetails)="details($event)" > - @if (pageTitle || showAdd || filter || caption || showRefresh || moreActions) { - -
-
{{ pageTitle }}
- @if (showAdd || filter || showRefresh || moreActions) { -
- - @if (filter) { - - } - @if (showRefresh) { - - } - @if (showAll && allItemsPageRoute) { - - } - @if (showAdd) { - - } -
- } -
-
+ @if (pageTitle || showAdd || filter || showRefresh || moreActions) { + }
- + - + } diff --git a/src/app/shared/components/pageDataList/page-data-value.component.ts b/src/app/shared/components/pageDataList/page-data-value.component.ts new file mode 100644 index 0000000..e36c862 --- /dev/null +++ b/src/app/shared/components/pageDataList/page-data-value.component.ts @@ -0,0 +1,100 @@ +import { formatJalali, formatWithCurrency, jalaliDiff } from '@/utils'; +import { CommonModule } from '@angular/common'; +import { Component, EventEmitter, Input, Output, TemplateRef } from '@angular/core'; +import { Tag } from 'primeng/tag'; +import { UikitCopyComponent } from '@/uikit'; +import { IColumn } from './page-data-list.component'; + +@Component({ + selector: 'app-page-data-value', + standalone: true, + imports: [CommonModule, Tag, UikitCopyComponent], + template: ` + @if (column.type === 'thumbnail') { +
+ @if (readFieldValue(item, column.field)) { + + } +
+ } @else if (column.variant === 'tag') { + + } @else if (getTemplate(column)) { + + } @else if (column.canCopy) { + + } @else { + {{ getCell(item, column) }} + } + `, +}) +export class PageDataValueComponent { + @Input({ required: true }) item!: Record; + @Input({ required: true }) column!: IColumn; + @Output() thumbnailClick = new EventEmitter(); + + readFieldValue(item: Record, field: IColumn['field']) { + return item?.[String(field)]; + } + + getPreviewClasses(item: Record, column: IColumn): string { + if (!item || !column || column.customDataModel) return ''; + const data = item[String(column.field)]; + if (column.type === 'date' && column.dateOption?.expiredMode && jalaliDiff(new Date(), data) > 0) { + return 'text-error'; + } + return ''; + } + + getCell(item: Record, column: IColumn): any { + if (!item || !column) return ''; + let { field, type } = column; + + if (column.customDataModel) { + return this.renderCustom(column, item); + } + + let data = item[String(field)]; + if (column.type === 'nested') { + const path = column.nestedOption?.path; + if (!path) return '-'; + data = path.split('.').reduce((obj: any, key: string) => (obj && obj[key] !== undefined ? obj[key] : null), item); + type = column.nestedOption?.type || 'simple'; + } + + switch (type) { + case 'id': + return data ? `${data.slice(0, 5)}...${data.slice(data.length - 5)}` : '-'; + case 'date': + return data ? formatJalali(data) : '-'; + case 'boolean': + return data ? 'بله' : 'خیر'; + case 'price': + return formatWithCurrency(data, false, 'ریال'); + case 'number': + return data || 0; + } + + if (data === undefined || data === null) return '-'; + if (typeof data === 'object') return data.title || '-'; + return data || '-'; + } + + getTemplate(col: IColumn): TemplateRef | null { + const v = col.customDataModel; + return v instanceof TemplateRef ? (v as TemplateRef) : null; + } + + renderCustom(column: IColumn, item: any): any { + const v = column.customDataModel; + if (!v) return null; + if (typeof v === 'function') { + try { + return (v as (item: any) => any)(item); + } catch { + return '-'; + } + } + if (typeof v === 'string') return v; + return null; + } +} diff --git a/src/presets.ts b/src/presets.ts index 5a15cb7..487270d 100644 --- a/src/presets.ts +++ b/src/presets.ts @@ -31,6 +31,9 @@ const MyPreset = definePreset(Aura, { }, }, semantic: { + ...updateSurfacePalette({ + 0: '#fcfcfc', + }), primary: { 0: '{surface.0}', 50: '{surface.50}', @@ -45,9 +48,27 @@ const MyPreset = definePreset(Aura, { 900: '{surface.900}', 950: '{surface.950}', }, - colorScheme: { + colorScheme: { + light: {}, + dark: {}, + }, light: { + surface: { + 0: '#fcfcfc', + 50: '#f8fafc', + 100: '#f1f5f9', + 200: '#e2e8f0', + 300: '#cbd5e1', + 400: '#94a3b8', + 500: '#64748b', + 600: '#475569', + 700: '#334155', + 800: '#1e293b', + 900: '#0f172a', + 950: '#020617', + }, + primary: { color: '{primary.950}', contrastColor: '#f0f0f0', @@ -79,7 +100,7 @@ const MyPreset = definePreset(Aura, { }, primitive: { ...updateSurfacePalette({ - 0: '#f0f0f0', + 0: '#fcfcfc', 50: '#f8fafc', 100: '#f1f5f9', 200: '#e2e8f0',