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
This commit is contained in:
@@ -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<I = any> {
|
||||
@@ -66,12 +64,13 @@ export class AppPageDataListTableView<I = any> {
|
||||
@Input() dataKey?: string = 'items';
|
||||
@Input() showPaginator?: boolean;
|
||||
@Input() showIndex?: boolean = true;
|
||||
@Input() hasCaption: boolean = false;
|
||||
|
||||
@ContentChild('filter', { static: true }) filter!: TemplateRef<any> | null;
|
||||
@ContentChild('paginator', { static: true }) paginator!: TemplateRef<any> | null;
|
||||
@ContentChild('moreActions', { static: true }) moreActions!: TemplateRef<any> | null;
|
||||
@ContentChild('expandableTemp', { static: false }) expandableTemp!: TemplateRef<any> | null;
|
||||
@ContentChild('captionBox', { static: true }) captionBox!: TemplateRef<any> | null;
|
||||
@ContentChild('captionBox', { static: false }) captionBox!: TemplateRef<any> | null;
|
||||
@ContentChild('emptyMessageCard', { static: true }) emptyMessageCard!: TemplateRef<any> | null;
|
||||
|
||||
@Output() onEdit = new EventEmitter<any>();
|
||||
@@ -117,99 +116,6 @@ export class AppPageDataListTableView<I = any> {
|
||||
// this.
|
||||
};
|
||||
|
||||
getPreviewClasses(item: Record<string, any>, 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<string, any>, 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<any> | null {
|
||||
const v = col.customDataModel;
|
||||
return v instanceof TemplateRef ? (v as TemplateRef<any>) : 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;
|
||||
|
||||
Reference in New Issue
Block a user