프로젝트·임시 보관함·사용자 관리·가입 요청·회사 관리·시스템 로그 컨테이너는 자료가 쌓일수록 세로로 계속 길어져 페이지가 늘어난다. 4행 높이에서 자르고 나머지는 컨테이너 안에서 스크롤하게 했다. 행 높이를 상수로 박지 않았다. 프로젝트 표는 셀 안에 단계 막대가 들어가고 보관함 묶음은 접힘 상태에 따라 높이가 제각각이라 4 x 고정값으로는 어긋난다. limitVisibleRows()가 4번째 항목의 실제 아래쪽 좌표를 재서 max-height를 넣는다 — 표든 묶음이든 같은 코드로 맞는다. 항목이 4개 이하면 max-height를 지워 스크롤바를 만들지 않는다. 스크롤 중 어느 열인지 알아야 하므로 표 머리행은 sticky로 붙였다. 배경이 투명하면 아래 행이 비쳐 보여 불투명 배경도 함께 준다. 임시 보관함은 표가 아니라 묶음이 한 행이다. 묶음 안 파일 표는 접혀 있어 제외했다. 묶음을 펼치면 높이가 달라지므로 토글 핸들러에서 다시 잰다. 목록을 다시 그릴 때마다 resize 청취자가 쌓이던 문제는 WeakMap으로 이전 것을 걷어내고 다시 등록해 막았다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
153 lines
4.5 KiB
TypeScript
153 lines
4.5 KiB
TypeScript
import { createButton, createTag } from "@ui/ui_template_elements";
|
|
import {
|
|
processJoinRequest,
|
|
type CompanyInfo,
|
|
type DashboardUser,
|
|
type JoinRequest,
|
|
type Member,
|
|
} from "./B01_Dashboard_Api_Fetch";
|
|
import { canChangeRole, canDeleteUser } from "./B01_Dashboard_UI_Helper";
|
|
import {
|
|
openChangeRoleModal,
|
|
openCreateCompanyModal,
|
|
openDeleteUserModal,
|
|
openEditUserModal,
|
|
openFindCompanyModal,
|
|
} from "./B01_Dashboard_UI_Modals";
|
|
import type { DashboardState } from "./B01_Dashboard_UI_Page";
|
|
import { actionPair, table, text } from "@ui/ui_template_general_blocks";
|
|
import { DASHBOARD_VISIBLE_ROWS, formatDate, L, runRequest } from "./B01_Dashboard_UI_Common";
|
|
|
|
export function buildCompanyPanel(state: DashboardState): HTMLElement {
|
|
const wrap = document.createElement("div");
|
|
wrap.className = "b01-dashboard__actions";
|
|
if (!state.company) {
|
|
wrap.append(
|
|
createTag(L("B01_Dashboard_NoCompany"), "warning"),
|
|
createButton({
|
|
label: L("B01_Dashboard_CreateCompany"),
|
|
onClick: () => openCreateCompanyModal(),
|
|
}),
|
|
createButton({
|
|
label: L("B01_Dashboard_FindCompany"),
|
|
variant: "ghost",
|
|
onClick: () => openFindCompanyModal(),
|
|
}),
|
|
);
|
|
return wrap;
|
|
}
|
|
wrap.append(
|
|
createTag(`${state.company.name} (${state.user.status})`, "success"),
|
|
text(`${L("B01_Dashboard_Metric_ActiveUsers")}: ${state.company.user_count ?? 0}`),
|
|
text(`${L("B01_Dashboard_Projects")}: ${state.company.project_count ?? 0}`),
|
|
);
|
|
return wrap;
|
|
}
|
|
|
|
export function memberTable(members: Member[], currentUser: DashboardUser): HTMLElement {
|
|
return table(
|
|
[
|
|
L("B01_Dashboard_Table_Email"),
|
|
L("B01_Dashboard_Table_Name"),
|
|
L("B01_Dashboard_Table_Position"),
|
|
L("B01_Dashboard_Table_Department"),
|
|
L("B01_Dashboard_Table_Role"),
|
|
L("B01_Dashboard_Table_Action"),
|
|
],
|
|
members.map((member) => {
|
|
const actionsEl = document.createElement("div");
|
|
actionsEl.className = "b01-dashboard__actions";
|
|
|
|
actionsEl.append(
|
|
createButton({
|
|
label: L("Common_Btn_Edit"),
|
|
variant: "ghost",
|
|
onClick: () => openEditUserModal(currentUser, member),
|
|
}),
|
|
);
|
|
|
|
if (canChangeRole(currentUser, member)) {
|
|
actionsEl.append(
|
|
createButton({
|
|
label: L("B01_Dashboard_ChangeRole"),
|
|
variant: "ghost",
|
|
onClick: () => openChangeRoleModal(member),
|
|
}),
|
|
);
|
|
}
|
|
|
|
if (canDeleteUser(currentUser, member)) {
|
|
actionsEl.append(
|
|
createButton({
|
|
label: L("B01_Dashboard_RemoveMember"),
|
|
variant: "danger",
|
|
onClick: () => openDeleteUserModal(member),
|
|
}),
|
|
);
|
|
}
|
|
|
|
return [
|
|
text(member.email),
|
|
text(member.name),
|
|
text(member.position),
|
|
text(member.department),
|
|
text(member.role),
|
|
actionsEl,
|
|
];
|
|
}),
|
|
DASHBOARD_VISIBLE_ROWS,
|
|
);
|
|
}
|
|
|
|
export function joinRequestTable(requests: JoinRequest[], systemMode: boolean): HTMLElement {
|
|
return table(
|
|
[
|
|
L("B01_Dashboard_Table_Email"),
|
|
...(systemMode ? [L("B01_Dashboard_Table_Company")] : []),
|
|
L("B01_Dashboard_Table_Requested"),
|
|
L("B01_Dashboard_Table_Status"),
|
|
L("B01_Dashboard_Table_Action"),
|
|
],
|
|
requests.map((request) => [
|
|
text(request.user_email),
|
|
...(systemMode ? [text(request.company_name)] : []),
|
|
text(formatDate(request.requested_at)),
|
|
text(request.status),
|
|
actionPair(
|
|
() => onB01_JoinRequest_Process_Click(request.id, "APPROVE", systemMode),
|
|
() => onB01_JoinRequest_Process_Click(request.id, "REJECT", systemMode),
|
|
),
|
|
]),
|
|
DASHBOARD_VISIBLE_ROWS,
|
|
);
|
|
}
|
|
|
|
export function companyTable(companies: CompanyInfo[]): HTMLElement {
|
|
return table(
|
|
[
|
|
L("B01_Dashboard_Table_Company"),
|
|
L("B01_Dashboard_Field_BusinessNumber"),
|
|
L("B01_Dashboard_Table_Status"),
|
|
],
|
|
companies.map((company) => [
|
|
text(company.name),
|
|
text(company.business_registration_number),
|
|
text(company.business_status),
|
|
]),
|
|
DASHBOARD_VISIBLE_ROWS,
|
|
);
|
|
}
|
|
|
|
export async function onB01_JoinRequest_Process_Click(
|
|
requestId: number,
|
|
action: "APPROVE" | "REJECT",
|
|
systemMode: boolean,
|
|
): Promise<void> {
|
|
await runRequest(() =>
|
|
systemMode && action === "APPROVE"
|
|
? import("./B01_Dashboard_Api_Fetch").then((api) => api.systemApproveJoinRequest(requestId))
|
|
: processJoinRequest(requestId, action),
|
|
);
|
|
window.dispatchEvent(new HashChangeEvent("hashchange"));
|
|
}
|