Merge remote-tracking branch 'origin/dev' into sub_laptop_7
This commit is contained in:
@@ -233,6 +233,9 @@ export interface LibraryRow {
|
||||
이름: string;
|
||||
제목?: string | null;
|
||||
단위?: string | null;
|
||||
/** 단가승격 = 원 로직 것 · 사전조합 = 사용자가 고름(51-12) */
|
||||
구분?: string | null;
|
||||
상세구분?: string | null;
|
||||
}
|
||||
/** 서고 목록 — 그 층(주인) 단가승격 `promote` · 사전조합 `precombo` 문서 */
|
||||
export const fetchLibrary = async (
|
||||
|
||||
@@ -82,9 +82,12 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra
|
||||
(!detail.select.value || x.상세구분 === detail.select.value) &&
|
||||
(!q || `${x.키} ${x.이름}`.toLowerCase().includes(q)),
|
||||
);
|
||||
const libFound = sub.select.value
|
||||
? []
|
||||
: libRows.filter((x) => !q || `${x.row.이름} ${x.row.제목 ?? ""}`.toLowerCase().includes(q));
|
||||
const libFound = libRows.filter(
|
||||
(x) =>
|
||||
(!sub.select.value || x.row.구분 === sub.select.value) &&
|
||||
(!detail.select.value || x.row.상세구분 === detail.select.value) &&
|
||||
(!q || `${x.row.이름} ${x.row.제목 ?? ""}`.toLowerCase().includes(q)),
|
||||
);
|
||||
const total = all.length + libRows.length;
|
||||
const shown = found.length + libFound.length;
|
||||
finder.hint.textContent = loading
|
||||
@@ -110,7 +113,7 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra
|
||||
key: x.row.이름,
|
||||
tag: tc(x.kind),
|
||||
name: x.row.제목 || x.row.이름,
|
||||
sub: x.row.이름,
|
||||
sub: `${x.row.이름} · ${x.row.구분 ?? ""} ${x.row.상세구분 ?? ""}`.trim(),
|
||||
unit: x.row.단위 ?? "",
|
||||
onPick: () => {
|
||||
close();
|
||||
@@ -142,6 +145,7 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra
|
||||
showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error");
|
||||
}
|
||||
loading = false;
|
||||
drawSubs();
|
||||
find();
|
||||
};
|
||||
const drawLayers = (): void =>
|
||||
@@ -158,10 +162,28 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra
|
||||
}),
|
||||
),
|
||||
);
|
||||
sub.select.addEventListener("change", () => {
|
||||
const d = subs.find((s) => s.name === sub.select.value)?.details ?? [];
|
||||
detail.setOptions(opts(d), "");
|
||||
/** 구분 → 상세구분 — 로직 구분에 서고 줄(승격 · 조합) 것을 더함 · 같은 값은 한 칸 */
|
||||
const subMap = (): Map<string, Set<string>> => {
|
||||
const m = new Map(subs.map((s) => [s.name, new Set(s.details)]));
|
||||
for (const { row } of libRows) {
|
||||
if (!row.구분) continue;
|
||||
if (!m.has(row.구분)) m.set(row.구분, new Set());
|
||||
if (row.상세구분) m.get(row.구분)!.add(row.상세구분);
|
||||
}
|
||||
return m;
|
||||
};
|
||||
const drawDetails = (keep: string): void => {
|
||||
const d = [...(subMap().get(sub.select.value) ?? [])];
|
||||
detail.setOptions(opts(d), d.includes(keep) ? keep : "");
|
||||
detail.select.disabled = d.length === 0;
|
||||
};
|
||||
const drawSubs = (): void => {
|
||||
const keep = detail.select.value;
|
||||
sub.setOptions(opts([...subMap().keys()]), sub.select.value);
|
||||
drawDetails(keep);
|
||||
};
|
||||
sub.select.addEventListener("change", () => {
|
||||
drawDetails("");
|
||||
find();
|
||||
});
|
||||
detail.select.addEventListener("change", find);
|
||||
@@ -202,8 +224,8 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra
|
||||
.then(([s, l]) => {
|
||||
subs.push(...s);
|
||||
all = l;
|
||||
drawSubs();
|
||||
find();
|
||||
sub.setOptions(opts(s.map((x) => x.name)), "");
|
||||
})
|
||||
.catch((error) =>
|
||||
showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"),
|
||||
|
||||
Reference in New Issue
Block a user