feat(project): add cell moves and width menus
This commit is contained in:
@@ -145,6 +145,17 @@ function mockAutoFitLayout(env) {
|
||||
return measured;
|
||||
}
|
||||
|
||||
function beginGoalMove(env, source, target) {
|
||||
const td = source.closest("td");
|
||||
td.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 10, clientY: 10 }));
|
||||
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
|
||||
const edge = td.querySelector('.pj-goal-move-edge[data-edge="bottom"]');
|
||||
edge.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 20, clientY: 20 }));
|
||||
env.d.elementFromPoint = function () { return target; };
|
||||
env.d.dispatchEvent(new env.w.MouseEvent("mousemove", { bubbles: true, clientX: 300, clientY: 200 }));
|
||||
return function () { env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true, clientX: 300, clientY: 200 })); };
|
||||
}
|
||||
|
||||
// ── 가짜 서버 — 목표 표(글 칸 상태를 기억해 화면 GET 에 반영) ───────────────
|
||||
function goalsServer(env, st) {
|
||||
st = Object.assign({ cells: {}, areaAdded: false, cellHook: null, metricHook: null, getHook: null }, st || {});
|
||||
@@ -182,6 +193,13 @@ function goalsServer(env, st) {
|
||||
}
|
||||
return { text: html };
|
||||
});
|
||||
env.route("POST", new RegExp("/project/api/goals/cells/move$"), async function (u, body, call) {
|
||||
st.moves = (st.moves || 0) + 1;
|
||||
if (st.moveHook) { const result = await st.moveHook(body, call); if (result) return result; }
|
||||
st.cells[body.source_row + ":" + body.source_month] = "";
|
||||
st.cells[body.target_row + ":" + body.target_month] = body.body;
|
||||
return { body: { ok: true, body: body.body } };
|
||||
});
|
||||
return st;
|
||||
}
|
||||
|
||||
@@ -581,7 +599,7 @@ function meetServer(env, st) {
|
||||
check("[8] 보기 전용: 메뉴 버튼·이름 편집 없음", !env.d.querySelector(".pj-goal-menu-btn") && !env.d.querySelector("[data-goal-edit]"));
|
||||
const th = env.d.querySelector("th.pj-goal-area-name");
|
||||
th.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true }));
|
||||
check("[8] 보기 전용: 우클릭 편집 메뉴 없음", !env.d.querySelector(".pj-ctxmenu"));
|
||||
check("[8] 보기 전용: 우클릭은 너비 맞춤만 제공", Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel).join("|") === "현재 열 너비 자동 맞춤|전체 열 너비 자동 맞춤");
|
||||
// 분기 접기는 보기 전용도
|
||||
const qth = env.d.querySelector('th.pj-goal-fold-th[data-h="1"]');
|
||||
qth.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true }));
|
||||
@@ -669,6 +687,76 @@ function meetServer(env, st) {
|
||||
check("[자동 너비] 보기 전용도 내용 맞춤 가능·쓰기 요청 없음", restored.d.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "95px" && !restored.calls.some(function (c) { return c.method !== "GET"; }));
|
||||
});
|
||||
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.goals_admin, GOALS_URL); goalsServer(env); await boot(env); mockAutoFitLayout(env);
|
||||
const table = env.d.getElementById("pj-goal-table"), editor = table.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
|
||||
editor.value = "길게".repeat(25);
|
||||
function menu(cell) { cell.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true })); }
|
||||
function action(label) { return Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === label; }); }
|
||||
menu(editor);
|
||||
check("[너비 메뉴] 기존 내용 지우기·현재 열·전체 열 맞춤 함께 표시", !!action("내용 지우기 (Del)") && !!action("현재 열 너비 자동 맞춤") && !!action("전체 열 너비 자동 맞춤"));
|
||||
action("현재 열 너비 자동 맞춤").click();
|
||||
check("[너비 메뉴] 현재 열만 맞춤", table.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "515px" && table.querySelector('thead th[data-col="m2"]').style.getPropertyValue("--cw") === "85px");
|
||||
table.querySelector('thead th[data-col="q1"]').click();
|
||||
menu(table.querySelector('thead th[data-col="y"]')); action("전체 열 너비 자동 맞춤").click();
|
||||
check("[너비 메뉴] 머리에서도 전체 맞춤·접힌 열 포함·저장", table.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "515px" && table.querySelector('thead th[data-col="q1"]').classList.contains("is-folded") && JSON.parse(env.w.localStorage.getItem("pj_goal_col_w")).m1 === 515);
|
||||
menu(table.querySelector("th.pj-goal-area-name"));
|
||||
check("[너비 메뉴] 구역 이름 편집 메뉴에도 맞춤 제공", !!action("색 바꾸기") && !!action("현재 열 너비 자동 맞춤"));
|
||||
});
|
||||
await section(async function () {
|
||||
const gate = deferred(), env = makeEnv(PAGE.goals_admin, GOALS_URL);
|
||||
const st = goalsServer(env, { moveHook: async function (body) { await gate.promise; return { body: { ok: true, body: body.body } }; } });
|
||||
await boot(env);
|
||||
const source = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]'), target = env.d.querySelector('.pj-goal-text[data-row="11"][data-month="2"]');
|
||||
type(env, source, "pj-rich:v1:" + JSON.stringify([{ text: "이동할 글", color: "#ff0000", size: 24, bold: true, italic: true, underline: true }]));
|
||||
const original = source.value;
|
||||
const drop = beginGoalMove(env, source, target);
|
||||
check("[셀 이동] 대상 미리보기·일반 범위 선택과 분리", target.closest("td").classList.contains("is-goal-move-target") && env.d.documentElement.classList.contains("pj-goal-moving"));
|
||||
drop(); await settle();
|
||||
check("[셀 이동] 먼저 초안 저장·이동은 한 번·응답 전 원본 유지", st.moves === 1 && source.value === original && target.value === "" && source.getAttribute("contenteditable") === "false" && target.getAttribute("contenteditable") === "false");
|
||||
const moveIndex = env.calls.findIndex(function (c) { return /cells\/move$/.test(c.url); });
|
||||
check("[셀 이동] 글 PUT 뒤 원자적 이동 API", moveIndex > env.calls.findIndex(function (c) { return c.method === "PUT" && /rows\/10\/cells\/1$/.test(c.url); }));
|
||||
gate.resolve(); await settle();
|
||||
const run = JSON.parse(target.value.slice(11))[0];
|
||||
check("[셀 이동] 성공 뒤 원본 비우기·대상 글과 모든 서식 보존", source.value === "" && run.text === "이동할 글" && run.color === "#ff0000" && run.size === 24 && run.bold && run.italic && run.underline);
|
||||
const count = env.calls.length; fire(env, source, "blur"); fire(env, target, "blur"); await settle();
|
||||
check("[셀 이동] 저장 기준값·초안 정리·후속 blur 중복 저장 없음", env.calls.length === count && !env.w.localStorage.getItem("pj_draft:goal:10:1") && source.getAttribute("contenteditable") === "true" && target.closest("td").classList.contains("is-goal-active"));
|
||||
});
|
||||
for (const failure of ["network", "conflict", "save"]) await section(async function () {
|
||||
const env = makeEnv(PAGE.goals_admin, GOALS_URL);
|
||||
const st = goalsServer(env, { moveHook: function () { return failure === "network" ? "NETWORK" : { status: 409, body: { detail: "다른 창에서 수정" } }; },
|
||||
cellHook: failure === "save" ? function () { return { status: 503, body: { detail: "저장 장애" } }; } : null });
|
||||
await boot(env);
|
||||
const source = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]'), target = env.d.querySelector('.pj-goal-text[data-row="11"][data-month="2"]');
|
||||
if (failure === "save") type(env, source, "미저장 초안");
|
||||
const before = source.value; beginGoalMove(env, source, target)(); await settle();
|
||||
check("[셀 이동 " + failure + "] 실패해도 양쪽 내용·편집 가능 상태 유지", source.value === before && target.value === "" && source.getAttribute("contenteditable") === "true" && !env.d.documentElement.classList.contains("pj-goal-moving"));
|
||||
check("[셀 이동 " + failure + "] 저장 실패면 이동 API 생략", failure !== "save" || !st.moves);
|
||||
});
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.goals_admin, GOALS_URL), st = goalsServer(env); await boot(env);
|
||||
const source = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]'), target = env.d.querySelector('.pj-goal-text[data-row="11"][data-month="2"]');
|
||||
target.value = "대상 기존 글"; let confirmations = 0;
|
||||
env.w.erpConfirm = function () { confirmations++; return Promise.resolve(false); };
|
||||
beginGoalMove(env, source, target)(); await settle();
|
||||
check("[셀 이동] 덮어쓰기 취소는 두 내용 유지·이동 없음", confirmations === 1 && !st.moves && source.value === "original" && target.value === "대상 기존 글");
|
||||
env.w.erpConfirm = function () { return Promise.resolve(true); };
|
||||
beginGoalMove(env, source, target)(); await settle();
|
||||
check("[셀 이동] 확인 뒤 덮어쓰기·원본 비우기", st.moves === 1 && source.value === "" && target.textContent === "original");
|
||||
});
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.goals_admin, GOALS_URL), st = goalsServer(env); await boot(env);
|
||||
const source = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]'), target = env.d.querySelector('.pj-goal-text[data-row="11"][data-month="2"]');
|
||||
beginGoalMove(env, source, target); key(env, env.d, "Escape"); await settle();
|
||||
check("[셀 이동] Esc 취소는 원본 유지·이동 요청 없음", !st.moves && source.value === "original" && !env.d.documentElement.classList.contains("pj-goal-moving"));
|
||||
beginGoalMove(env, source, target); env.w.dispatchEvent(new env.w.Event("blur")); await settle();
|
||||
check("[셀 이동] 창 포커스 이탈도 이동 취소·드래그 정리", !st.moves && !env.d.querySelector(".is-goal-move-target"));
|
||||
beginGoalMove(env, source, source)(); await settle();
|
||||
check("[셀 이동] 자기 셀에 놓기 = 변경 없음", !st.moves && source.value === "original");
|
||||
const ro = makeEnv(PAGE.goals_ro, GOALS_URL); goalsServer(ro); await boot(ro);
|
||||
check("[셀 이동] 보기 전용에는 이동 테두리 없음", !ro.d.querySelector(".pj-goal-move-edge"));
|
||||
});
|
||||
|
||||
// ════════════════════ [9] 매출 자동 갱신 — 정상 조용히 · 실패/일부 실패 안내 + 재시도 · 권한 없음 ════════════════════
|
||||
await section(async function () {
|
||||
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
|
||||
|
||||
Reference in New Issue
Block a user