fix: translate __orphan__ sentinel to null in bulk move; ungrouped units now fully bulk-operable
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 })
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user