chore(webui): make add mods behave more like adding items (#1732)

Reviewed-on: OpenWF/SpaceNinjaServer#1732
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-04-19 09:05:55 -07:00 committed by Sainan
parent e59bdcdfbc
commit 26f37f58e5

View File

@ -1260,6 +1260,8 @@ function doAcquireMod() {
$("#mod-to-acquire").addClass("is-invalid").focus(); $("#mod-to-acquire").addClass("is-invalid").focus();
return; return;
} }
const count = parseInt($("#mod-count").val());
if (count != 0) {
revalidateAuthz(() => { revalidateAuthz(() => {
$.post({ $.post({
url: "/custom/addItems?" + window.authz, url: "/custom/addItems?" + window.authz,
@ -1267,14 +1269,19 @@ function doAcquireMod() {
data: JSON.stringify([ data: JSON.stringify([
{ {
ItemType: uniqueName, ItemType: uniqueName,
ItemCount: parseInt($("#mod-count").val()) ItemCount: count
} }
]) ])
}).done(function () { }).done(function () {
document.getElementById("mod-to-acquire").value = ""; if (count > 0) {
toast(loc("code_succAdded"));
} else {
toast(loc("code_succRemoved"));
}
updateInventory(); updateInventory();
}); });
}); });
}
} }
const uiConfigs = [...$("#server-settings input[id]")].map(x => x.id); const uiConfigs = [...$("#server-settings input[id]")].map(x => x.id);