Skip to content

Commit 832f025

Browse files
sluFicodesSHENGXING LU
andauthored
Slu/order list (#217)
* order item action shown in front * filter by order item action --------- Co-authored-by: SHENGXING LU <slu@SHENGXINGs-MacBook-Air.local>
1 parent 6d8ded9 commit 832f025

6 files changed

Lines changed: 94 additions & 5 deletions

File tree

src/app/pages/product-orders/sections/order-info/order-info.component.html

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,51 @@
3030
<!-- FILTERS -->
3131
<div class="w-full h-fit mb-4 flex flex-col">
3232
<div class="flex w-full flex-col items-center lg:flex-row justify-between">
33+
<div class="p-8 w-full">
34+
<div class="flex flex-row mb-1">
35+
<fa-icon [icon]="faSwatchbook" class="fa-base text-primary-100 align-middle mr-2"></fa-icon>
36+
<h2 class="text-base dark:text-white font-bold">{{ 'PRODUCT_ORDERS._filter_action' | translate }}</h2>
37+
</div>
38+
<button id="dropdownActionButton" data-dropdown-toggle="dropdownAction" (click)="$event.stopPropagation();"
39+
class="text-black border border-primary-100sa dark:text-white w-full justify-between bg-white dark:bg-secondary-200 hover:bg-gray-100 dark:hover:bg-secondary-300 focus:ring-2 focus:outline-none focus:ring-primary-100 font-medium rounded-lg text-sm p-2.5 text-center inline-flex items-center"
40+
type="button">
41+
@if(actionFilters.length > 0){
42+
{{actionFilters.join(', ')}}
43+
} @else {
44+
{{ 'PRODUCT_ORDERS._filter_action' | translate }}
45+
}
46+
<svg class="w-4 h-4 ml-2" aria-hidden="true" fill="none" stroke="currentColor" viewBox="0 0 24 24"
47+
xmlns="http://www.w3.org/2000/svg">
48+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
49+
</svg>
50+
</button>
51+
52+
<div id="dropdownAction" class="z-20 hidden w-fit md:w-1/5 p-3 bg-white rounded-lg border dark:bg-secondary-200">
53+
<ul class="space-y-2 text-sm" aria-labelledby="dropdownActionButton">
54+
<li class="flex items-center">
55+
<input id="actionAdd" type="checkbox" [checked]="actionFilters.includes('add')" (change)="onActionFilterChange('add')"
56+
class="w-4 h-4 bg-gray-100 checked:bg-primary-100 dark:checked:bg-primary-100 border-gray-300 rounded focus:ring-primary-100 dark:focus:ring-primary-100 dark:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500" />
57+
<label for="actionAdd" class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-100">
58+
{{ 'PRODUCT_ORDERS._action_add' | translate }}
59+
</label>
60+
</li>
61+
<li class="flex items-center">
62+
<input id="actionModify" type="checkbox" [checked]="actionFilters.includes('modify')" (change)="onActionFilterChange('modify')"
63+
class="w-4 h-4 bg-gray-100 checked:bg-primary-100 dark:checked:bg-primary-100 border-gray-300 rounded focus:ring-primary-100 dark:focus:ring-primary-100 dark:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500" />
64+
<label for="actionModify" class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-100">
65+
{{ 'PRODUCT_ORDERS._action_modify' | translate }}
66+
</label>
67+
</li>
68+
<li class="flex items-center">
69+
<input id="actionDelete" type="checkbox" [checked]="actionFilters.includes('delete')" (change)="onActionFilterChange('delete')"
70+
class="w-4 h-4 bg-gray-100 checked:bg-primary-100 dark:checked:bg-primary-100 border-gray-300 rounded focus:ring-primary-100 dark:focus:ring-primary-100 dark:ring-offset-gray-700 focus:ring-2 dark:bg-gray-600 dark:border-gray-500" />
71+
<label for="actionDelete" class="ml-2 text-sm font-medium text-gray-900 dark:text-gray-100">
72+
{{ 'PRODUCT_ORDERS._action_delete' | translate }}
73+
</label>
74+
</li>
75+
</ul>
76+
</div>
77+
</div>
3378
<div class="p-8 w-full">
3479
<div class="flex flex-row mb-1">
3580
<fa-icon [icon]="faSwatchbook" class="fa-base text-primary-100 align-middle mr-2"></fa-icon>
@@ -38,7 +83,11 @@ <h2 class="text-base dark:text-white font-bold">{{ 'PRODUCT_ORDERS._filter_state
3883
<button id="dropdownStateButton" data-dropdown-toggle="dropdown" (click)="$event.stopPropagation();"
3984
class="text-black border border-primary-100sa dark:text-white w-full justify-between bg-white dark:bg-secondary-200 hover:bg-gray-100 dark:hover:bg-secondary-300 focus:ring-2 focus:outline-none focus:ring-primary-100 font-medium rounded-lg text-sm p-2.5 text-center inline-flex items-center"
4085
type="button">
41-
{{ 'PRODUCT_ORDERS._filter_state' | translate }}
86+
@if(filters.length > 0){
87+
{{filters.join(', ')}}
88+
} @else {
89+
{{ 'PRODUCT_ORDERS._filter_state' | translate }}
90+
}
4291
<svg class="w-4 h-4 ml-2" aria-hidden="true" fill="none" stroke="currentColor" viewBox="0 0 24 24"
4392
xmlns="http://www.w3.org/2000/svg">
4493
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
@@ -354,6 +403,9 @@ <h3 class="text-base dark:text-gray-200">
354403
<th scope="col" class="px-6 py-3 text-center align-middle">
355404
{{ 'PRODUCT_ORDERS._state' | translate }}
356405
</th>
406+
<th scope="col" class="px-6 py-3 text-center align-middle">
407+
{{ 'PRODUCT_ORDERS._items_action' | translate }}
408+
</th>
357409
<th scope="col" class="px-6 py-3 text-center align-middle">
358410
{{ 'PRODUCT_ORDERS._actions' | translate }}
359411
</th>
@@ -410,6 +462,15 @@ <h3 class="text-base dark:text-gray-200">
410462
<span class="bg-amber-500 dark:bg-amber-900 text-amber-900 dark:text-amber-100 text-xs font-medium me-2 px-2.5 py-0.5 rounded border border-amber-950">Unchecked</span>
411463
}
412464
</td>
465+
<td class="px-6 py-4 text-center align-middle">
466+
@if(item.productOrderItem.action === 'add'){
467+
<span class="bg-blue-100 dark:bg-secondary-100 text-blue-600 text-xs font-medium me-2 px-2.5 py-0.5 rounded border border-blue-400 w-fit">{{item.productOrderItem.action}}</span>
468+
} @else if(item.productOrderItem.action === 'delete') {
469+
<span class="bg-blue-100 dark:bg-secondary-100 text-red-500 text-xs font-medium me-2 px-2.5 py-0.5 rounded border border-red-500 w-fit">{{item.productOrderItem.action}}</span>
470+
} @else if(item.productOrderItem.action === 'modify') {
471+
<span class="bg-blue-100 dark:bg-secondary-100 text-yellow-500 text-xs font-medium me-2 px-2.5 py-0.5 rounded border border-yellow-500">{{item.productOrderItem.action}}</span>
472+
}
473+
</td>
413474
<td class="px-6 py-4 text-center align-middle flex justify-center">
414475
@if (!hasProcurementAutomaticTerm(item)) {
415476
@if (!item.productOrderItem.state && role == sellerRole) {

src/app/pages/product-orders/sections/order-info/order-info.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class OrderInfoComponent implements OnInit, AfterViewInit, OnDestroy {
5252
page: number=0;
5353
ORDER_LIMIT: number = environment.ORDER_LIMIT;
5454
filters: any[]=[];
55+
actionFilters: string[] = [];
5556
check_custom:boolean=false;
5657

5758
buyerRole: string = environment.BUYER_ROLE;
@@ -316,7 +317,8 @@ export class OrderInfoComponent implements OnInit, AfterViewInit, OnDestroy {
316317
"filters": this.filters,
317318
"partyId": this.partyId,
318319
"orders": this.orders,
319-
"role": this.role
320+
"role": this.role,
321+
"actionFilters": this.actionFilters
320322
}
321323

322324
this.paginationService.getItemsPaginated(this.page, this.ORDER_LIMIT, next, this.orders,this.nextOrders, options,
@@ -363,6 +365,16 @@ export class OrderInfoComponent implements OnInit, AfterViewInit, OnDestroy {
363365
this.getOrders(false);
364366
}
365367

368+
onActionFilterChange(action:string){
369+
const index = this.actionFilters.findIndex(item => item === action);
370+
if (index !== -1) {
371+
this.actionFilters.splice(index, 1);
372+
} else {
373+
this.actionFilters.push(action)
374+
}
375+
this.getOrders(false);
376+
}
377+
366378
isFilterSelected(filter:any){
367379
const index = this.filters.findIndex(item => item === filter);
368380
if (index !== -1) {

src/app/services/pagination.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export class PaginationService {
6161
if("role" in options){
6262
params.push(options.role)
6363
}
64+
if("actionFilters" in options){
65+
params.push(options.actionFilters)
66+
}
6467

6568
if(next == false){
6669
items=[];
@@ -546,10 +549,10 @@ export class PaginationService {
546549
}
547550
}*/
548551

549-
async getOrders(page: number, filters: Category[], partyId: any, orders: any[], role: any): Promise<any[]> {
552+
async getOrders(page: number, filters: Category[], partyId: any, orders: any[], role: any, actionFilters: string[] = []): Promise<any[]> {
550553
try {
551554
// Get Orders
552-
orders = await this.orderService.getProductOrders(partyId, page, filters, role);
555+
orders = await this.orderService.getProductOrders(partyId, page, filters, role, actionFilters);
553556
console.log('getOrders', orders);
554557
// Obtener todas las cuentas de facturación en paralelo
555558
const billingAccounts = await Promise.all(orders.map(order => this.accountService.getBillingAccountById(order.billingAccount.id)));

src/app/services/product-order-service.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ProductOrderService {
2424
return this.http.post<any>(url, prod, { observe: 'response' });
2525
}
2626

27-
getProductOrders(partyId:any,page:any,filters:any[],role:any){
27+
getProductOrders(partyId:any,page:any,filters:any[],role:any,actionFilters:string[]=[]){
2828
console.log('getProductOrders');
2929
let url = `${ProductOrderService.BASE_URL}${ProductOrderService.API_ORDERING}/productOrder?limit=${ProductOrderService.ORDER_LIMIT}&offset=${page}&relatedParty.id=${partyId}&relatedParty.role=${role}`;
3030

@@ -40,6 +40,9 @@ export class ProductOrderService {
4040
}
4141
url=url+'&state='+status;
4242
}
43+
if(actionFilters.length>0){
44+
url=url+'&productOrderItem.action='+actionFilters.join(',');
45+
}
4346
return lastValueFrom(this.http.get<any[]>(url));
4447
}
4548

src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,11 @@
12601260
"_as_provider": "As Provider",
12611261
"_date": "Date",
12621262
"_actions": "Actions",
1263+
"_items_action": "Items Action",
1264+
"_filter_action": "Filter by action",
1265+
"_action_add": "Add",
1266+
"_action_modify": "Modify",
1267+
"_action_delete": "Delete",
12631268
"_order_details": "Order details:",
12641269
"_customer_info": "Customer Info:",
12651270
"_name": "Name",

src/assets/i18n/es.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,11 @@
12591259
"_as_provider": "As Provider",
12601260
"_date": "Date",
12611261
"_actions": "Actions",
1262+
"_items_action": "Items Action",
1263+
"_filter_action": "Filter by action",
1264+
"_action_add": "Add",
1265+
"_action_modify": "Modify",
1266+
"_action_delete": "Delete",
12621267
"_order_details": "Order details:",
12631268
"_customer_info": "Customer Info:",
12641269
"_name": "Name",

0 commit comments

Comments
 (0)