feat(b09): 좌측 하단 고정 줄 — [박스보기|호표보기] 한 설정(묶음 탭 셋 · 옛 탭별 값 하나로 · 탭 줄 토글 걷음) · [하이퍼링크|팝업] 스위치(pref global · 기본 팝업) · DRAFT.actions 자리 · [?][저장][내역 초기화] 그대로 (303-1 · 304-1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
"""304-1 B09 박스보기 · 호표보기 = 좌측 하단 한 설정(묶음 탭 셋 함께).
|
||||
|
||||
- 한 값(`b09-group-view` · pref global)이 dg · machine_blocks · sg 셋에 함께 · 기본 = 박스(카드)
|
||||
- 옛 탭별 값(`{탭: 보기}`) = 첫 읽기에 한 값으로(dg · 없으면 다른 탭 · 없으면 기본) 옮겨 적음
|
||||
- 보조 탭 줄 보기 토글 걷음 · 가로 열 수 단추(박스 보기)는 그대로
|
||||
- 좌측 하단 스위치 [박스보기|호표보기] 누름 = 값 바꿈 · 다시 그림 부름
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from resources.tester.helper_b09_group_cards import COMMON, GROUPS, RAW, TABS, run # noqa: E402
|
||||
|
||||
LABOR = "B09_Estimation/B09_Estimation_UI_Tabs_Labor.ts"
|
||||
DOCK = "B09_Estimation/B09_Estimation_UI_Dock.ts"
|
||||
DG = {"id": "DG1", "no": 1, "name": "찰쌓기", "unit": "m2", "lines": [], "sum": 0}
|
||||
SPEC = (
|
||||
"\nconst spec = buildDaegaBlocks({ sheets: { daega_blocks: ["
|
||||
+ json.dumps(DG, ensure_ascii=False)
|
||||
+ "] } });"
|
||||
"\nconst tools = [];"
|
||||
"\nconst draw = (tab) => renderGroupPanel({ tab, spec, hint: null, goto: () => {},"
|
||||
" setTools: (t) => tools.push(...t),"
|
||||
" makeTable: () => ({ root: document.createElement('table'), focusRow: () => {} }) })[0];"
|
||||
"\nconst kinds = () => ['dg', 'machine_blocks', 'sg'].map((t) => draw(t).tagName);"
|
||||
)
|
||||
|
||||
|
||||
def test_한_설정_셋_탭_함께():
|
||||
out = run(
|
||||
[COMMON, TABS, LABOR, GROUPS],
|
||||
SPEC + "\nconst a = kinds();"
|
||||
"\nchooseGroupView('table');"
|
||||
"\nconst b = kinds();"
|
||||
"\nconsole.log(JSON.stringify({ a, b, kept: Object.fromEntries(kept),"
|
||||
" toggles: tools.filter((e) => e.dataset.b09GroupView).length,"
|
||||
" cols: tools.flatMap((e) => e.all('[data-group-cols]')).length }));",
|
||||
RAW,
|
||||
)
|
||||
assert out["a"] == ["DIV"] * 3 # 기본 = 박스
|
||||
assert out["b"] == ["TABLE"] * 3 # 한 값이 셋 탭 함께
|
||||
assert json.loads(out["kept"]["b09-group-view"]) == "table"
|
||||
assert out["toggles"] == 0 # 탭 줄 보기 토글 없음
|
||||
assert out["cols"] == 4 * 3 # 박스 보기 가로 열 수 단추 = 탭 줄 그대로
|
||||
|
||||
|
||||
def test_옛_탭별_값_첫_읽기에_한_값으로():
|
||||
cases = [
|
||||
({"dg": "table", "sg": "cards"}, "table"),
|
||||
({"dg": "cards", "sg": "table"}, "cards"), # dg 먼저
|
||||
({"sg": "table"}, "table"), # dg 없으면 다른 탭
|
||||
({"machine_blocks": "table", "sg": "cards"}, "table"),
|
||||
({}, "cards"), # 없으면 기본
|
||||
]
|
||||
for old, want in cases:
|
||||
out = run(
|
||||
[COMMON, TABS, LABOR, GROUPS],
|
||||
"\nkept.set('b09-group-view', "
|
||||
+ json.dumps(json.dumps(old))
|
||||
+ ");"
|
||||
+ SPEC
|
||||
+ "\nconst got = kinds();"
|
||||
"\nconsole.log(JSON.stringify({ got, kept: Object.fromEntries(kept) }));",
|
||||
RAW,
|
||||
)
|
||||
assert out["got"] == ["TABLE" if want == "table" else "DIV"] * 3, old
|
||||
assert json.loads(out["kept"]["b09-group-view"]) == want, old # 옮겨 적음
|
||||
|
||||
|
||||
def test_좌측_스위치_누름():
|
||||
out = run(
|
||||
[COMMON, TABS, GROUPS, DOCK],
|
||||
"\nlet redraws = 0;"
|
||||
"\nconst dock = createDock([document.createElement('button')], () => redraws++);"
|
||||
"\nconst row = dock.children[0];"
|
||||
"\nconst pressed = () => row.children.map((b) => b.attrs['aria-pressed']);"
|
||||
"\nconst labels = row.children.map((b) => b.textContent);"
|
||||
"\nconst a = pressed();"
|
||||
"\nrow.children[0].click();" # 이미 박스 = 그대로
|
||||
"\nconst b = [redraws, pressed()];"
|
||||
"\nrow.children[1].click();"
|
||||
"\nconsole.log(JSON.stringify({ name: row.dataset.b09Switch, labels, a, b, c: [redraws, pressed()],"
|
||||
" view: groupView(), kept: Object.fromEntries(kept) }));",
|
||||
)
|
||||
assert out["name"] == "view" and out["labels"] == ["박스보기", "호표보기"]
|
||||
assert out["a"] == ["true", "false"] # 기본 = 박스보기
|
||||
assert out["b"] == [0, ["true", "false"]]
|
||||
assert out["c"] == [1, ["false", "true"]] and out["view"] == "table"
|
||||
assert json.loads(out["kept"]["b09-group-view"]) == "table" # [저장] 없이 pref
|
||||
|
||||
|
||||
def test_잇기():
|
||||
groups = (ROOT / GROUPS).read_text("utf-8")
|
||||
assert "toggle" not in groups and "redraw" not in groups and "createButton" not in groups
|
||||
shell = (ROOT / "B09_Estimation/B09_Estimation_UI_Shell.ts").read_text("utf-8")
|
||||
assert "createDock([save, reset], () => isGroupTab(current) && show(current))" in shell
|
||||
state = (ROOT / "A00_Common/b_page_state.ts").read_text("utf-8")
|
||||
assert '"b09-group-view": { bucket: "pref", scope: "global" },' in state
|
||||
Reference in New Issue
Block a user