14 changed files with 227 additions and 52 deletions
@ -0,0 +1,3 @@ |
|||||
|
export * from './order-view-model'; |
||||
|
export * from './proxy'; |
||||
|
export * from './to-order-view-model'; |
||||
@ -0,0 +1,5 @@ |
|||||
|
import { OrderDto } from './proxy/orders'; |
||||
|
|
||||
|
export interface OrderViewModel extends OrderDto { |
||||
|
orderTotal: number; |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
import { OrderDto } from './proxy/orders'; |
||||
|
import { OrderViewModel } from './order-view-model'; |
||||
|
|
||||
|
const mapItem = (x: OrderDto): OrderViewModel => { |
||||
|
const orderTotal = x.items?.reduce((acc, curr) => ( acc + (curr.unitPrice * curr.units)), 0) || 0; |
||||
|
return {...x, orderTotal}; |
||||
|
}; |
||||
|
export const toOrderViewModel = (orders: OrderDto[]) => orders.map(mapItem); |
||||
@ -0,0 +1,21 @@ |
|||||
|
import { Component, Input } from '@angular/core'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'lib-order-detail-item', |
||||
|
template: ` |
||||
|
<div class='row'> |
||||
|
<div class='col-3'> |
||||
|
{{label}} |
||||
|
</div> |
||||
|
<b class='col-9'> |
||||
|
<ng-content></ng-content> |
||||
|
</b> |
||||
|
</div> |
||||
|
`,
|
||||
|
styles: [] |
||||
|
}) |
||||
|
export class OrderDetailItemComponent { |
||||
|
|
||||
|
@Input() |
||||
|
label = ''; |
||||
|
} |
||||
@ -1,22 +1,17 @@ |
|||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; |
import { Component, EventEmitter, Input, Output } from '@angular/core'; |
||||
import { OrderDto } from '../../../lib/proxy/orders'; |
import { OrderViewModel } from '../../../lib/order-view-model'; |
||||
|
import { environment } from '../../../../../../src/environments/environment'; |
||||
|
|
||||
@Component({ |
@Component({ |
||||
selector: 'lib-order-detail', |
selector: 'lib-order-detail', |
||||
templateUrl: './order-detail.component.html' |
templateUrl: './order-detail.component.html' |
||||
}) |
}) |
||||
export class OrderDetailComponent implements OnInit { |
export class OrderDetailComponent { |
||||
|
modalOption = { size: 'xl' } |
||||
@Input() |
@Input() |
||||
visible: boolean; |
visible: boolean; |
||||
@Input() |
@Input() |
||||
order: OrderDto | undefined; |
order: OrderViewModel | undefined; |
||||
|
mediaServerUrl = environment.mediaServerUrl; |
||||
@Output() readonly visibleChange = new EventEmitter<boolean>(); |
@Output() readonly visibleChange = new EventEmitter<boolean>(); |
||||
|
|
||||
constructor() { } |
|
||||
|
|
||||
ngOnInit(): void { |
|
||||
} |
|
||||
|
|
||||
} |
} |
||||
|
|||||
@ -1,20 +1,73 @@ |
|||||
import { Component, OnInit } from '@angular/core'; |
import { Component, OnInit } from '@angular/core'; |
||||
import { OrderDto, OrderService } from '../../lib/proxy/orders'; |
import { OrderService } from '../../lib/proxy/orders'; |
||||
|
import { OrderViewModel, toOrderViewModel } from '../../lib'; |
||||
|
import { Confirmation, ConfirmationService } from '@abp/ng.theme.shared'; |
||||
|
import { ListService } from '@abp/ng.core'; |
||||
|
|
||||
@Component({ |
@Component({ |
||||
selector: 'lib-orders', |
selector: 'lib-orders', |
||||
templateUrl: './orders.component.html', |
templateUrl: './orders.component.html', |
||||
styleUrls: ['./orders.component.css'] |
styleUrls: ['./orders.component.css'], |
||||
|
providers: [ListService], |
||||
}) |
}) |
||||
export class OrdersComponent implements OnInit { |
export class OrdersComponent implements OnInit { |
||||
constructor(private orderService: OrderService) { } |
constructor(private service: OrderService, |
||||
list$ = this.orderService.getOrders({}); |
public list: ListService, |
||||
selectedOrder: OrderDto | undefined; |
private confirmationService: ConfirmationService) { } |
||||
|
selectedOrder: OrderViewModel | undefined; |
||||
isModalVisible = false; |
isModalVisible = false; |
||||
ngOnInit(): void {} |
items: OrderViewModel[]; |
||||
|
count = 0; |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
|
||||
openModal(id: string) { |
const ordersStreamCreator = query => this.service.getListPaged(query); |
||||
|
|
||||
|
this.list.hookToQuery(ordersStreamCreator).subscribe(response => { |
||||
|
this.items = toOrderViewModel(response.items); |
||||
|
this.count = response.totalCount; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
openModal(order: OrderViewModel) { |
||||
|
if (!order){ |
||||
|
return; |
||||
|
} |
||||
|
this.selectedOrder = order; |
||||
this.isModalVisible = true; |
this.isModalVisible = true; |
||||
} |
} |
||||
|
|
||||
|
closeModal(isVisible: boolean){ |
||||
|
if (isVisible){ |
||||
|
return; |
||||
|
} |
||||
|
this.selectedOrder = null; |
||||
|
this.isModalVisible = false; |
||||
|
} |
||||
|
|
||||
|
setAsShipped(row: OrderViewModel) { |
||||
|
this.confirmationService |
||||
|
.warn('AbpOrdering::WillSetAsShipped', { key: '::AreYouSure', defaultValue: 'Are you sure?' }) |
||||
|
.subscribe((status) => { |
||||
|
if (status !== Confirmation.Status.confirm) { |
||||
|
return; |
||||
|
} |
||||
|
this.service.setAsShipped(row.id).subscribe(() => { |
||||
|
this.list.get(); |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
setAsCancelled(row: OrderViewModel){ |
||||
|
this.confirmationService |
||||
|
.warn('AbpOrdering::WillSetAsCancelled', { key: '::AreYouSure', defaultValue: 'Are you sure?' }) |
||||
|
.subscribe((status``) => { |
||||
|
if (status !== Confirmation.Status.confirm) { |
||||
|
return; |
||||
|
} |
||||
|
this.service.setAsCancelled(row.id, { paymentRequestId: undefined, paymentRequestStatus: undefined}).subscribe(() => { |
||||
|
this.list.get(); |
||||
|
}); |
||||
|
}) |
||||
|
; |
||||
|
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,5 @@ |
|||||
|
import { Environment } from '@abp/ng.core'; |
||||
|
|
||||
|
export interface MyEnvironment extends Environment{ |
||||
|
mediaServerUrl?: string; |
||||
|
} |
||||
Loading…
Reference in new issue