Files
MajoorWaldi-ComfyUI-Majoor-…/js/features/collections/contextmenu/addToCollectionMenu.js
T
MajoorWaldi 2fa41a0e76 feat: add useGridState and useVirtualGrid composables for asset management
- Implemented useGridState to manage grid state, including asset selection and loading states.
- Created useVirtualGrid to centralize virtualization helpers for improved performance.
- Added createVueApp for isolated Vue 3 + Pinia application instances.
- Introduced Vite configuration for building the ComfyUI-Majoor-AssetsManager with external dependencies.
2026-04-03 11:04:55 +02:00

33 lines
1.0 KiB
JavaScript

import { comfyToast } from "../../../app/toast.js";
import { t } from "../../../app/i18n.js";
import { pickRootId } from "../../../utils/ids.js";
import { openAddToCollectionMenu } from "./addToCollectionMenuState.js";
function simplifyAsset(a) {
if (!a || typeof a !== "object") return null;
const filepath = a.filepath || a.path || a?.file_info?.filepath || "";
if (!filepath) return null;
return {
filepath,
filename: a.filename || "",
subfolder: a.subfolder || "",
type: (a.type || "output").toLowerCase(),
root_id: pickRootId(a),
kind: a.kind || "",
};
}
export async function showAddToCollectionMenu({ x, y, assets }) {
const selected = Array.isArray(assets) ? assets.map(simplifyAsset).filter(Boolean) : [];
if (!selected.length) {
comfyToast(t("toast.noValidAssetsSelected", "No valid assets selected."), "warning");
return;
}
openAddToCollectionMenu({
x: Number(x) || 0,
y: Number(y) || 0,
assets: selected,
});
}