Merge remote-tracking branch 'origin/sub_desktop_1' into sub_laptop_6
This commit is contained in:
@@ -138,6 +138,12 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 이동해 온 줄(PLAN 144 · focusRow) */
|
||||
.ui-data-table__table tbody tr.is-focus td {
|
||||
background: var(--dt-hover);
|
||||
box-shadow: inset 0 -2px 0 var(--color-accent);
|
||||
}
|
||||
|
||||
/* 고칠 칸(PLAN 121) — 칸 가득 글 상자 · 숫자 오른쪽 맞춤 */
|
||||
.ui-data-table__table td.is-edit {
|
||||
padding: 0;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* host.append(t.root); t.setRows(rows2, total2);
|
||||
* 열 = { key: "cut_soil_area", label: "단면적", group: ["절토", "토사"], kind: "number", decimals: 2 }
|
||||
* 고칠 칸(PLAN 121) = editable(줄, 열) 참인 칸만 글 상자 · 바꾸면 onEdit(줄, 열, 글) — 다시 그려도 커서 자리 지킴
|
||||
* 칸 누름(PLAN 144) = onCellClick(줄, 열) · 줄로 이동 = t.focusRow(줄)(스크롤 + 강조)
|
||||
* ========================================================================== */
|
||||
|
||||
import "./ui_template_data_table.css";
|
||||
@@ -48,6 +49,10 @@ export interface DataTableOptions {
|
||||
empty?: string;
|
||||
/** 줄 누름(본문 줄만 · 합계 제외) — 주면 줄에 `data-i`(줄 번호)·`is-clickable` 이 붙음 */
|
||||
onRowClick?: (index: number) => void;
|
||||
/** 칸 누름(본문 줄만) — 주면 줄에 `data-i`·`is-clickable` 이 붙음 · 줄 누름보다 먼저 부름 */
|
||||
onCellClick?: (index: number, key: string) => void;
|
||||
/** 강조할 줄(`focusRow` 가 정함) */
|
||||
focus?: number | null;
|
||||
/** 고칠 칸인지(본문 줄만 · 합계 제외) — 참이면 칸이 글 상자 */
|
||||
editable?: (index: number, key: string) => boolean;
|
||||
/** 고친 칸 글(바꾼 뒤 · 커서가 옮겨 간 다음에 부름) */
|
||||
@@ -57,6 +62,8 @@ export interface DataTableOptions {
|
||||
export interface DataTable {
|
||||
root: HTMLElement;
|
||||
setRows: (rows: DataRow[], total?: DataRow | null) => void;
|
||||
/** 그 줄로 스크롤하고 강조 */
|
||||
focusRow: (index: number) => void;
|
||||
}
|
||||
|
||||
const EMPTY = "-";
|
||||
@@ -124,6 +131,7 @@ function rowHtml(
|
||||
index: number | null = null,
|
||||
edit: number | null = null,
|
||||
editable?: (index: number, key: string) => boolean,
|
||||
focus = false,
|
||||
): string {
|
||||
let tr = "";
|
||||
for (let j = 0; j < cols.length; j++) {
|
||||
@@ -146,7 +154,9 @@ function rowHtml(
|
||||
(fmts[j] ? ' data-num=""' : "");
|
||||
tr += `<td${attrs}>${esc(txt)}</td>`;
|
||||
}
|
||||
const cls = [alt && "is-alt", index !== null && "is-clickable"].filter(Boolean).join(" ");
|
||||
const cls = [alt && "is-alt", index !== null && "is-clickable", focus && "is-focus"]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
const data = index !== null ? ` data-i="${index}"` : "";
|
||||
return cls || data ? `<tr${cls ? ` class="${cls}"` : ""}${data}>${tr}</tr>` : `<tr>${tr}</tr>`;
|
||||
}
|
||||
@@ -185,7 +195,7 @@ export function renderDataTableHtml(o: DataTableOptions, win?: RowWindow): strin
|
||||
const to = win ? Math.max(from, Math.min(win.to, n)) : n;
|
||||
let body = win ? pad(from * win.rowH, cols.length) : "";
|
||||
const blank = o.empty ?? EMPTY;
|
||||
const pick = o.onRowClick !== undefined;
|
||||
const pick = o.onRowClick !== undefined || o.onCellClick !== undefined;
|
||||
for (let i = from; i < to; i++)
|
||||
body += rowHtml(
|
||||
cols,
|
||||
@@ -197,6 +207,7 @@ export function renderDataTableHtml(o: DataTableOptions, win?: RowWindow): strin
|
||||
pick ? i : null,
|
||||
i,
|
||||
o.editable,
|
||||
o.focus === i,
|
||||
);
|
||||
if (win) body += pad((n - to) * win.rowH, cols.length);
|
||||
const foot = o.total ? `<tfoot>${rowHtml(cols, fmts, left, o.total, false, blank)}</tfoot>` : "";
|
||||
@@ -250,7 +261,11 @@ export function createDataTable(opts: DataTableOptions): DataTable {
|
||||
});
|
||||
root.addEventListener("click", (event) => {
|
||||
const row = (event.target as Element).closest<HTMLElement>("tr[data-i]");
|
||||
if (row && root.contains(row)) state.onRowClick?.(Number(row.dataset.i));
|
||||
if (!row || !root.contains(row)) return;
|
||||
const cell = (event.target as Element).closest<HTMLTableCellElement>("td");
|
||||
const column = cell ? state.columns[cell.cellIndex] : undefined;
|
||||
if (column) state.onCellClick?.(Number(row.dataset.i), column.key);
|
||||
state.onRowClick?.(Number(row.dataset.i));
|
||||
});
|
||||
draw(true);
|
||||
return {
|
||||
@@ -260,5 +275,10 @@ export function createDataTable(opts: DataTableOptions): DataTable {
|
||||
if (total !== undefined) state.total = total;
|
||||
draw(true);
|
||||
},
|
||||
focusRow(index) {
|
||||
state.focus = index;
|
||||
root.scrollTop = Math.max(0, index * win.rowH - root.clientHeight / 3);
|
||||
draw(true);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ export const ui_locales_b4 = {
|
||||
B08_Quantity_Tab_MaterialQuantity: ["자재수량집계표", "Material Quantity Table"],
|
||||
B08_Quantity_Sheets_Title: ["구조물도", "Structure Sheets"],
|
||||
B08_Quantity_Sheets_FromCopy: ["프로젝트 복사본", "Project copy"],
|
||||
B08_Quantity_Sheets_FromMaster: ["M02 원본", "M02 original"],
|
||||
B08_Quantity_Sheets_NoCopy: ["복사본에 없음", "Not in the project copy"],
|
||||
B08_Quantity_Drawing_Loading: ["구조물도를 불러오는 중…", "Loading structure sheets…"],
|
||||
B08_Quantity_Drawing_Failed: [
|
||||
@@ -36,15 +35,15 @@ export const ui_locales_b4 = {
|
||||
"Failed to load structure sheets",
|
||||
],
|
||||
B08_Quantity_Drawing_Missing: [
|
||||
"M02 에 없는 조합입니다 — 도면 · 면적산출을 보일 수 없습니다.",
|
||||
"This combination is not in M02 — no drawing or area sheet to show.",
|
||||
"사본 없음 — B05 · B06 좌측 패널에서 조합 연결 · [저장] 뒤 보입니다.",
|
||||
"No project copy — link the combination in the B05 · B06 panel and save.",
|
||||
],
|
||||
B08_Quantity_Drawing_NoDrawing: [
|
||||
"이 조합은 도면이 없습니다 — M02 구조물 조합에서 그립니다.",
|
||||
"This combination has no drawing — draw it in M02 structure combinations.",
|
||||
"이 조합 사본은 도면이 없습니다 — M02 구조물 조합에서 그린 뒤 [재적용].",
|
||||
"This copy has no drawing — draw it in M02 structure combinations, then reapply.",
|
||||
],
|
||||
B08_Quantity_Summary_Station: ["측점", "Station"],
|
||||
B08_Quantity_Summary_MissingGroup: ["M02 에 없음", "Not in M02"],
|
||||
B08_Quantity_Summary_MissingGroup: ["경로 없음", "No path"],
|
||||
B08_Quantity_Summary_Loading: ["구조물 집계표를 불러오는 중…", "Loading the structure summary…"],
|
||||
B08_Quantity_Summary_Failed: [
|
||||
"구조물 집계표를 불러오지 못했습니다",
|
||||
|
||||
Reference in New Issue
Block a user