1.3.0
Fix item pagination and unassigned item placement - Keep unassigned items off earlier assigned pages - Start unassigned items after the last assigned slot - Continue unassigned items on subsequent pages - Prevent unassigned item duplication - Correct pagination for categories with no assigned items - Update maximum page calculation to match pagination behavior
This commit is contained in:
1 parent
b6d376a2f9
commit
a992f044cd
10 files changed
+326
-96
No files matched your search
@@ -84,12 +84,6 @@ public class ItemsMenu {
|
||||
)
|
||||
);
|
||||
|
||||
List<WarehouseItem> items =
|
||||
ItemsPagination.getItemsForDisplay(
|
||||
categoryId,
|
||||
page
|
||||
);
|
||||
|
||||
int maxPage =
|
||||
ItemsPagination.getMaximumPage(
|
||||
categoryId
|
||||
@@ -108,6 +102,12 @@ public class ItemsMenu {
|
||||
page
|
||||
);
|
||||
|
||||
List<WarehouseItem> items =
|
||||
ItemsPagination.getItemsForDisplay(
|
||||
categoryId,
|
||||
page
|
||||
);
|
||||
|
||||
boolean hasPrevious =
|
||||
page > 0;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ItemsPagination {
|
||||
|
||||
int highestAssignedPage = -1;
|
||||
int unassigned = 0;
|
||||
int lastPageHighestSlot = 8;
|
||||
int finalAssignedHighestSlot = 8;
|
||||
|
||||
for (WarehouseItem item : items) {
|
||||
|
||||
@@ -47,18 +47,25 @@ public class ItemsPagination {
|
||||
|
||||
}
|
||||
|
||||
if (highestAssignedPage < 0) {
|
||||
/*
|
||||
* No assigned items means this is a normal unassigned-only list.
|
||||
*/
|
||||
if (highestAssignedPage == -1) {
|
||||
|
||||
int pages =
|
||||
(unassigned + 44) / 45;
|
||||
if (unassigned == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(
|
||||
0,
|
||||
pages - 1
|
||||
);
|
||||
return (unassigned - 1) / 45;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Only the final assigned page can contain unassigned items.
|
||||
*/
|
||||
int finalAssignedPage =
|
||||
highestAssignedPage + 1;
|
||||
|
||||
for (WarehouseItem item : items) {
|
||||
|
||||
if (
|
||||
@@ -66,12 +73,12 @@ public class ItemsPagination {
|
||||
&&
|
||||
item.slot() != null
|
||||
&&
|
||||
item.page() == highestAssignedPage + 1
|
||||
item.page() == finalAssignedPage
|
||||
) {
|
||||
|
||||
lastPageHighestSlot =
|
||||
finalAssignedHighestSlot =
|
||||
Math.max(
|
||||
lastPageHighestSlot,
|
||||
finalAssignedHighestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
@@ -79,25 +86,22 @@ public class ItemsPagination {
|
||||
|
||||
}
|
||||
|
||||
int availableOnLastAssignedPage =
|
||||
int availableOnFinalAssignedPage =
|
||||
Math.max(
|
||||
0,
|
||||
53 - lastPageHighestSlot
|
||||
53 - finalAssignedHighestSlot
|
||||
);
|
||||
|
||||
int remainingUnassigned =
|
||||
Math.max(
|
||||
0,
|
||||
unassigned - availableOnLastAssignedPage
|
||||
unassigned - availableOnFinalAssignedPage
|
||||
);
|
||||
|
||||
int overflowPages =
|
||||
(remainingUnassigned + 44) / 45;
|
||||
|
||||
return Math.max(
|
||||
0,
|
||||
highestAssignedPage + overflowPages
|
||||
);
|
||||
return highestAssignedPage + overflowPages;
|
||||
|
||||
}
|
||||
|
||||
@@ -150,7 +154,37 @@ public class ItemsPagination {
|
||||
}
|
||||
|
||||
/*
|
||||
* Assigned pages
|
||||
* Categories with no assigned items are a simple unassigned-only
|
||||
* list. They begin on page 1 and use all 45 item slots.
|
||||
*/
|
||||
if (highestAssignedPage == -1) {
|
||||
|
||||
int start =
|
||||
page * 45;
|
||||
|
||||
if (start >= unassigned.size()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
int end =
|
||||
Math.min(
|
||||
start + 45,
|
||||
unassigned.size()
|
||||
);
|
||||
|
||||
return new ArrayList<>(
|
||||
unassigned.subList(
|
||||
start,
|
||||
end
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Assigned pages. Only the final assigned page receives
|
||||
* unassigned items, and they begin immediately after the
|
||||
* highest assigned slot on that page.
|
||||
*/
|
||||
if (page <= highestAssignedPage) {
|
||||
|
||||
@@ -175,9 +209,6 @@ public class ItemsPagination {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Unassigned items begin only on the last assigned page.
|
||||
*/
|
||||
if (page == highestAssignedPage) {
|
||||
|
||||
int remainingSlots =
|
||||
@@ -186,17 +217,18 @@ public class ItemsPagination {
|
||||
53 - highestSlot
|
||||
);
|
||||
|
||||
for (int i = 0;
|
||||
i < remainingSlots && i < unassigned.size();
|
||||
i++) {
|
||||
int end =
|
||||
Math.min(
|
||||
remainingSlots,
|
||||
unassigned.size()
|
||||
);
|
||||
|
||||
results.add(
|
||||
unassigned.get(
|
||||
i
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
results.addAll(
|
||||
unassigned.subList(
|
||||
0,
|
||||
end
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -205,17 +237,21 @@ public class ItemsPagination {
|
||||
}
|
||||
|
||||
/*
|
||||
* Overflow pages contain only unassigned items.
|
||||
* Pages after the final assigned page contain only unassigned
|
||||
* items. The first overflow page starts after the unassigned
|
||||
* items that fit on the final assigned page.
|
||||
*/
|
||||
int lastPageHighestSlot = 8;
|
||||
int finalAssignedHighestSlot = 8;
|
||||
int finalAssignedPage =
|
||||
highestAssignedPage + 1;
|
||||
|
||||
for (WarehouseItem item : assigned) {
|
||||
|
||||
if (item.page() == highestAssignedPage + 1) {
|
||||
if (item.page() == finalAssignedPage) {
|
||||
|
||||
lastPageHighestSlot =
|
||||
finalAssignedHighestSlot =
|
||||
Math.max(
|
||||
lastPageHighestSlot,
|
||||
finalAssignedHighestSlot,
|
||||
item.slot()
|
||||
);
|
||||
|
||||
@@ -226,7 +262,7 @@ public class ItemsPagination {
|
||||
int consumed =
|
||||
Math.max(
|
||||
0,
|
||||
53 - lastPageHighestSlot
|
||||
53 - finalAssignedHighestSlot
|
||||
);
|
||||
|
||||
consumed =
|
||||
|
||||
Reference in new issue
Block a user