Files
ISA-Frontend/apps/page/goods-in/src/lib/goods-in-reservation/goods-in-reservation-selectable.pipe.ts
Andreas Schickinger 69c23a55f7 Merged PR 1453: #3682 AHF // Reservierungsliste - RadionButton ein- und ausblenden bei Paid/Unpaid
#3682 AHF // Reservierungsliste - Radion-Button ein- und ausblenden bei Bezahlt vs Nicht Bezahlt

Related work items: #3682
2022-11-29 14:17:52 +00:00

24 lines
899 B
TypeScript

import { Pipe, PipeTransform } from '@angular/core';
import { KeyValueDTOOfStringAndString, OrderItemListItemDTO } from '@swagger/oms';
@Pipe({
name: 'goodsInReservationSelectable',
})
export class GoodsInReservationSelectablePipe implements PipeTransform {
transform(
item: OrderItemListItemDTO,
selectionRules: (action: KeyValueDTOOfStringAndString) => boolean,
selectedItems: OrderItemListItemDTO[]
): boolean {
if (selectedItems.length > 0) {
const firstSelectedItem = selectedItems[0];
const selectedLabel = firstSelectedItem.actions.find((action) => selectionRules(action)).label;
return item?.actions?.some(
(action) => selectionRules(action) && action.label === selectedLabel && item?.features?.paid === firstSelectedItem?.features?.paid
);
} else {
return item?.actions?.some((action) => selectionRules(action));
}
}
}