Split batch clear buttons for source and target images
This commit is contained in:
@@ -337,9 +337,10 @@ const renderReferenceRole = vm.runInContext("renderReferenceRole", context);
|
|||||||
const editReference = vm.runInContext("editReference", context);
|
const editReference = vm.runInContext("editReference", context);
|
||||||
const replaceReference = vm.runInContext("replaceReference", context);
|
const replaceReference = vm.runInContext("replaceReference", context);
|
||||||
const updateBatchReferenceHint = vm.runInContext("updateBatchReferenceHint", context);
|
const updateBatchReferenceHint = vm.runInContext("updateBatchReferenceHint", context);
|
||||||
const clearAllReferences = vm.runInContext("clearAllReferences", context);
|
const clearReferenceRole = vm.runInContext("clearReferenceRole", context);
|
||||||
const syncClearReferenceButtons = vm.runInContext("syncClearReferenceButtons", context);
|
const syncClearReferenceButtons = vm.runInContext("syncClearReferenceButtons", context);
|
||||||
const referenceListsAreEmpty = vm.runInContext("referenceListsAreEmpty", context);
|
const referenceListsAreEmpty = vm.runInContext("referenceListsAreEmpty", context);
|
||||||
|
const referenceRoleIsEmpty = vm.runInContext("referenceRoleIsEmpty", context);
|
||||||
const setWidgetValue = vm.runInContext("setWidgetValue", context);
|
const setWidgetValue = vm.runInContext("setWidgetValue", context);
|
||||||
const updateBatchSummary = vm.runInContext("updateBatchSummary", context);
|
const updateBatchSummary = vm.runInContext("updateBatchSummary", context);
|
||||||
const initializeSaveSlots = vm.runInContext("initializeSaveSlots", context);
|
const initializeSaveSlots = vm.runInContext("initializeSaveSlots", context);
|
||||||
@@ -516,10 +517,12 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
|
|||||||
assert.equal(modelActions.className, "o1ig-asset-actions");
|
assert.equal(modelActions.className, "o1ig-asset-actions");
|
||||||
assert.equal(modelActions.children[0], node._o1igClearModelReferences);
|
assert.equal(modelActions.children[0], node._o1igClearModelReferences);
|
||||||
assert.equal(modelActions.children[1], node._o1igModelCanvasPick);
|
assert.equal(modelActions.children[1], node._o1igModelCanvasPick);
|
||||||
assert.equal(node._o1igClearModelReferences.children[0].textContent, "清空");
|
assert.equal(node._o1igClearModelReferences.children[0].textContent, "清空目标图");
|
||||||
assert.equal(node._o1igClearModelReferences.disabled, true);
|
assert.equal(node._o1igClearModelReferences.disabled, true);
|
||||||
|
assert.equal(node._o1igClearReferences.children[0].textContent, "清空素材图");
|
||||||
node._o1igBatchToggle.dispatch("click");
|
node._o1igBatchToggle.dispatch("click");
|
||||||
assert.equal(node._o1igBatchEnabled, false);
|
assert.equal(node._o1igBatchEnabled, false);
|
||||||
|
assert.equal(node._o1igClearReferences.children[0].textContent, "清空参考图");
|
||||||
const promptWidget = widgets.find(widget => widget.name === "prompt");
|
const promptWidget = widgets.find(widget => widget.name === "prompt");
|
||||||
const computeSize = promptWidget.computeSize;
|
const computeSize = promptWidget.computeSize;
|
||||||
promptWidget.options = {};promptWidget.hidden = false;
|
promptWidget.options = {};promptWidget.hidden = false;
|
||||||
@@ -3141,8 +3144,10 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
|
|||||||
};
|
};
|
||||||
buildPanel(clearNode);
|
buildPanel(clearNode);
|
||||||
assert.equal(referenceListsAreEmpty(clearNode), true);
|
assert.equal(referenceListsAreEmpty(clearNode), true);
|
||||||
assert.equal(clearAllReferences(clearNode), false, "No-op when already empty");
|
assert.equal(referenceRoleIsEmpty(clearNode, "references"), true);
|
||||||
|
assert.equal(clearReferenceRole(clearNode, "references"), false, "No-op when already empty");
|
||||||
assert.equal(clearNode._o1igClearReferences.disabled, true);
|
assert.equal(clearNode._o1igClearReferences.disabled, true);
|
||||||
|
assert.equal(clearNode._o1igClearReferences.children[0].textContent, "清空参考图");
|
||||||
|
|
||||||
clearNode._o1igReferences = [
|
clearNode._o1igReferences = [
|
||||||
{ name: "a.png", subfolder: "", type: "input" },
|
{ name: "a.png", subfolder: "", type: "input" },
|
||||||
@@ -3153,11 +3158,10 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
|
|||||||
setWidgetValue(clearNode, "蒙版清单", JSON.stringify(clearNode._o1igMask));
|
setWidgetValue(clearNode, "蒙版清单", JSON.stringify(clearNode._o1igMask));
|
||||||
syncClearReferenceButtons(clearNode);
|
syncClearReferenceButtons(clearNode);
|
||||||
assert.equal(clearNode._o1igClearReferences.disabled, false);
|
assert.equal(clearNode._o1igClearReferences.disabled, false);
|
||||||
assert.equal(clearAllReferences(clearNode), true);
|
assert.equal(clearReferenceRole(clearNode, "references"), true);
|
||||||
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igReferences)), []);
|
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igReferences)), []);
|
||||||
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
|
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
|
||||||
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, "[]");
|
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, "[]");
|
||||||
assert.equal(widgets.find((widget) => widget.name === "模特图清单").value, "[]");
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
JSON.parse(JSON.stringify(clearNode._o1igMask)),
|
JSON.parse(JSON.stringify(clearNode._o1igMask)),
|
||||||
{ name: "mask.png", subfolder: "", type: "input" },
|
{ name: "mask.png", subfolder: "", type: "input" },
|
||||||
@@ -3176,7 +3180,24 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
|
|||||||
syncClearReferenceButtons(clearNode);
|
syncClearReferenceButtons(clearNode);
|
||||||
assert.equal(clearNode._o1igClearReferences.disabled, false);
|
assert.equal(clearNode._o1igClearReferences.disabled, false);
|
||||||
assert.equal(clearNode._o1igClearModelReferences.disabled, false);
|
assert.equal(clearNode._o1igClearModelReferences.disabled, false);
|
||||||
|
assert.equal(clearNode._o1igClearReferences.children[0].textContent, "清空素材图");
|
||||||
|
assert.equal(clearNode._o1igClearModelReferences.children[0].textContent, "清空目标图");
|
||||||
|
assert.equal(clearNode._o1igClearReferences.title, "清空全部素材图");
|
||||||
|
assert.equal(clearNode._o1igClearModelReferences.title, "清空全部目标图");
|
||||||
|
|
||||||
clearNode._o1igClearModelReferences.dispatch("click");
|
clearNode._o1igClearModelReferences.dispatch("click");
|
||||||
|
assert.deepEqual(
|
||||||
|
JSON.parse(JSON.stringify(clearNode._o1igReferences)),
|
||||||
|
[{ name: "outfit.png", subfolder: "", type: "input" }],
|
||||||
|
"Clearing 目标图 must not touch 素材图",
|
||||||
|
);
|
||||||
|
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
|
||||||
|
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, JSON.stringify([{ name: "outfit.png", subfolder: "", type: "input" }]));
|
||||||
|
assert.equal(widgets.find((widget) => widget.name === "模特图清单").value, "[]");
|
||||||
|
assert.equal(clearNode._o1igClearReferences.disabled, false);
|
||||||
|
assert.equal(clearNode._o1igClearModelReferences.disabled, true);
|
||||||
|
|
||||||
|
clearNode._o1igClearReferences.dispatch("click");
|
||||||
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igReferences)), []);
|
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igReferences)), []);
|
||||||
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
|
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
|
||||||
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, "[]");
|
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, "[]");
|
||||||
@@ -3274,8 +3295,12 @@ assert.match(source, /\.o1ig-thumb\{[\s\S]*?flex:0 0 102px;height:102px/);
|
|||||||
assert.match(source, /\.o1ig-thumb img\{[\s\S]*?object-fit:contain;background:var\(--o1ig-surface\)/);
|
assert.match(source, /\.o1ig-thumb img\{[\s\S]*?object-fit:contain;background:var\(--o1ig-surface\)/);
|
||||||
assert.match(source, /referenceActions\.append\(clearReferences, canvasPick\)/);
|
assert.match(source, /referenceActions\.append\(clearReferences, canvasPick\)/);
|
||||||
assert.match(source, /modelActions\.append\(clearModelReferences, modelCanvasPick\)/);
|
assert.match(source, /modelActions\.append\(clearModelReferences, modelCanvasPick\)/);
|
||||||
assert.match(source, /function clearAllReferences\(node\)/);
|
assert.match(source, /function clearReferenceRole\(node, role = "references"\)/);
|
||||||
assert.match(source, /textContent = "清空参考图"/);
|
assert.match(source, /textContent = "清空参考图"/);
|
||||||
|
assert.match(source, /textContent = "清空目标图"/);
|
||||||
|
assert.match(source, /batch \? "清空素材图" : "清空参考图"/);
|
||||||
|
assert.match(source, /clearReferenceRole\(node, "references"\)/);
|
||||||
|
assert.match(source, /clearReferenceRole\(node, "models"\)/);
|
||||||
assert.match(source, /\.o1ig-clear-refs\{/);
|
assert.match(source, /\.o1ig-clear-refs\{/);
|
||||||
assert.doesNotMatch(source, /o1ig-add[\s\S]{0,400}?addLabel\.textContent = "上传"/, "头部不再有上传按钮");
|
assert.doesNotMatch(source, /o1ig-add[\s\S]{0,400}?addLabel\.textContent = "上传"/, "头部不再有上传按钮");
|
||||||
assert.match(source, /upload\.addEventListener\("click", \(\) => requestReferenceUpload\(node, role\)\)/);
|
assert.match(source, /upload\.addEventListener\("click", \(\) => requestReferenceUpload\(node, role\)\)/);
|
||||||
|
|||||||
@@ -2299,37 +2299,57 @@ function renderReferences(node) {
|
|||||||
syncClearReferenceButtons(node);
|
syncClearReferenceButtons(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
function referenceListsAreEmpty(node) {
|
function referenceRoleIsEmpty(node, role = "references") {
|
||||||
|
if (role === "models") {
|
||||||
|
return !(
|
||||||
|
(node?._o1igModelReferences?.length || 0)
|
||||||
|
|| (node?._o1igModelPending?.length || 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
return !(
|
return !(
|
||||||
(node?._o1igReferences?.length || 0)
|
(node?._o1igReferences?.length || 0)
|
||||||
|| (node?._o1igPending?.length || 0)
|
|| (node?._o1igPending?.length || 0)
|
||||||
|| (node?._o1igModelReferences?.length || 0)
|
|
||||||
|| (node?._o1igModelPending?.length || 0)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function referenceListsAreEmpty(node) {
|
||||||
|
return referenceRoleIsEmpty(node, "references") && referenceRoleIsEmpty(node, "models");
|
||||||
|
}
|
||||||
|
|
||||||
function syncClearReferenceButtons(node) {
|
function syncClearReferenceButtons(node) {
|
||||||
const empty = referenceListsAreEmpty(node);
|
const batch = Boolean(node?._o1igBatchEnabled);
|
||||||
if (node?._o1igClearReferences) {
|
if (node?._o1igClearReferences) {
|
||||||
|
const empty = referenceRoleIsEmpty(node, "references");
|
||||||
|
const label = batch ? "清空素材图" : "清空参考图";
|
||||||
node._o1igClearReferences.disabled = empty;
|
node._o1igClearReferences.disabled = empty;
|
||||||
node._o1igClearReferences.title = empty ? "暂无参考图可清空" : "清空全部参考图与目标图";
|
const span = node._o1igClearReferences.children?.[0];
|
||||||
|
if (span) span.textContent = label;
|
||||||
|
node._o1igClearReferences.title = empty
|
||||||
|
? (batch ? "暂无素材图可清空" : "暂无参考图可清空")
|
||||||
|
: (batch ? "清空全部素材图" : "清空全部参考图");
|
||||||
}
|
}
|
||||||
if (node?._o1igClearModelReferences) {
|
if (node?._o1igClearModelReferences) {
|
||||||
|
const empty = referenceRoleIsEmpty(node, "models");
|
||||||
node._o1igClearModelReferences.disabled = empty;
|
node._o1igClearModelReferences.disabled = empty;
|
||||||
node._o1igClearModelReferences.title = empty ? "暂无图片可清空" : "清空全部素材图与目标图";
|
const span = node._o1igClearModelReferences.children?.[0];
|
||||||
|
if (span) span.textContent = "清空目标图";
|
||||||
|
node._o1igClearModelReferences.title = empty ? "暂无目标图可清空" : "清空全部目标图";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clear every reference image list the panel uses for generation (batch + non-batch). */
|
/** Clear one reference role list (素材/参考图 or 目标图). Mask stays untouched. */
|
||||||
function clearAllReferences(node) {
|
function clearReferenceRole(node, role = "references") {
|
||||||
if (!node || referenceListsAreEmpty(node)) return false;
|
if (!node || referenceRoleIsEmpty(node, role)) return false;
|
||||||
node._o1igReferences = [];
|
if (role === "models") {
|
||||||
node._o1igPending = [];
|
node._o1igModelReferences = [];
|
||||||
node._o1igModelReferences = [];
|
node._o1igModelPending = [];
|
||||||
node._o1igModelPending = [];
|
setWidgetValue(node, "模特图清单", "[]");
|
||||||
// Follow single-tile remove: mask stays on its own control.
|
} else {
|
||||||
setWidgetValue(node, "参考图清单", "[]");
|
node._o1igReferences = [];
|
||||||
setWidgetValue(node, "模特图清单", "[]");
|
node._o1igPending = [];
|
||||||
|
// Follow single-tile remove: mask stays on its own control.
|
||||||
|
setWidgetValue(node, "参考图清单", "[]");
|
||||||
|
}
|
||||||
renderReferences(node);
|
renderReferences(node);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5008,11 +5028,11 @@ function buildPanel(node) {
|
|||||||
const clearReferences = document.createElement("button");
|
const clearReferences = document.createElement("button");
|
||||||
clearReferences.type = "button";
|
clearReferences.type = "button";
|
||||||
clearReferences.className = "o1ig-clear-refs";
|
clearReferences.className = "o1ig-clear-refs";
|
||||||
clearReferences.title = "清空全部参考图与目标图";
|
clearReferences.title = "清空全部参考图";
|
||||||
const clearReferencesLabel = document.createElement("span");
|
const clearReferencesLabel = document.createElement("span");
|
||||||
clearReferencesLabel.textContent = "清空参考图";
|
clearReferencesLabel.textContent = "清空参考图";
|
||||||
clearReferences.append(clearReferencesLabel);
|
clearReferences.append(clearReferencesLabel);
|
||||||
clearReferences.addEventListener("click", () => clearAllReferences(node));
|
clearReferences.addEventListener("click", () => clearReferenceRole(node, "references"));
|
||||||
referenceActions.className = "o1ig-asset-actions";
|
referenceActions.className = "o1ig-asset-actions";
|
||||||
referenceActions.append(clearReferences, canvasPick);
|
referenceActions.append(clearReferences, canvasPick);
|
||||||
referenceHeader.append(referenceMeta, referenceActions);
|
referenceHeader.append(referenceMeta, referenceActions);
|
||||||
@@ -5060,11 +5080,11 @@ function buildPanel(node) {
|
|||||||
const clearModelReferences = document.createElement("button");
|
const clearModelReferences = document.createElement("button");
|
||||||
clearModelReferences.type = "button";
|
clearModelReferences.type = "button";
|
||||||
clearModelReferences.className = "o1ig-clear-refs";
|
clearModelReferences.className = "o1ig-clear-refs";
|
||||||
clearModelReferences.title = "清空全部素材图与目标图";
|
clearModelReferences.title = "清空全部目标图";
|
||||||
const clearModelReferencesLabel = document.createElement("span");
|
const clearModelReferencesLabel = document.createElement("span");
|
||||||
clearModelReferencesLabel.textContent = "清空";
|
clearModelReferencesLabel.textContent = "清空目标图";
|
||||||
clearModelReferences.append(clearModelReferencesLabel);
|
clearModelReferences.append(clearModelReferencesLabel);
|
||||||
clearModelReferences.addEventListener("click", () => clearAllReferences(node));
|
clearModelReferences.addEventListener("click", () => clearReferenceRole(node, "models"));
|
||||||
modelActions.className = "o1ig-asset-actions";
|
modelActions.className = "o1ig-asset-actions";
|
||||||
modelActions.append(clearModelReferences, modelCanvasPick);
|
modelActions.append(clearModelReferences, modelCanvasPick);
|
||||||
modelHeader.append(modelMeta, modelActions);
|
modelHeader.append(modelMeta, modelActions);
|
||||||
|
|||||||
Reference in New Issue
Block a user