fix: translate __orphan__ sentinel to null in bulk move; ungrouped units now fully bulk-operable

This commit is contained in:
Falkan
2026-03-17 18:32:03 -04:00
parent 91398174e6
commit f43f415cfa
2 changed files with 7 additions and 33 deletions

View File

@@ -5,7 +5,7 @@
"label": "Blurb",
"labelPlural": "Blurbs",
"symbol": "bl",
"group": "florp",
"group": "agroup",
"toBase": 1
},
{
@@ -13,42 +13,14 @@
"label": "Snorp",
"labelPlural": "Snorps",
"symbol": "sn",
"group": "florp",
"group": "agroup",
"toBase": 7.5
},
{
"id": "krumble",
"label": "Krumble",
"labelPlural": "Krumbles",
"symbol": "kr",
"group": "the-third-group",
"toBase": 0.25
},
{
"id": "wobbit",
"label": "Wobbit",
"labelPlural": "Wobbits",
"symbol": "wb",
"group": "florp",
"toBase": 144
}
],
"groups": [
{
"id": "florp",
"label": "Florp Units",
"baseUnitId": "blurb",
"toUniversal": 1
},
{
"id": "non-florp-units",
"label": "The other group",
"baseUnitId": "",
"toUniversal": 1
},
{
"id": "the-third-group",
"label": "The third group",
"id": "agroup",
"label": "agroup",
"baseUnitId": "",
"toUniversal": 1
}

View File

@@ -125,12 +125,14 @@
if (bulkAction === 'move') {
if (!bulkMoveTargetGroupId || checkedUnitIds.size === 0) return;
formError = null;
// '__orphan__' is the sentinel value for "move to ungrouped" (group: null)
const targetGroup = bulkMoveTargetGroupId === '__orphan__' ? null : bulkMoveTargetGroupId;
const results = await Promise.all(
[...checkedUnitIds].map((unitId) =>
fetch(`/admin/api/units/${unitId}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ group: bulkMoveTargetGroupId })
body: JSON.stringify({ group: targetGroup })
})
)
);