Add accumulator preview reordering
This commit is contained in:
@@ -154,6 +154,31 @@ async function deleteSelected(node) {
|
||||
}
|
||||
}
|
||||
|
||||
async function moveSelected(node, direction) {
|
||||
const key = storeKey(node);
|
||||
if (!key) {
|
||||
alert("Set the same explicit store_key on the Accumulator and Accumulator Preview first.");
|
||||
return;
|
||||
}
|
||||
const entry = selectedEntry(node);
|
||||
if (!entry) {
|
||||
alert("No accumulator entry selected.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const data = await postJson("/sxcp/accumulator/move", {
|
||||
store_key: key,
|
||||
entry_id: entry.id || "",
|
||||
index: entry.id ? 0 : entry.index,
|
||||
direction,
|
||||
});
|
||||
setEntries(node, data.entries || [], `${data.status || ""}; moved=${data.moved ? "yes" : "no"}; rerun preview to refresh images`);
|
||||
} catch (err) {
|
||||
console.error(`[${EXTENSION}] move failed`, err);
|
||||
alert(`Move failed: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function clearStore(node) {
|
||||
const key = storeKey(node);
|
||||
if (!key) {
|
||||
@@ -183,6 +208,18 @@ function setupNode(node) {
|
||||
node._sxcpAccumulatorStatusWidget = node.addWidget("text", "accumulator_status", "no accumulator data", () => {});
|
||||
node._sxcpAccumulatorStatusWidget.serialize = false;
|
||||
}
|
||||
if (!node._sxcpMoveTopButton) {
|
||||
node._sxcpMoveTopButton = node.addWidget("button", "Move Selected Top", null, () => moveSelected(node, "top"));
|
||||
}
|
||||
if (!node._sxcpMoveUpButton) {
|
||||
node._sxcpMoveUpButton = node.addWidget("button", "Move Selected Up", null, () => moveSelected(node, "up"));
|
||||
}
|
||||
if (!node._sxcpMoveDownButton) {
|
||||
node._sxcpMoveDownButton = node.addWidget("button", "Move Selected Down", null, () => moveSelected(node, "down"));
|
||||
}
|
||||
if (!node._sxcpMoveBottomButton) {
|
||||
node._sxcpMoveBottomButton = node.addWidget("button", "Move Selected Bottom", null, () => moveSelected(node, "bottom"));
|
||||
}
|
||||
if (!node._sxcpDeleteSelectedButton) {
|
||||
node._sxcpDeleteSelectedButton = node.addWidget("button", "Delete Selected Entry", null, () => deleteSelected(node));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user