From dce61e13252489c5db8dd7b69154806da00c419b Mon Sep 17 00:00:00 2001 From: Kostis Trantzas Date: Thu, 29 Aug 2024 18:50:30 +0300 Subject: [PATCH] Fix the display of Supporting Services in Service Orders than contain multiple Service Order Items (#8) --- ...resource-reservation-calendar.component.ts | 2 +- .../list-service-orders.component.ts | 2 +- .../preview-service-order.component.ts | 22 +++++++++++++------ .../service-order-calendar.component.ts | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/app/p_resources/admin/resourcePoolManagement/resource-reservation-calendar/resource-reservation-calendar.component.ts b/src/app/p_resources/admin/resourcePoolManagement/resource-reservation-calendar/resource-reservation-calendar.component.ts index 1727f5c..4ea9e87 100644 --- a/src/app/p_resources/admin/resourcePoolManagement/resource-reservation-calendar/resource-reservation-calendar.component.ts +++ b/src/app/p_resources/admin/resourcePoolManagement/resource-reservation-calendar/resource-reservation-calendar.component.ts @@ -84,7 +84,7 @@ export class ResourceReservationCalendarComponent implements OnInit { this.reservations ).map(function(eventEl: Reservation) { - console.info("this is event: " + eventEl.id +" " + eventEl.requestedPeriodStartDateTime ) + // console.info("this is event: " + eventEl.id +" " + eventEl.requestedPeriodStartDateTime ) // var result = new Date(eventEl.startDate); // var evd = result.toISOString().replace(/T.*$/, ''); // YYYY-MM-DD of today diff --git a/src/app/p_services/admin/orderManagement/list-service-orders/list-service-orders.component.ts b/src/app/p_services/admin/orderManagement/list-service-orders/list-service-orders.component.ts index 95b988e..fd2594f 100644 --- a/src/app/p_services/admin/orderManagement/list-service-orders/list-service-orders.component.ts +++ b/src/app/p_services/admin/orderManagement/list-service-orders/list-service-orders.component.ts @@ -109,7 +109,7 @@ export class ListServiceOrdersComponent implements OnInit { this.serviceOrders ).map(function(eventEl: ServiceOrder) { - console.info("this is event: " + eventEl.id +" " + eventEl.requestedStartDate ) + // console.info("this is event: " + eventEl.id +" " + eventEl.requestedStartDate ) // var result = new Date(eventEl.startDate); // var evd = result.toISOString().replace(/T.*$/, ''); // YYYY-MM-DD of today diff --git a/src/app/p_services/admin/orderManagement/preview-service-order/preview-service-order.component.ts b/src/app/p_services/admin/orderManagement/preview-service-order/preview-service-order.component.ts index 69c43d6..37851f0 100644 --- a/src/app/p_services/admin/orderManagement/preview-service-order/preview-service-order.component.ts +++ b/src/app/p_services/admin/orderManagement/preview-service-order/preview-service-order.component.ts @@ -58,8 +58,8 @@ export class PreviewServiceOrderComponent implements OnInit { serviceOrderNotFound: boolean = false finishedLoading: boolean = false - supportingServices: Service[][] = [[]] - + supportingServices: Service[][] = [] + // supportingServices' first array is Order Item Index and second array is SupportingService index of the respective Order Item editMode: boolean = false editModeNotes: boolean = false isAdminUser: boolean = false @@ -122,18 +122,26 @@ export class PreviewServiceOrderComponent implements OnInit { this.checkboxesOrderItemList = [] this.currentItemRelationshipsUrl = [] - this.serviceOrder.orderItem.forEach((orderItem, index) => { + + this.supportingServices = [] + this.serviceOrder.orderItem.forEach((orderItem) => { + + //Expands the length of the array for each Service Order Item + this.supportingServices.push([]) this.checkboxesOrderItemList.push({orderItem: orderItem, isChecked: false}) orderItem.service.serviceCharacteristic.sort(this.sortingService.ascStringSortingFunctionByNameProperty()) - orderItem.service.supportingService.forEach( (supService, serviceIndex) => { - this.retrieveServiceInventory(supService.id).pipe(delay(Math.random()*1000)).subscribe( - data => this.supportingServices[index][serviceIndex] = data + orderItem.service.supportingService.forEach( (supService) => { + this.retrieveServiceInventory(supService.id).subscribe( + data => { + const orderItemIndex = this.serviceOrder.orderItem.findIndex(SOI => orderItem.id === SOI.id) + const supportingServiceIndex = this.serviceOrder.orderItem[orderItemIndex].service.supportingService.findIndex(SupS => supService.id === SupS.id) + this.supportingServices[orderItemIndex][supportingServiceIndex] = data + } ) }) - this.currentItemRelationshipsUrl.push( this.orderService.rootUrl + "/serviceOrdering/v4/serviceOrder/" + this.serviceOrder.id + "/item/" + orderItem.id + "/relationship_graph" ); }) diff --git a/src/app/p_services/admin/orderManagement/service-order-calendar/service-order-calendar.component.ts b/src/app/p_services/admin/orderManagement/service-order-calendar/service-order-calendar.component.ts index 8daf914..39e0af6 100644 --- a/src/app/p_services/admin/orderManagement/service-order-calendar/service-order-calendar.component.ts +++ b/src/app/p_services/admin/orderManagement/service-order-calendar/service-order-calendar.component.ts @@ -69,7 +69,7 @@ export class ServiceOrdersCalendarComponent implements OnInit { this.serviceOrders ).map(function(eventEl: ServiceOrder) { - console.info("this is event: " + eventEl.id +" " + eventEl.requestedStartDate ) + // console.info("this is event: " + eventEl.id +" " + eventEl.requestedStartDate ) // var result = new Date(eventEl.startDate); // var evd = result.toISOString().replace(/T.*$/, ''); // YYYY-MM-DD of today -- GitLab