Loading src/app/p_product/admin/productOrderManagement/list-product-orders/list-product-orders.component.html +1 −1 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ <ng-container matColumnDef="id"> <ng-container matColumnDef="id"> <th mat-header-cell *matHeaderCellDef mat-sort-header> Order ID</th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Order ID</th> <td mat-cell *matCellDef="let element"> <a routerLink="/services/service_order/{{element.id}}">{{element.id}}</a> <td mat-cell *matCellDef="let element"> <a routerLink="/products/product_order/{{element.id}}">{{element.id}}</a> </td> </td> </ng-container> </ng-container> Loading src/app/p_product/admin/productOrderManagement/preview-product-order/preview-product-order.component.html +56 −61 File changed.Preview size limit exceeded, changes collapsed. Show changes src/app/p_product/admin/productOrderManagement/preview-product-order/preview-product-order.component.ts +101 −100 Original line number Original line Diff line number Diff line import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router'; import { ServiceOrder, ServiceOrderUpdate, ServiceRef, ServiceOrderItem } from 'src/app/openApis/serviceOrderingManagement/models'; import { ProductOrder, ProductOrderUpdate, ServiceRef, ProductOrderItem } from 'src/app/openApis/productOrderingManagement/models'; import { ServiceOrderService } from 'src/app/openApis/serviceOrderingManagement/services'; import { ProductOrderService } from 'src/app/openApis/productOrderingManagement/services'; import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr'; import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { ServiceService } from 'src/app/openApis/serviceInventoryManagement/services'; import { ServiceService } from 'src/app/openApis/serviceInventoryManagement/services'; Loading Loading @@ -34,7 +34,7 @@ export class PreviewProductOrderComponent implements OnInit { constructor( constructor( private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute, private orderService: ServiceOrderService, private orderService: ProductOrderService, private router: Router, private router: Router, private inventoryService: ServiceService, private inventoryService: ServiceService, private toast: ToastrService, private toast: ToastrService, Loading @@ -53,9 +53,9 @@ export class PreviewProductOrderComponent implements OnInit { availablePriorities = ['low', 'normal', 'high'] availablePriorities = ['low', 'normal', 'high'] serviceOrder: ServiceOrder productOrder: ProductOrder orderID: string orderID: string serviceOrderNotFound: boolean = false productOrderNotFound: boolean = false finishedLoading: boolean = false finishedLoading: boolean = false supportingServices: Service[][] = [] supportingServices: Service[][] = [] Loading @@ -72,8 +72,8 @@ export class PreviewProductOrderComponent implements OnInit { note: new UntypedFormControl() note: new UntypedFormControl() }) }) checkboxesOrderItemList: {orderItem: ServiceOrderItem, isChecked: boolean}[] = [] checkboxesOrderItemList: {orderItem: ProductOrderItem, isChecked: boolean}[] = [] selection = new SelectionModel<ServiceOrderItem>(true, []); selection = new SelectionModel<ProductOrderItem>(true, []); subscription = new Subscription subscription = new Subscription Loading @@ -86,7 +86,7 @@ export class PreviewProductOrderComponent implements OnInit { if (this.activatedRoute.snapshot.params.id) if (this.activatedRoute.snapshot.params.id) { { this.orderID = this.activatedRoute.snapshot.params.id this.orderID = this.activatedRoute.snapshot.params.id this.retrieveServiceOrder() this.retrieveProductOrder() } else { } else { this.router.navigate(['../service_orders'], { relativeTo: this.activatedRoute}) this.router.navigate(['../service_orders'], { relativeTo: this.activatedRoute}) } } Loading @@ -96,71 +96,71 @@ export class PreviewProductOrderComponent implements OnInit { this.activeListItem = item this.activeListItem = item if (!this.staticListItems.includes(item)) if (!this.staticListItems.includes(item)) this.serviceOrder.orderItem.find(it => it.id === item).service.serviceCharacteristic this.productOrder.productOrderItem.find(it => it.id === item).product.productCharacteristic } } retrieveServiceOrder() { retrieveProductOrder() { this.selection.clear() this.selection.clear() this.orderService.retrieveServiceOrder({id: this.orderID}).subscribe( this.orderService.retrieveProductOrder({id: this.orderID}).subscribe( data => this.serviceOrder = data, data => this.productOrder = data, error => { console.error(error) }, error => { console.error(error) }, () => { () => { if (this.serviceOrder) { if (this.productOrder) { this.finishedLoading = true this.finishedLoading = true this.editForm.patchValue({ this.editForm.patchValue({ state: this.serviceOrder.state, state: this.productOrder.state, startDate: this.serviceOrder.startDate ? this.serviceOrder.startDate : this.serviceOrder.requestedStartDate, startDate: this.productOrder.requestedStartDate ? this.productOrder.requestedStartDate : this.productOrder.requestedStartDate, expectedCompletionDate: this.serviceOrder.expectedCompletionDate ? this.serviceOrder.expectedCompletionDate : this.serviceOrder.completionDate expectedCompletionDate: this.productOrder.expectedCompletionDate ? this.productOrder.expectedCompletionDate : this.productOrder.completionDate }) }) this.serviceOrder.note.sort(this.sortingService.ascDateSortingFuncByDateProperty()) this.productOrder.note.sort(this.sortingService.ascDateSortingFuncByDateProperty()) if (!this.serviceOrder.startDate) { this.serviceOrder.startDate = this.serviceOrder.requestedStartDate } if (!this.productOrder.requestedStartDate) { this.productOrder.requestedStartDate = this.productOrder.requestedStartDate } if (!this.serviceOrder.expectedCompletionDate) { this.serviceOrder.expectedCompletionDate = this.serviceOrder.requestedCompletionDate } if (!this.productOrder.expectedCompletionDate) { this.productOrder.expectedCompletionDate = this.productOrder.requestedCompletionDate } this.checkboxesOrderItemList = [] this.checkboxesOrderItemList = [] this.currentItemRelationshipsUrl = [] this.currentItemRelationshipsUrl = [] this.supportingServices = [] this.supportingServices = [] this.serviceOrder.orderItem.forEach((orderItem) => { this.productOrder.productOrderItem.forEach((orderItem) => { //Expands the length of the array for each Service Order Item //Expands the length of the array for each Service Order Item this.supportingServices.push([]) this.supportingServices.push([]) this.checkboxesOrderItemList.push({orderItem: orderItem, isChecked: false}) this.checkboxesOrderItemList.push({orderItem: orderItem, isChecked: false}) orderItem.service.serviceCharacteristic.sort(this.sortingService.ascStringSortingFunctionByNameProperty()) orderItem.product.productCharacteristic.sort(this.sortingService.ascStringSortingFunctionByNameProperty()) orderItem.service.supportingService.forEach( (supService) => { // orderItem.product.realizingService.forEach( (supService) => { this.retrieveServiceInventory(supService.id).subscribe( // this.retrieveProductInventory(supService.id).subscribe( data => { // data => { const orderItemIndex = this.serviceOrder.orderItem.findIndex(SOI => orderItem.id === SOI.id) // const orderItemIndex = this.productOrder.productOrderItem.findIndex(SOI => orderItem.id === SOI.id) const supportingServiceIndex = this.serviceOrder.orderItem[orderItemIndex].service.supportingService.findIndex(SupS => supService.id === SupS.id) // const supportingServiceIndex = this.productOrder.productOrderItem[orderItemIndex].product.realizingService.findIndex(SupS => supService.id === SupS.id) this.supportingServices[orderItemIndex][supportingServiceIndex] = data // this.supportingServices[orderItemIndex][supportingServiceIndex] = data } // } ) // ) }) // }) this.currentItemRelationshipsUrl.push( this.orderService.rootUrl + "/serviceOrdering/v4/serviceOrder/" + this.serviceOrder.id + "/item/" + orderItem.id + "/relationship_graph" ); // this.currentItemRelationshipsUrl.push( this.orderService.rootUrl + "/productOrderingManagement/v4/productOrder/" + this.productOrder.id + "/item/" + orderItem.id + "/relationship_graph" ); }) }) this.notesGraphUrl = this.orderService.rootUrl + "/serviceOrdering/v4/serviceOrder/" + this.serviceOrder.id + "/notes_graph"; // this.notesGraphUrl = this.orderService.rootUrl + "/productOrderingManagement/v4/productOrder/" + this.productOrder.id + "/notes_graph"; if (this.activatedRoute.snapshot.queryParams && this.serviceOrder.orderItem.some(item => item.id === this.activatedRoute.snapshot.queryParams.item)) { if (this.activatedRoute.snapshot.queryParams && this.productOrder.productOrderItem.some(item => item.id === this.activatedRoute.snapshot.queryParams.item)) { // console.log(this.activatedRoute.snapshot.queryParams) // console.log(this.activatedRoute.snapshot.queryParams) this.activeListItem = this.activatedRoute.snapshot.queryParams.item this.activeListItem = this.activatedRoute.snapshot.queryParams.item } } } else { } else { this.serviceOrderNotFound = true this.productOrderNotFound = true } } } } ) ) } } retrieveServiceInventory(serviceId:string) { retrieveProductInventory(serviceId:string) { return this.inventoryService.retrieveService({id:serviceId}) return this.inventoryService.retrieveService({id:serviceId}) } } Loading Loading @@ -208,10 +208,11 @@ export class PreviewProductOrderComponent implements OnInit { submitOrderEditing() { submitOrderEditing() { this.editMode = false this.editMode = false let orderUpdate: ServiceOrderUpdate = { let orderUpdate: ProductOrderUpdate = { state: this.editForm.get('state').value, state: this.editForm.get('state').value, startDate: this.editForm.get('startDate').value, requestedStartDate: this.editForm.get('startDate').value, expectedCompletionDate: this.editForm.get('expectedCompletionDate').value, expectedCompletionDate: this.editForm.get('expectedCompletionDate').value, productOrderItem: [] } } if (this.editForm.get('note').value) { if (this.editForm.get('note').value) { orderUpdate.note = [{ orderUpdate.note = [{ Loading @@ -221,13 +222,13 @@ export class PreviewProductOrderComponent implements OnInit { }] }] } } this.orderService.patchServiceOrder({serviceOrder: orderUpdate, id: this.orderID}).subscribe( // this.orderService.patchProductOrder({productOrder: orderUpdate, id: this.orderID}).subscribe( data => {this.toast.success("Service Order was successfully updated")}, // data => {this.toast.success("Service Order was successfully updated")}, error => {console.error(error); this.toast.error("An error occurred while editing Service Order")}, // error => {console.error(error); this.toast.error("An error occurred while editing Service Order")}, () => { // () => { this.enableOrderRefreshTimer() // this.enableOrderRefreshTimer() } // } ) // ) } } cancelOrderEditing() { cancelOrderEditing() { Loading @@ -238,7 +239,7 @@ export class PreviewProductOrderComponent implements OnInit { this.editModeNotes = !this.editModeNotes this.editModeNotes = !this.editModeNotes } } // openOrdersSpecCharacteristicsDialog(orderItem: ServiceOrderItem) { // openOrdersSpecCharacteristicsDialog(orderItem: ProductOrderItem) { // const dialogRef = this.dialog.open(EditOrdersServiceSpecCharacteristicsComponent, { // const dialogRef = this.dialog.open(EditOrdersServiceSpecCharacteristicsComponent, { // data: { orderItem } // data: { orderItem } Loading @@ -251,18 +252,18 @@ export class PreviewProductOrderComponent implements OnInit { // // if (result) { // // if (result) { // // orderItem.service.serviceCharacteristic = result // // orderItem.service.serviceCharacteristic = result // // } // // } // console.log(this.serviceOrder) // console.log(this.productOrder) // if (result) { // if (result) { // let newOrderUpdate: ServiceOrderUpdate = { // let newOrderUpdate: ProductOrderUpdate = { // orderItem: [] // orderItem: [] // } // } // this.serviceOrder.orderItem.find(item => item.id === orderItem.id).service.serviceCharacteristic = result // this.productOrder.orderItem.find(item => item.id === orderItem.id).service.serviceCharacteristic = result // newOrderUpdate.orderItem = this.serviceOrder.orderItem // newOrderUpdate.orderItem = this.productOrder.orderItem // this.orderService.patchServiceOrder({serviceOrder: newOrderUpdate, id: this.serviceOrder.id}).subscribe( // this.orderService.patchProductOrder({productOrder: newOrderUpdate, id: this.productOrder.id}).subscribe( // data => { this.retrieveServiceOrder() }, // data => { this.retrieveProductOrder() }, // error => console.error(error) // error => console.error(error) // ) // ) // } // } Loading @@ -272,15 +273,15 @@ export class PreviewProductOrderComponent implements OnInit { areOrderItemsEditable() { areOrderItemsEditable() { // states > 'INITIAL'|'ACKNOWLEDGED'|'REJECTED'|'PENDING'|'HELD'|'INPROGRESS'|'CANCELLED'|'COMPLETED'|'FAILED'|'PARTIAL' // states > 'INITIAL'|'ACKNOWLEDGED'|'REJECTED'|'PENDING'|'HELD'|'INPROGRESS'|'CANCELLED'|'COMPLETED'|'FAILED'|'PARTIAL' // return ['INITIAL', 'REJECTED','CANCELLED', 'COMPLETED', 'FAILED', 'PARTIAL'].includes(this.serviceOrder.state) // return ['INITIAL', 'REJECTED','CANCELLED', 'COMPLETED', 'FAILED', 'PARTIAL'].includes(this.productOrder.state) return ['INITIAL'].includes(this.serviceOrder.state) return ['INITIAL'].includes(this.productOrder.state) } } areOrderItemsTerminable() { areOrderItemsTerminable() { return ['COMPLETED', 'FAILED', 'PARTIAL'].includes(this.serviceOrder.state) return ['COMPLETED', 'FAILED', 'PARTIAL'].includes(this.productOrder.state) } } openEditServiceOrderItemsDialog() { openEditProductOrderItemsDialog() { const dialogRef = this.dialog.open(EditProductOrderItemsComponent, { const dialogRef = this.dialog.open(EditProductOrderItemsComponent, { data: this.selection.selected, data: this.selection.selected, minWidth: "60vw" minWidth: "60vw" Loading @@ -292,41 +293,41 @@ export class PreviewProductOrderComponent implements OnInit { // console.log(editedOrderItems) // console.log(editedOrderItems) if (editedOrderItems) { if (editedOrderItems) { let newOrderUpdate: ServiceOrderUpdate = { let newOrderUpdate: ProductOrderUpdate = { orderItem: [] productOrderItem: [] } editedOrderItems.forEach( editedOrderItem => { this.serviceOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID).service.serviceCharacteristic = editedOrderItem.serviceSpecChars // Decide orderItem action verb if (this.serviceOrder.state === "COMPLETED") { this.serviceOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID).action = "modify" } } // editedOrderItems.forEach( editedOrderItem => { // this.productOrder.productOrderItem.find(item => item.id === editedOrderItem.orderItemID).product.productCharacteristic = editedOrderItem.serviceSpecChars // // Decide orderItem action verb // if (this.productOrder.state === "COMPLETED") { // this.productOrder.productOrderItem.find(item => item.id === editedOrderItem.orderItemID).action = "modify" // } // newOrderUpdate.orderItem.push(this.serviceOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID)) // // newOrderUpdate.orderItem.push(this.productOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID)) }) // }) newOrderUpdate.orderItem = this.serviceOrder.orderItem newOrderUpdate.productOrderItem = this.productOrder.productOrderItem // console.log(newOrderUpdate) // console.log(newOrderUpdate) this.orderService.patchServiceOrder({serviceOrder: newOrderUpdate, id: this.serviceOrder.id}).subscribe( // this.orderService.patchProductOrder({productOrder: newOrderUpdate, id: this.productOrder.id}).subscribe( data => { // data => { this.toast.success("Selected Order Items were successfully updated") // this.toast.success("Selected Order Items were successfully updated") this.retrieveServiceOrder() // this.retrieveProductOrder() }, // }, error => { // error => { this.toast.error("An error occurred while updating Service Order Items") // this.toast.error("An error occurred while updating Service Order Items") this.retrieveServiceOrder() // this.retrieveProductOrder() console.error(error) // console.error(error) } // } ) // ) } } } } ) ) } } terminateServiceOrderItemsDialog() { terminateProductOrderItemsDialog() { const dialogRef = this.dialog.open(TerminateProductOrderItemsComponent, { const dialogRef = this.dialog.open(TerminateProductOrderItemsComponent, { data: this.selection.selected data: this.selection.selected }) }) Loading @@ -334,29 +335,29 @@ export class PreviewProductOrderComponent implements OnInit { dialogRef.afterClosed().subscribe( dialogRef.afterClosed().subscribe( result => { result => { if (result) { if (result) { let newOrderUpdate: ServiceOrderUpdate = { let newOrderUpdate: ProductOrderUpdate = { orderItem: [] productOrderItem: [] } } this.selection.selected.forEach( selectedOrderItem => { // this.selection.selected.forEach( selectedOrderItem => { this.serviceOrder.orderItem.find(item => item.id === selectedOrderItem.id).action = "modify" // this.productOrder.productOrderItem.find(item => item.id === selectedOrderItem.id).action = "modify" this.serviceOrder.orderItem.find(item => item.id === selectedOrderItem.id).service.state = "terminated" // this.productOrder.productOrderItem.find(item => item.id === selectedOrderItem.id).product.state = "terminated" }) // }) newOrderUpdate.orderItem = this.serviceOrder.orderItem newOrderUpdate.productOrderItem = this.productOrder.productOrderItem // console.log(newOrderUpdate) // console.log(newOrderUpdate) this.orderService.patchServiceOrder({serviceOrder: newOrderUpdate, id: this.serviceOrder.id}).subscribe( // this.orderService.patchProductOrder({productOrder: newOrderUpdate, id: this.productOrder.id}).subscribe( data => { // data => { this.toast.success("Selected Order Items were successfully updated") // this.toast.success("Selected Order Items were successfully updated") this.retrieveServiceOrder() // this.retrieveProductOrder() }, // }, error => { // error => { this.toast.error("An error occurred while updating Service Order Items") // this.toast.error("An error occurred while updating Service Order Items") this.retrieveServiceOrder() // this.retrieveProductOrder() console.error(error) // console.error(error) } // } ) // ) } } } } ) ) Loading @@ -365,14 +366,14 @@ export class PreviewProductOrderComponent implements OnInit { //checkBoxSelection Logic //checkBoxSelection Logic isAllSelected() { isAllSelected() { const numSelected = this.selection.selected.length const numSelected = this.selection.selected.length const numItems = this.serviceOrder.orderItem.length const numItems = this.productOrder.productOrderItem.length return numSelected === numItems return numSelected === numItems } } masterCheckboxToggle() { masterCheckboxToggle() { this.isAllSelected() ? this.isAllSelected() ? this.selection.clear() : this.selection.clear() : this.serviceOrder.orderItem.forEach (item => this.selection.select(item)) this.productOrder.productOrderItem.forEach (item => this.selection.select(item)) } } //---checkBoxSelection Logic //---checkBoxSelection Logic Loading @@ -381,7 +382,7 @@ export class PreviewProductOrderComponent implements OnInit { this.subscription = timer(0, 10000).subscribe( this.subscription = timer(0, 10000).subscribe( data => { data => { // this.supportingServices = [[]] // this.supportingServices = [[]] this.retrieveServiceOrder() this.retrieveProductOrder() } } ) ) } } Loading src/app/p_product/orderCheckout/product-order-checkout/product-order-checkout.component.ts +93 −75 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ const today = new Date(); templateUrl: './product-order-checkout.component.html', templateUrl: './product-order-checkout.component.html', styleUrls: ['./product-order-checkout.component.scss'] styleUrls: ['./product-order-checkout.component.scss'] }) }) export class ProductOrderCheckoutComponent implements OnInit { export class ProductOrderCheckoutComponent implements OnInit { constructor( constructor( Loading Loading @@ -51,8 +50,6 @@ export class ProductOrderCheckoutComponent implements OnInit { this.populateOrderedSpecsConfigurationList() this.populateOrderedSpecsConfigurationList() } } freshLoadOrderListChanges() { freshLoadOrderListChanges() { let storageOrderArray = [] let storageOrderArray = [] storageOrderArray = JSON.parse(localStorage.getItem('orderedProductSpecsList')) || [] storageOrderArray = JSON.parse(localStorage.getItem('orderedProductSpecsList')) || [] Loading Loading @@ -82,7 +79,6 @@ export class ProductOrderCheckoutComponent implements OnInit { } } } } initCharacteristicsValue(orderedSpec: ProductOffering): { name: string; valueType: string; value: import("src/app/openApis/productCatalogManagement/models").ProductSpecificationCharacteristicValue[]; }[] { initCharacteristicsValue(orderedSpec: ProductOffering): { name: string; valueType: string; value: import("src/app/openApis/productCatalogManagement/models").ProductSpecificationCharacteristicValue[]; }[] { let initialCharValues: { let initialCharValues: { name: string, name: string, Loading @@ -106,16 +102,12 @@ export class ProductOrderCheckoutComponent implements OnInit { }) }) }) }) return initialCharValues return initialCharValues } } initValuesForm() { initValuesForm() { // console.log(this.requesterService.serviceConfigurationList) this.specCharFormArray = new UntypedFormArray([]) this.specCharFormArray = new UntypedFormArray([]) const formArray = this.specCharFormArray as UntypedFormArray const formArray = this.specCharFormArray as UntypedFormArray this.configurableSpecChar = this.selectedOrderSpecToView.offering.prodSpecCharValueUse; this.configurableSpecChar = this.selectedOrderSpecToView.offering.prodSpecCharValueUse; //Sort Configurable Characteristics by Asc Name Order //Sort Configurable Characteristics by Asc Name Order Loading @@ -124,7 +116,6 @@ export class ProductOrderCheckoutComponent implements OnInit { this.configurableSpecChar.forEach((confSpecChar) => { this.configurableSpecChar.forEach((confSpecChar) => { formArray.push(this.updateFormArrayItem(confSpecChar)) formArray.push(this.updateFormArrayItem(confSpecChar)) }) }) } } updateFormArrayItem(specChar: ProductSpecificationCharacteristicRes): UntypedFormGroup { updateFormArrayItem(specChar: ProductSpecificationCharacteristicRes): UntypedFormGroup { Loading Loading @@ -152,9 +143,7 @@ export class ProductOrderCheckoutComponent implements OnInit { } } viewAndConfigureSpec(item: productSpecConfigurationListItem) { viewAndConfigureSpec(item: productSpecConfigurationListItem) { this.updateActiveProductInList() this.updateActiveProductInList() this.selectedOrderSpecToView = item this.selectedOrderSpecToView = item this.initValuesForm() this.initValuesForm() } } Loading @@ -180,7 +169,6 @@ export class ProductOrderCheckoutComponent implements OnInit { if (orderArray.length) { if (orderArray.length) { orderArray.splice(orderArray.findIndex(el => el === specId), 1) orderArray.splice(orderArray.findIndex(el => el === specId), 1) } } localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) } } Loading @@ -188,71 +176,102 @@ export class ProductOrderCheckoutComponent implements OnInit { this.updateActiveProductInList(); this.updateActiveProductInList(); let newOrder: ProductOrderCreate = { const startDate = this.reqStartDate.value ? new Date(this.reqStartDate.value).toISOString() : new Date().toISOString(); const completionDate = this.reqCompletionDate.value ? new Date(this.reqCompletionDate.value).toISOString() : new Date().toISOString(); let newOrder: ProductOrderCreate | any = { "@type": "ProductOrder", category: "Product Order", description: "Product Order via Portal", requestedStartDate: startDate, requestedCompletionDate: completionDate, productOrderItem: [], productOrderItem: [], requestedStartDate: this.reqStartDate.value, relatedParty: [] requestedCompletionDate: this.reqCompletionDate.value }; }; if (this.serviceNoteCtrl.value) { if (this.authService.portalUserJWT) { newOrder.note = [{ newOrder.relatedParty.push({ author: this.authService.portalUserJWT.preferred_username, "@type": "RelatedParty", text: this.serviceNoteCtrl.value, role: 'REQUESTER', date: new Date().toISOString() name: this.authService.portalUserJWT.preferred_username || 'Unknown', }]; }); } } this.orderedSpecsConfigurationList.forEach((productItem, index) => { this.orderedSpecsConfigurationList.forEach((productItem, index) => { if (!productItem.offering || !productItem.offering.id) { if (!productItem.offering?.id) return; this.toastr.error('Not a valid product offering', 'Configuration Error'); return; } const pChars = []; const pChars = []; productItem.specCharacteristics.forEach((characteristic) => { productItem.specCharacteristics.forEach((characteristic) => { let valToSubmit = null; if (['SET', 'ARRAY'].includes(characteristic.valueType?.toUpperCase())) { //filter empty values valToSubmit = { const validItems = characteristic.value.filter(el => el.value && el.value.value && String(el.value.value).trim() !== ''); value: JSON.stringify(characteristic.value.map(el => ({ 'value': el.value.value, 'alias': el.value.alias }))) }; validItems.forEach(item => { } else { let charType = 'StringCharacteristic'; valToSubmit = characteristic.value[0]?.value; let rawValue: any = item.value.value; if (characteristic.valueType === 'INTEGER') { charType = 'IntegerCharacteristic'; rawValue = parseInt(rawValue); } else if (characteristic.valueType === 'FLOAT') { charType = 'FloatCharacteristic'; rawValue = parseFloat(rawValue); } else if (characteristic.valueType === 'BOOLEAN') { charType = 'BooleanCharacteristic'; rawValue = (String(rawValue).toLowerCase() === 'true'); } } if(valToSubmit) { pChars.push({ pChars.push({ name: characteristic.name, name: characteristic.name, valueType: characteristic.valueType, valueType: characteristic.valueType, value: valToSubmit "@type": charType, }); value: { value: rawValue, alias: item.value.alias || '' } } }); }); }); }); const newOrderItem: ProductOrderItem = { const newOrderItem: ProductOrderItem = { id: (index + 1).toString(), id: (index + 1).toString(), action: 'ADD', action: 'ADD', product: { quantity: 1, "@type": "ProductOrderItem", productOffering: { productOffering: { id: productItem.offering.id, id: productItem.offering.id, name: productItem.offering.name, name: productItem.offering.name, '@type': 'ProductOfferingRef' }, }, productCharacteristic: pChars product: { "@type": "Product", productCharacteristic: pChars, productSpecification: productItem.offering.productSpecification ? { id: productItem.offering.productSpecification.id, name: productItem.offering.name, version: productItem.offering.version, '@type': 'ProductSpecificationRef' } : undefined } as any } as any }; }; newOrder.productOrderItem.push(newOrderItem); newOrder.productOrderItem.push(newOrderItem); }); }); // console.log('Submitting Product Order:', newOrder); this.orderService.createProductOrder({ body: newOrder }).subscribe({ this.orderService.createProductOrder({ body: newOrder }).subscribe({ next: (createdOrder: any) => { next: (createdOrder: any) => { this.toastr.success("Product Order was successfully placed"); this.toastr.success("Order Placed Successfully"); this.orderedSpecsConfigurationList = []; this.orderedSpecsConfigurationList = []; this.productRequesterService.orderedProductSpecsList = []; this.productRequesterService.orderedProductSpecsList = []; localStorage.removeItem('orderedProductSpecsList'); localStorage.removeItem('orderedProductSpecsList'); if (createdOrder?.id) { if (createdOrder?.id) { this.router.navigate(["products", 'product_order', createdOrder.id]); this.router.navigate(["products", 'product_order', createdOrder.id]); } else { } else { Loading @@ -260,8 +279,8 @@ export class ProductOrderCheckoutComponent implements OnInit { } } }, }, error: (error) => { error: (error) => { console.error(error); console.error("Submission Error:", error); this.toastr.error("An error occurred while processing your Service Order"); this.toastr.error("Validation Failed (400).", "Order Failed"); } } }); }); } } Loading @@ -274,5 +293,4 @@ export class ProductOrderCheckoutComponent implements OnInit { this.subscription.unsubscribe() this.subscription.unsubscribe() } } } } No newline at end of file Loading
src/app/p_product/admin/productOrderManagement/list-product-orders/list-product-orders.component.html +1 −1 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,7 @@ <ng-container matColumnDef="id"> <ng-container matColumnDef="id"> <th mat-header-cell *matHeaderCellDef mat-sort-header> Order ID</th> <th mat-header-cell *matHeaderCellDef mat-sort-header> Order ID</th> <td mat-cell *matCellDef="let element"> <a routerLink="/services/service_order/{{element.id}}">{{element.id}}</a> <td mat-cell *matCellDef="let element"> <a routerLink="/products/product_order/{{element.id}}">{{element.id}}</a> </td> </td> </ng-container> </ng-container> Loading
src/app/p_product/admin/productOrderManagement/preview-product-order/preview-product-order.component.html +56 −61 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/app/p_product/admin/productOrderManagement/preview-product-order/preview-product-order.component.ts +101 −100 Original line number Original line Diff line number Diff line import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router'; import { ServiceOrder, ServiceOrderUpdate, ServiceRef, ServiceOrderItem } from 'src/app/openApis/serviceOrderingManagement/models'; import { ProductOrder, ProductOrderUpdate, ServiceRef, ProductOrderItem } from 'src/app/openApis/productOrderingManagement/models'; import { ServiceOrderService } from 'src/app/openApis/serviceOrderingManagement/services'; import { ProductOrderService } from 'src/app/openApis/productOrderingManagement/services'; import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr'; import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { ServiceService } from 'src/app/openApis/serviceInventoryManagement/services'; import { ServiceService } from 'src/app/openApis/serviceInventoryManagement/services'; Loading Loading @@ -34,7 +34,7 @@ export class PreviewProductOrderComponent implements OnInit { constructor( constructor( private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute, private orderService: ServiceOrderService, private orderService: ProductOrderService, private router: Router, private router: Router, private inventoryService: ServiceService, private inventoryService: ServiceService, private toast: ToastrService, private toast: ToastrService, Loading @@ -53,9 +53,9 @@ export class PreviewProductOrderComponent implements OnInit { availablePriorities = ['low', 'normal', 'high'] availablePriorities = ['low', 'normal', 'high'] serviceOrder: ServiceOrder productOrder: ProductOrder orderID: string orderID: string serviceOrderNotFound: boolean = false productOrderNotFound: boolean = false finishedLoading: boolean = false finishedLoading: boolean = false supportingServices: Service[][] = [] supportingServices: Service[][] = [] Loading @@ -72,8 +72,8 @@ export class PreviewProductOrderComponent implements OnInit { note: new UntypedFormControl() note: new UntypedFormControl() }) }) checkboxesOrderItemList: {orderItem: ServiceOrderItem, isChecked: boolean}[] = [] checkboxesOrderItemList: {orderItem: ProductOrderItem, isChecked: boolean}[] = [] selection = new SelectionModel<ServiceOrderItem>(true, []); selection = new SelectionModel<ProductOrderItem>(true, []); subscription = new Subscription subscription = new Subscription Loading @@ -86,7 +86,7 @@ export class PreviewProductOrderComponent implements OnInit { if (this.activatedRoute.snapshot.params.id) if (this.activatedRoute.snapshot.params.id) { { this.orderID = this.activatedRoute.snapshot.params.id this.orderID = this.activatedRoute.snapshot.params.id this.retrieveServiceOrder() this.retrieveProductOrder() } else { } else { this.router.navigate(['../service_orders'], { relativeTo: this.activatedRoute}) this.router.navigate(['../service_orders'], { relativeTo: this.activatedRoute}) } } Loading @@ -96,71 +96,71 @@ export class PreviewProductOrderComponent implements OnInit { this.activeListItem = item this.activeListItem = item if (!this.staticListItems.includes(item)) if (!this.staticListItems.includes(item)) this.serviceOrder.orderItem.find(it => it.id === item).service.serviceCharacteristic this.productOrder.productOrderItem.find(it => it.id === item).product.productCharacteristic } } retrieveServiceOrder() { retrieveProductOrder() { this.selection.clear() this.selection.clear() this.orderService.retrieveServiceOrder({id: this.orderID}).subscribe( this.orderService.retrieveProductOrder({id: this.orderID}).subscribe( data => this.serviceOrder = data, data => this.productOrder = data, error => { console.error(error) }, error => { console.error(error) }, () => { () => { if (this.serviceOrder) { if (this.productOrder) { this.finishedLoading = true this.finishedLoading = true this.editForm.patchValue({ this.editForm.patchValue({ state: this.serviceOrder.state, state: this.productOrder.state, startDate: this.serviceOrder.startDate ? this.serviceOrder.startDate : this.serviceOrder.requestedStartDate, startDate: this.productOrder.requestedStartDate ? this.productOrder.requestedStartDate : this.productOrder.requestedStartDate, expectedCompletionDate: this.serviceOrder.expectedCompletionDate ? this.serviceOrder.expectedCompletionDate : this.serviceOrder.completionDate expectedCompletionDate: this.productOrder.expectedCompletionDate ? this.productOrder.expectedCompletionDate : this.productOrder.completionDate }) }) this.serviceOrder.note.sort(this.sortingService.ascDateSortingFuncByDateProperty()) this.productOrder.note.sort(this.sortingService.ascDateSortingFuncByDateProperty()) if (!this.serviceOrder.startDate) { this.serviceOrder.startDate = this.serviceOrder.requestedStartDate } if (!this.productOrder.requestedStartDate) { this.productOrder.requestedStartDate = this.productOrder.requestedStartDate } if (!this.serviceOrder.expectedCompletionDate) { this.serviceOrder.expectedCompletionDate = this.serviceOrder.requestedCompletionDate } if (!this.productOrder.expectedCompletionDate) { this.productOrder.expectedCompletionDate = this.productOrder.requestedCompletionDate } this.checkboxesOrderItemList = [] this.checkboxesOrderItemList = [] this.currentItemRelationshipsUrl = [] this.currentItemRelationshipsUrl = [] this.supportingServices = [] this.supportingServices = [] this.serviceOrder.orderItem.forEach((orderItem) => { this.productOrder.productOrderItem.forEach((orderItem) => { //Expands the length of the array for each Service Order Item //Expands the length of the array for each Service Order Item this.supportingServices.push([]) this.supportingServices.push([]) this.checkboxesOrderItemList.push({orderItem: orderItem, isChecked: false}) this.checkboxesOrderItemList.push({orderItem: orderItem, isChecked: false}) orderItem.service.serviceCharacteristic.sort(this.sortingService.ascStringSortingFunctionByNameProperty()) orderItem.product.productCharacteristic.sort(this.sortingService.ascStringSortingFunctionByNameProperty()) orderItem.service.supportingService.forEach( (supService) => { // orderItem.product.realizingService.forEach( (supService) => { this.retrieveServiceInventory(supService.id).subscribe( // this.retrieveProductInventory(supService.id).subscribe( data => { // data => { const orderItemIndex = this.serviceOrder.orderItem.findIndex(SOI => orderItem.id === SOI.id) // const orderItemIndex = this.productOrder.productOrderItem.findIndex(SOI => orderItem.id === SOI.id) const supportingServiceIndex = this.serviceOrder.orderItem[orderItemIndex].service.supportingService.findIndex(SupS => supService.id === SupS.id) // const supportingServiceIndex = this.productOrder.productOrderItem[orderItemIndex].product.realizingService.findIndex(SupS => supService.id === SupS.id) this.supportingServices[orderItemIndex][supportingServiceIndex] = data // this.supportingServices[orderItemIndex][supportingServiceIndex] = data } // } ) // ) }) // }) this.currentItemRelationshipsUrl.push( this.orderService.rootUrl + "/serviceOrdering/v4/serviceOrder/" + this.serviceOrder.id + "/item/" + orderItem.id + "/relationship_graph" ); // this.currentItemRelationshipsUrl.push( this.orderService.rootUrl + "/productOrderingManagement/v4/productOrder/" + this.productOrder.id + "/item/" + orderItem.id + "/relationship_graph" ); }) }) this.notesGraphUrl = this.orderService.rootUrl + "/serviceOrdering/v4/serviceOrder/" + this.serviceOrder.id + "/notes_graph"; // this.notesGraphUrl = this.orderService.rootUrl + "/productOrderingManagement/v4/productOrder/" + this.productOrder.id + "/notes_graph"; if (this.activatedRoute.snapshot.queryParams && this.serviceOrder.orderItem.some(item => item.id === this.activatedRoute.snapshot.queryParams.item)) { if (this.activatedRoute.snapshot.queryParams && this.productOrder.productOrderItem.some(item => item.id === this.activatedRoute.snapshot.queryParams.item)) { // console.log(this.activatedRoute.snapshot.queryParams) // console.log(this.activatedRoute.snapshot.queryParams) this.activeListItem = this.activatedRoute.snapshot.queryParams.item this.activeListItem = this.activatedRoute.snapshot.queryParams.item } } } else { } else { this.serviceOrderNotFound = true this.productOrderNotFound = true } } } } ) ) } } retrieveServiceInventory(serviceId:string) { retrieveProductInventory(serviceId:string) { return this.inventoryService.retrieveService({id:serviceId}) return this.inventoryService.retrieveService({id:serviceId}) } } Loading Loading @@ -208,10 +208,11 @@ export class PreviewProductOrderComponent implements OnInit { submitOrderEditing() { submitOrderEditing() { this.editMode = false this.editMode = false let orderUpdate: ServiceOrderUpdate = { let orderUpdate: ProductOrderUpdate = { state: this.editForm.get('state').value, state: this.editForm.get('state').value, startDate: this.editForm.get('startDate').value, requestedStartDate: this.editForm.get('startDate').value, expectedCompletionDate: this.editForm.get('expectedCompletionDate').value, expectedCompletionDate: this.editForm.get('expectedCompletionDate').value, productOrderItem: [] } } if (this.editForm.get('note').value) { if (this.editForm.get('note').value) { orderUpdate.note = [{ orderUpdate.note = [{ Loading @@ -221,13 +222,13 @@ export class PreviewProductOrderComponent implements OnInit { }] }] } } this.orderService.patchServiceOrder({serviceOrder: orderUpdate, id: this.orderID}).subscribe( // this.orderService.patchProductOrder({productOrder: orderUpdate, id: this.orderID}).subscribe( data => {this.toast.success("Service Order was successfully updated")}, // data => {this.toast.success("Service Order was successfully updated")}, error => {console.error(error); this.toast.error("An error occurred while editing Service Order")}, // error => {console.error(error); this.toast.error("An error occurred while editing Service Order")}, () => { // () => { this.enableOrderRefreshTimer() // this.enableOrderRefreshTimer() } // } ) // ) } } cancelOrderEditing() { cancelOrderEditing() { Loading @@ -238,7 +239,7 @@ export class PreviewProductOrderComponent implements OnInit { this.editModeNotes = !this.editModeNotes this.editModeNotes = !this.editModeNotes } } // openOrdersSpecCharacteristicsDialog(orderItem: ServiceOrderItem) { // openOrdersSpecCharacteristicsDialog(orderItem: ProductOrderItem) { // const dialogRef = this.dialog.open(EditOrdersServiceSpecCharacteristicsComponent, { // const dialogRef = this.dialog.open(EditOrdersServiceSpecCharacteristicsComponent, { // data: { orderItem } // data: { orderItem } Loading @@ -251,18 +252,18 @@ export class PreviewProductOrderComponent implements OnInit { // // if (result) { // // if (result) { // // orderItem.service.serviceCharacteristic = result // // orderItem.service.serviceCharacteristic = result // // } // // } // console.log(this.serviceOrder) // console.log(this.productOrder) // if (result) { // if (result) { // let newOrderUpdate: ServiceOrderUpdate = { // let newOrderUpdate: ProductOrderUpdate = { // orderItem: [] // orderItem: [] // } // } // this.serviceOrder.orderItem.find(item => item.id === orderItem.id).service.serviceCharacteristic = result // this.productOrder.orderItem.find(item => item.id === orderItem.id).service.serviceCharacteristic = result // newOrderUpdate.orderItem = this.serviceOrder.orderItem // newOrderUpdate.orderItem = this.productOrder.orderItem // this.orderService.patchServiceOrder({serviceOrder: newOrderUpdate, id: this.serviceOrder.id}).subscribe( // this.orderService.patchProductOrder({productOrder: newOrderUpdate, id: this.productOrder.id}).subscribe( // data => { this.retrieveServiceOrder() }, // data => { this.retrieveProductOrder() }, // error => console.error(error) // error => console.error(error) // ) // ) // } // } Loading @@ -272,15 +273,15 @@ export class PreviewProductOrderComponent implements OnInit { areOrderItemsEditable() { areOrderItemsEditable() { // states > 'INITIAL'|'ACKNOWLEDGED'|'REJECTED'|'PENDING'|'HELD'|'INPROGRESS'|'CANCELLED'|'COMPLETED'|'FAILED'|'PARTIAL' // states > 'INITIAL'|'ACKNOWLEDGED'|'REJECTED'|'PENDING'|'HELD'|'INPROGRESS'|'CANCELLED'|'COMPLETED'|'FAILED'|'PARTIAL' // return ['INITIAL', 'REJECTED','CANCELLED', 'COMPLETED', 'FAILED', 'PARTIAL'].includes(this.serviceOrder.state) // return ['INITIAL', 'REJECTED','CANCELLED', 'COMPLETED', 'FAILED', 'PARTIAL'].includes(this.productOrder.state) return ['INITIAL'].includes(this.serviceOrder.state) return ['INITIAL'].includes(this.productOrder.state) } } areOrderItemsTerminable() { areOrderItemsTerminable() { return ['COMPLETED', 'FAILED', 'PARTIAL'].includes(this.serviceOrder.state) return ['COMPLETED', 'FAILED', 'PARTIAL'].includes(this.productOrder.state) } } openEditServiceOrderItemsDialog() { openEditProductOrderItemsDialog() { const dialogRef = this.dialog.open(EditProductOrderItemsComponent, { const dialogRef = this.dialog.open(EditProductOrderItemsComponent, { data: this.selection.selected, data: this.selection.selected, minWidth: "60vw" minWidth: "60vw" Loading @@ -292,41 +293,41 @@ export class PreviewProductOrderComponent implements OnInit { // console.log(editedOrderItems) // console.log(editedOrderItems) if (editedOrderItems) { if (editedOrderItems) { let newOrderUpdate: ServiceOrderUpdate = { let newOrderUpdate: ProductOrderUpdate = { orderItem: [] productOrderItem: [] } editedOrderItems.forEach( editedOrderItem => { this.serviceOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID).service.serviceCharacteristic = editedOrderItem.serviceSpecChars // Decide orderItem action verb if (this.serviceOrder.state === "COMPLETED") { this.serviceOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID).action = "modify" } } // editedOrderItems.forEach( editedOrderItem => { // this.productOrder.productOrderItem.find(item => item.id === editedOrderItem.orderItemID).product.productCharacteristic = editedOrderItem.serviceSpecChars // // Decide orderItem action verb // if (this.productOrder.state === "COMPLETED") { // this.productOrder.productOrderItem.find(item => item.id === editedOrderItem.orderItemID).action = "modify" // } // newOrderUpdate.orderItem.push(this.serviceOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID)) // // newOrderUpdate.orderItem.push(this.productOrder.orderItem.find(item => item.id === editedOrderItem.orderItemID)) }) // }) newOrderUpdate.orderItem = this.serviceOrder.orderItem newOrderUpdate.productOrderItem = this.productOrder.productOrderItem // console.log(newOrderUpdate) // console.log(newOrderUpdate) this.orderService.patchServiceOrder({serviceOrder: newOrderUpdate, id: this.serviceOrder.id}).subscribe( // this.orderService.patchProductOrder({productOrder: newOrderUpdate, id: this.productOrder.id}).subscribe( data => { // data => { this.toast.success("Selected Order Items were successfully updated") // this.toast.success("Selected Order Items were successfully updated") this.retrieveServiceOrder() // this.retrieveProductOrder() }, // }, error => { // error => { this.toast.error("An error occurred while updating Service Order Items") // this.toast.error("An error occurred while updating Service Order Items") this.retrieveServiceOrder() // this.retrieveProductOrder() console.error(error) // console.error(error) } // } ) // ) } } } } ) ) } } terminateServiceOrderItemsDialog() { terminateProductOrderItemsDialog() { const dialogRef = this.dialog.open(TerminateProductOrderItemsComponent, { const dialogRef = this.dialog.open(TerminateProductOrderItemsComponent, { data: this.selection.selected data: this.selection.selected }) }) Loading @@ -334,29 +335,29 @@ export class PreviewProductOrderComponent implements OnInit { dialogRef.afterClosed().subscribe( dialogRef.afterClosed().subscribe( result => { result => { if (result) { if (result) { let newOrderUpdate: ServiceOrderUpdate = { let newOrderUpdate: ProductOrderUpdate = { orderItem: [] productOrderItem: [] } } this.selection.selected.forEach( selectedOrderItem => { // this.selection.selected.forEach( selectedOrderItem => { this.serviceOrder.orderItem.find(item => item.id === selectedOrderItem.id).action = "modify" // this.productOrder.productOrderItem.find(item => item.id === selectedOrderItem.id).action = "modify" this.serviceOrder.orderItem.find(item => item.id === selectedOrderItem.id).service.state = "terminated" // this.productOrder.productOrderItem.find(item => item.id === selectedOrderItem.id).product.state = "terminated" }) // }) newOrderUpdate.orderItem = this.serviceOrder.orderItem newOrderUpdate.productOrderItem = this.productOrder.productOrderItem // console.log(newOrderUpdate) // console.log(newOrderUpdate) this.orderService.patchServiceOrder({serviceOrder: newOrderUpdate, id: this.serviceOrder.id}).subscribe( // this.orderService.patchProductOrder({productOrder: newOrderUpdate, id: this.productOrder.id}).subscribe( data => { // data => { this.toast.success("Selected Order Items were successfully updated") // this.toast.success("Selected Order Items were successfully updated") this.retrieveServiceOrder() // this.retrieveProductOrder() }, // }, error => { // error => { this.toast.error("An error occurred while updating Service Order Items") // this.toast.error("An error occurred while updating Service Order Items") this.retrieveServiceOrder() // this.retrieveProductOrder() console.error(error) // console.error(error) } // } ) // ) } } } } ) ) Loading @@ -365,14 +366,14 @@ export class PreviewProductOrderComponent implements OnInit { //checkBoxSelection Logic //checkBoxSelection Logic isAllSelected() { isAllSelected() { const numSelected = this.selection.selected.length const numSelected = this.selection.selected.length const numItems = this.serviceOrder.orderItem.length const numItems = this.productOrder.productOrderItem.length return numSelected === numItems return numSelected === numItems } } masterCheckboxToggle() { masterCheckboxToggle() { this.isAllSelected() ? this.isAllSelected() ? this.selection.clear() : this.selection.clear() : this.serviceOrder.orderItem.forEach (item => this.selection.select(item)) this.productOrder.productOrderItem.forEach (item => this.selection.select(item)) } } //---checkBoxSelection Logic //---checkBoxSelection Logic Loading @@ -381,7 +382,7 @@ export class PreviewProductOrderComponent implements OnInit { this.subscription = timer(0, 10000).subscribe( this.subscription = timer(0, 10000).subscribe( data => { data => { // this.supportingServices = [[]] // this.supportingServices = [[]] this.retrieveServiceOrder() this.retrieveProductOrder() } } ) ) } } Loading
src/app/p_product/orderCheckout/product-order-checkout/product-order-checkout.component.ts +93 −75 Original line number Original line Diff line number Diff line Loading @@ -18,7 +18,6 @@ const today = new Date(); templateUrl: './product-order-checkout.component.html', templateUrl: './product-order-checkout.component.html', styleUrls: ['./product-order-checkout.component.scss'] styleUrls: ['./product-order-checkout.component.scss'] }) }) export class ProductOrderCheckoutComponent implements OnInit { export class ProductOrderCheckoutComponent implements OnInit { constructor( constructor( Loading Loading @@ -51,8 +50,6 @@ export class ProductOrderCheckoutComponent implements OnInit { this.populateOrderedSpecsConfigurationList() this.populateOrderedSpecsConfigurationList() } } freshLoadOrderListChanges() { freshLoadOrderListChanges() { let storageOrderArray = [] let storageOrderArray = [] storageOrderArray = JSON.parse(localStorage.getItem('orderedProductSpecsList')) || [] storageOrderArray = JSON.parse(localStorage.getItem('orderedProductSpecsList')) || [] Loading Loading @@ -82,7 +79,6 @@ export class ProductOrderCheckoutComponent implements OnInit { } } } } initCharacteristicsValue(orderedSpec: ProductOffering): { name: string; valueType: string; value: import("src/app/openApis/productCatalogManagement/models").ProductSpecificationCharacteristicValue[]; }[] { initCharacteristicsValue(orderedSpec: ProductOffering): { name: string; valueType: string; value: import("src/app/openApis/productCatalogManagement/models").ProductSpecificationCharacteristicValue[]; }[] { let initialCharValues: { let initialCharValues: { name: string, name: string, Loading @@ -106,16 +102,12 @@ export class ProductOrderCheckoutComponent implements OnInit { }) }) }) }) return initialCharValues return initialCharValues } } initValuesForm() { initValuesForm() { // console.log(this.requesterService.serviceConfigurationList) this.specCharFormArray = new UntypedFormArray([]) this.specCharFormArray = new UntypedFormArray([]) const formArray = this.specCharFormArray as UntypedFormArray const formArray = this.specCharFormArray as UntypedFormArray this.configurableSpecChar = this.selectedOrderSpecToView.offering.prodSpecCharValueUse; this.configurableSpecChar = this.selectedOrderSpecToView.offering.prodSpecCharValueUse; //Sort Configurable Characteristics by Asc Name Order //Sort Configurable Characteristics by Asc Name Order Loading @@ -124,7 +116,6 @@ export class ProductOrderCheckoutComponent implements OnInit { this.configurableSpecChar.forEach((confSpecChar) => { this.configurableSpecChar.forEach((confSpecChar) => { formArray.push(this.updateFormArrayItem(confSpecChar)) formArray.push(this.updateFormArrayItem(confSpecChar)) }) }) } } updateFormArrayItem(specChar: ProductSpecificationCharacteristicRes): UntypedFormGroup { updateFormArrayItem(specChar: ProductSpecificationCharacteristicRes): UntypedFormGroup { Loading Loading @@ -152,9 +143,7 @@ export class ProductOrderCheckoutComponent implements OnInit { } } viewAndConfigureSpec(item: productSpecConfigurationListItem) { viewAndConfigureSpec(item: productSpecConfigurationListItem) { this.updateActiveProductInList() this.updateActiveProductInList() this.selectedOrderSpecToView = item this.selectedOrderSpecToView = item this.initValuesForm() this.initValuesForm() } } Loading @@ -180,7 +169,6 @@ export class ProductOrderCheckoutComponent implements OnInit { if (orderArray.length) { if (orderArray.length) { orderArray.splice(orderArray.findIndex(el => el === specId), 1) orderArray.splice(orderArray.findIndex(el => el === specId), 1) } } localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) } } Loading @@ -188,71 +176,102 @@ export class ProductOrderCheckoutComponent implements OnInit { this.updateActiveProductInList(); this.updateActiveProductInList(); let newOrder: ProductOrderCreate = { const startDate = this.reqStartDate.value ? new Date(this.reqStartDate.value).toISOString() : new Date().toISOString(); const completionDate = this.reqCompletionDate.value ? new Date(this.reqCompletionDate.value).toISOString() : new Date().toISOString(); let newOrder: ProductOrderCreate | any = { "@type": "ProductOrder", category: "Product Order", description: "Product Order via Portal", requestedStartDate: startDate, requestedCompletionDate: completionDate, productOrderItem: [], productOrderItem: [], requestedStartDate: this.reqStartDate.value, relatedParty: [] requestedCompletionDate: this.reqCompletionDate.value }; }; if (this.serviceNoteCtrl.value) { if (this.authService.portalUserJWT) { newOrder.note = [{ newOrder.relatedParty.push({ author: this.authService.portalUserJWT.preferred_username, "@type": "RelatedParty", text: this.serviceNoteCtrl.value, role: 'REQUESTER', date: new Date().toISOString() name: this.authService.portalUserJWT.preferred_username || 'Unknown', }]; }); } } this.orderedSpecsConfigurationList.forEach((productItem, index) => { this.orderedSpecsConfigurationList.forEach((productItem, index) => { if (!productItem.offering || !productItem.offering.id) { if (!productItem.offering?.id) return; this.toastr.error('Not a valid product offering', 'Configuration Error'); return; } const pChars = []; const pChars = []; productItem.specCharacteristics.forEach((characteristic) => { productItem.specCharacteristics.forEach((characteristic) => { let valToSubmit = null; if (['SET', 'ARRAY'].includes(characteristic.valueType?.toUpperCase())) { //filter empty values valToSubmit = { const validItems = characteristic.value.filter(el => el.value && el.value.value && String(el.value.value).trim() !== ''); value: JSON.stringify(characteristic.value.map(el => ({ 'value': el.value.value, 'alias': el.value.alias }))) }; validItems.forEach(item => { } else { let charType = 'StringCharacteristic'; valToSubmit = characteristic.value[0]?.value; let rawValue: any = item.value.value; if (characteristic.valueType === 'INTEGER') { charType = 'IntegerCharacteristic'; rawValue = parseInt(rawValue); } else if (characteristic.valueType === 'FLOAT') { charType = 'FloatCharacteristic'; rawValue = parseFloat(rawValue); } else if (characteristic.valueType === 'BOOLEAN') { charType = 'BooleanCharacteristic'; rawValue = (String(rawValue).toLowerCase() === 'true'); } } if(valToSubmit) { pChars.push({ pChars.push({ name: characteristic.name, name: characteristic.name, valueType: characteristic.valueType, valueType: characteristic.valueType, value: valToSubmit "@type": charType, }); value: { value: rawValue, alias: item.value.alias || '' } } }); }); }); }); const newOrderItem: ProductOrderItem = { const newOrderItem: ProductOrderItem = { id: (index + 1).toString(), id: (index + 1).toString(), action: 'ADD', action: 'ADD', product: { quantity: 1, "@type": "ProductOrderItem", productOffering: { productOffering: { id: productItem.offering.id, id: productItem.offering.id, name: productItem.offering.name, name: productItem.offering.name, '@type': 'ProductOfferingRef' }, }, productCharacteristic: pChars product: { "@type": "Product", productCharacteristic: pChars, productSpecification: productItem.offering.productSpecification ? { id: productItem.offering.productSpecification.id, name: productItem.offering.name, version: productItem.offering.version, '@type': 'ProductSpecificationRef' } : undefined } as any } as any }; }; newOrder.productOrderItem.push(newOrderItem); newOrder.productOrderItem.push(newOrderItem); }); }); // console.log('Submitting Product Order:', newOrder); this.orderService.createProductOrder({ body: newOrder }).subscribe({ this.orderService.createProductOrder({ body: newOrder }).subscribe({ next: (createdOrder: any) => { next: (createdOrder: any) => { this.toastr.success("Product Order was successfully placed"); this.toastr.success("Order Placed Successfully"); this.orderedSpecsConfigurationList = []; this.orderedSpecsConfigurationList = []; this.productRequesterService.orderedProductSpecsList = []; this.productRequesterService.orderedProductSpecsList = []; localStorage.removeItem('orderedProductSpecsList'); localStorage.removeItem('orderedProductSpecsList'); if (createdOrder?.id) { if (createdOrder?.id) { this.router.navigate(["products", 'product_order', createdOrder.id]); this.router.navigate(["products", 'product_order', createdOrder.id]); } else { } else { Loading @@ -260,8 +279,8 @@ export class ProductOrderCheckoutComponent implements OnInit { } } }, }, error: (error) => { error: (error) => { console.error(error); console.error("Submission Error:", error); this.toastr.error("An error occurred while processing your Service Order"); this.toastr.error("Validation Failed (400).", "Order Failed"); } } }); }); } } Loading @@ -274,5 +293,4 @@ export class ProductOrderCheckoutComponent implements OnInit { this.subscription.unsubscribe() this.subscription.unsubscribe() } } } } No newline at end of file