From 6d9dff00755c57f40ede3a328591939d4a5fd673 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=87etin?=
<69278826+cetincakiroglu@users.noreply.github.com>
Date: Mon, 6 Jan 2025 15:53:16 +0300
Subject: [PATCH] Fix table demos
---
src/views/uikit/tabledoc.ts | 225 +++++++++++++++++++++---------------
1 file changed, 135 insertions(+), 90 deletions(-)
diff --git a/src/views/uikit/tabledoc.ts b/src/views/uikit/tabledoc.ts
index 517aa75..7648ac8 100644
--- a/src/views/uikit/tabledoc.ts
+++ b/src/views/uikit/tabledoc.ts
@@ -16,7 +16,8 @@ import { Customer, CustomerService, Representative } from '@/src/service/custome
import { Product, ProductService } from '@/src/service/product.service';
import { RippleModule } from 'primeng/ripple';
import { InputIconModule } from 'primeng/inputicon';
-import { IconField } from 'primeng/iconfield';
+import { IconFieldModule } from 'primeng/iconfield';
+import { TagModule } from 'primeng/tag';
interface expandedRows {
[key: string]: boolean;
@@ -24,12 +25,12 @@ interface expandedRows {
@Component({
standalone: true,
- imports: [TableModule, MultiSelectModule, InputIconModule, SelectModule, InputTextModule, SliderModule, ProgressBarModule, ToggleButtonModule, ToastModule, CommonModule, FormsModule, ButtonModule, RatingModule, RippleModule, IconField],
+ imports: [TableModule, MultiSelectModule,SelectModule, InputIconModule, TagModule, InputTextModule, SliderModule, ProgressBarModule, ToggleButtonModule, ToastModule, CommonModule, FormsModule, ButtonModule, RatingModule, RippleModule, IconFieldModule],
template: `
Filtering
@@ -46,21 +47,21 @@ interface expandedRows {
|
- |
- |
-
+
Agent
@@ -71,11 +72,11 @@ interface expandedRows {
+ (onChange)="filter($event.value)" optionLabel="name" styleClass="w-full">
-
+
{{ option.name }}
@@ -86,21 +87,21 @@ interface expandedRows {
|
- |
- |
-
+
Status
@@ -117,7 +118,7 @@ interface expandedRows {
|
-
+
Activity
@@ -125,7 +126,7 @@ interface expandedRows {
-
+
{{ activityValues[0] }}
{{ activityValues[1] }}
@@ -134,7 +135,7 @@ interface expandedRows {
|
-
+
@@ -147,15 +148,19 @@ interface expandedRows {
{{ customer.name }}
-
- {{ customer.country.name }}
+
+ 
+ {{ customer.country.name }}
+
|
-
- {{ customer.representative.name }}
+
+ 
+ {{ customer.representative.name }}
+
|
{{ customer.date | date: 'MM/dd/yyyy' }}
@@ -164,15 +169,14 @@ interface expandedRows {
{{ customer.balance | currency:'USD':'symbol' }}
|
- {{ customer.status }}
+
|
|
-
+
|
|
@@ -191,50 +195,34 @@ interface expandedRows {
Frozen Columns
-
+
-
-
+
+
- | Name |
- Id |
- Country |
- Date |
- Company |
- Status |
- Activity |
- Representative |
- Balance |
+ Name |
+ Id |
+ Country |
+ Date |
+ Company |
+ Status |
+ Activity |
+ Representative |
+ Balance |
-
+
- | {{ customer.name }} |
- {{ customer.id }}
- |
-
-
- {{ customer.country.name }}
- |
- {{ customer.date }} |
- {{ customer.company }} |
-
- {{ customer.status }}
- |
- {{ customer.activity }} |
-
-
- {{ customer.representative.name }}
- |
- {{ formatCurrency(customer.balance) }}
+ | {{ customer.name }} |
+ {{ customer.id }} |
+ {{ customer.country.name }} |
+ {{ customer.date }} |
+ {{ customer.company }} |
+ {{ customer.status }} |
+ {{ customer.activity }} |
+ {{ customer.representative.name }} |
+
+ {{ formatCurrency(customer.balance) }}
|
@@ -279,15 +267,15 @@ interface expandedRows {
[icon]="expanded ? 'pi pi-chevron-down' : 'pi pi-chevron-right'">
{{ product.name }} |
- ![]() |
+ ![]() |
{{ product.price | currency:'USD' }} |
{{ product.category }} |
|
- {{ product.inventoryStatus }}
+ |
+
|
@@ -345,9 +333,7 @@ interface expandedRows {
Grouping
-
+
| Name |
@@ -357,37 +343,55 @@ interface expandedRows {
Date |
-
-
-
-
- {{ customer.representative.name }}
+
+
+
+
+ 
+ {{ customer.representative.name }}
+
|
+
+
- |
- {{ customer.name }}
- | ƒ
-
-
- {{ customer.country.name }}
+ |
+ Total Customers: {{calculateCustomerTotal(customer.representative.name)}}
|
-
+ |
+
+
+
+ |
+ {{ customer.name }}
+ |
+
+
+ 
+ {{ customer.country.name }}
+
+ |
+
{{ customer.company }}
|
-
- {{ customer.status }}
+ |
+
|
-
+ |
{{ customer.date }}
|
`,
+ styles: `
+ .p-datatable-frozen-tbody {
+ font-weight: bold;
+ }
+
+ .p-datatable-scrollable .p-frozen-column {
+ font-weight: bold;
+ }`,
providers: [ConfirmationService, MessageService, CustomerService, ProductService],
})
export class TableDoc implements OnInit {
@@ -416,7 +420,7 @@ export class TableDoc implements OnInit {
isExpanded: boolean = false;
- idFrozen: boolean = false;
+ balanceFrozen: boolean = false;
loading: boolean = true;
@@ -511,5 +515,46 @@ export class TableDoc implements OnInit {
this.filter.nativeElement.value = '';
}
+ getSeverity(status: string) {
+ switch (status) {
+ case 'qualified':
+ case 'instock':
+ case 'INSTOCK':
+ case 'DELIVERED':
+ case 'delivered':
+ return 'success';
+
+ case 'negotiation':
+ case 'lowstock':
+ case 'LOWSTOCK':
+ case 'PENDING':
+ case 'pending':
+ return 'warn';
+
+ case 'unqualified':
+ case 'outofstock':
+ case 'OUTOFSTOCK':
+ case 'CANCELLED':
+ case 'cancelled':
+ return 'danger';
+
+ default:
+ return 'info'
+ }
+ }
+
+ calculateCustomerTotal(name: string) {
+ let total = 0;
+
+ if (this.customers2) {
+ for (let customer of this.customers2) {
+ if (customer.representative?.name === name) {
+ total++;
+ }
+ }
+ }
+
+ return total;
+ }
}
|