mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
committed by
Lorenz Hilpert
parent
15a4718e58
commit
a086111ab5
@@ -23,7 +23,7 @@
|
||||
{{ hits() }} Einträge
|
||||
</span>
|
||||
|
||||
<div class="flex flex-col gap-4 w-full items-center justify-center mb-24">
|
||||
<div class="flex flex-col gap-4 w-full items-center justify-center mb-36">
|
||||
@for (item of items(); track item.id) {
|
||||
@defer (on viewport) {
|
||||
<remi-feature-remission-list-item
|
||||
@@ -52,14 +52,16 @@
|
||||
[hasValidSearchTerm]="hasValidSearchTerm()"
|
||||
[hits]="hits()"
|
||||
></remi-feature-remission-list-empty-state>
|
||||
<utils-scroll-top-button
|
||||
[position]="{ bottom: remissionStarted() ? '5.5rem' : '1.5rem' }"
|
||||
></utils-scroll-top-button>
|
||||
</div>
|
||||
|
||||
<utils-scroll-top-button
|
||||
class="flex flex-col self-end fixed bottom-6 mr-6"
|
||||
[class.scroll-top-button-spacing-bottom]="remissionStarted()"
|
||||
></utils-scroll-top-button>
|
||||
|
||||
@if (remissionStarted()) {
|
||||
<ui-stateful-button
|
||||
class="fixed right-6 bottom-6"
|
||||
class="flex flex-col self-end fixed bottom-6 mr-6"
|
||||
(clicked)="remitItems()"
|
||||
(action)="remitItems()"
|
||||
[(state)]="remitItemsState"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.scroll-top-button-spacing-bottom {
|
||||
@apply bottom-[5.5rem];
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import {
|
||||
RemissionListType,
|
||||
RemissionResponseArgsErrorMessage,
|
||||
UpdateItem,
|
||||
orderByListItems,
|
||||
} from '@isa/remission/data-access';
|
||||
import { injectDialog, injectFeedbackErrorDialog } from '@isa/ui/dialog';
|
||||
import { SearchItemToRemitDialogComponent } from '@isa/remission/shared/search-item-to-remit-dialog';
|
||||
@@ -372,20 +373,23 @@ export class RemissionListComponent {
|
||||
/**
|
||||
* Handles the removal or update of an item from the remission list.
|
||||
* Updates the local items signal and the remission store accordingly.
|
||||
* Items with impediments are automatically moved to the end of the list and sorted by attempt count.
|
||||
* @param param0 - Object containing inProgress state, itemId, and optional impediment.
|
||||
*/
|
||||
onRemoveOrUpdateItem({ inProgress, itemId, impediment }: UpdateItem) {
|
||||
this.removeItemInProgress.set(inProgress);
|
||||
if (!inProgress && itemId) {
|
||||
if (!impediment) {
|
||||
this.items.set(this.items().filter((item) => item.id !== itemId)); // Remove Item
|
||||
if (!impediment || (impediment.attempts && impediment.attempts >= 4)) {
|
||||
this.items.set(this.items().filter((item) => item.id !== itemId)); // Filter Item if no impediment or attempts >= 4 (#5361)
|
||||
} else {
|
||||
// Update Item
|
||||
this.items.update((items) =>
|
||||
items.map((item) =>
|
||||
this.items.update((items) => {
|
||||
const updatedItems = items.map((item) =>
|
||||
item.id === itemId ? { ...item, impediment } : item,
|
||||
),
|
||||
);
|
||||
);
|
||||
orderByListItems(updatedItems);
|
||||
return updatedItems;
|
||||
});
|
||||
}
|
||||
|
||||
// Always Unselect Item
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { inject, resource } from '@angular/core';
|
||||
import { ListResponseArgs, ResponseArgsError } from '@isa/common/data-access';
|
||||
import {
|
||||
orderByListItems,
|
||||
QueryTokenInput,
|
||||
RemissionItem,
|
||||
RemissionListType,
|
||||
@@ -9,7 +10,6 @@ import {
|
||||
RemissionSupplierService,
|
||||
} from '@isa/remission/data-access';
|
||||
import { SearchTrigger } from '@isa/shared/filter';
|
||||
import { parseISO, compareDesc } from 'date-fns';
|
||||
import { isEan } from '@isa/utils/ean-validation';
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ export const createRemissionListResource = (
|
||||
const hasOrderBy = !!queryToken?.orderBy && queryToken.orderBy.length > 0;
|
||||
|
||||
if (!hasOrderBy && res && res.result && Array.isArray(res.result)) {
|
||||
sortResponseResult(res);
|
||||
orderByListItems(res.result);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -152,55 +152,6 @@ export const createRemissionListResource = (
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sorts the remission items in the response based on specific criteria:
|
||||
* - Items with impediments are moved to the end of the list.
|
||||
* - Manually added items are prioritized to appear first.
|
||||
* - (Commented out) Items can be sorted by creation date in descending order.
|
||||
* @param {ListResponseArgs<RemissionItem>} resopnse - The response object containing remission items to be sorted
|
||||
* @returns {void} The function modifies the response object in place
|
||||
*/
|
||||
const sortResponseResult = (
|
||||
resopnse: ListResponseArgs<RemissionItem>,
|
||||
): void => {
|
||||
resopnse.result.sort((a, b) => {
|
||||
const aHasImpediment = !!a.impediment;
|
||||
const bHasImpediment = !!b.impediment;
|
||||
const aIsManuallyAdded = a.source === 'manually-added';
|
||||
const bIsManuallyAdded = b.source === 'manually-added';
|
||||
|
||||
// First priority: move all items with impediment to the end of the list
|
||||
if (!aHasImpediment && bHasImpediment) {
|
||||
return -1;
|
||||
}
|
||||
if (aHasImpediment && !bHasImpediment) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Second priority: manually-added items come first
|
||||
if (aIsManuallyAdded && !bIsManuallyAdded) {
|
||||
return -1;
|
||||
}
|
||||
if (!aIsManuallyAdded && bIsManuallyAdded) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// #5295 Fix - Sortierung über Created (Pflichtremission) wird wie auch die Sortierung über die SORT Nummer (Abteilungsremission) bereits über das Backend erledigt
|
||||
// Third priority: sort by created date (latest first)
|
||||
// if (a.created && b.created) {
|
||||
// const dateA = parseISO(a.created);
|
||||
// const dateB = parseISO(b.created);
|
||||
// return compareDesc(dateA, dateB); // Descending order (latest first)
|
||||
// }
|
||||
|
||||
// // Handle cases where created date might be missing
|
||||
// if (a.created && !b.created) return -1;
|
||||
// if (!a.created && b.created) return 1;
|
||||
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
// #5128 #5234 Bei Exact Search soll er über Alle Listen nur mit dem Input ohne aktive Filter / orderBy suchen
|
||||
/**
|
||||
* Checks if the query token is an exact search based on the search trigger.
|
||||
|
||||
Reference in New Issue
Block a user