Merge remote-tracking branch 'origin/sub_laptop_4' into sub_laptop_7

This commit is contained in:
2026-09-28 22:25:52 +09:00
5 changed files with 59 additions and 20 deletions
@@ -40,6 +40,8 @@ const TEXT = {
apply: "적용",
undo: "되돌리기",
empty: "담은 자재가 없음",
noItems: "담은 자재가 없어 적용 안 됨 — 자재를 하나 이상 담음",
already: "이미 담은 자재 — {value}",
unlinkAsk: "{value} 자재는 {cell} 칸에 이어져 있음 — 빼면 연결도 풂",
unlinkOk: "빼고 연결 풂",
loadFailed: "자재 조합을 못 읽음 — {value}",
@@ -233,7 +235,7 @@ export function buildMaterialPanel(opts: MaterialPanelOptions): MaterialPanel {
)
return;
items.splice(i, 1);
removed.push(m.코드);
if (cells.length) opts.unlink([m.코드]); // 확인 글대로 바로 풂(알약 막대 「목록에서 빼기」와 같음)
paint();
opts.onChange(items);
});
@@ -257,16 +259,14 @@ export function buildMaterialPanel(opts: MaterialPanelOptions): MaterialPanel {
paintToggle();
};
/** 이번에 뺀 자재 코드 — 적용하면 이은 칸 연결도 풂 */
let removed: string[] = [];
const paintFoot = (): void => {
if (!opts.isAdmin) return foot.replaceChildren();
const add = createButton({ label: TEXT.add, variant: "ghost", size: "sm" });
add.addEventListener("click", () =>
pickMaterial((m) => {
if (items.some((x) => x.코드 === m.코드)) return;
if (items.some((x) => x.코드 === m.코드))
return showToast(fill(TEXT.already, { value: m.코드 }), "info");
items.push(m);
removed = removed.filter((c) => c !== m.코드);
paint();
opts.onChange(items);
}),
@@ -275,6 +275,7 @@ export function buildMaterialPanel(opts: MaterialPanelOptions): MaterialPanel {
if (sig(items) !== sig(saved)) {
const apply = createButton({ label: TEXT.apply, variant: "filled", size: "sm" });
apply.addEventListener("click", async () => {
if (!items.length) return showToast(TEXT.noItems, "error");
const message = !key
? TEXT.askFirst
: others
@@ -290,8 +291,6 @@ export function buildMaterialPanel(opts: MaterialPanelOptions): MaterialPanel {
이름: name,
});
branchToast(result);
if (removed.length) opts.unlink(removed);
removed = [];
key = result.키;
others = 0;
combo = await fetchMaterialCombo(key).catch(() => null);
@@ -306,7 +305,6 @@ export function buildMaterialPanel(opts: MaterialPanelOptions): MaterialPanel {
const undo = createButton({ label: TEXT.undo, variant: "ghost", size: "sm" });
undo.addEventListener("click", () => {
items = [...saved];
removed = [];
paint();
opts.onChange(items);
});