손으로 정확히 쳐야만 되던 주소칸을 후보 검색·선택 방식으로 바꿈. VWorld 주소검색을 서버가 중계하고, 고른 즉시 좌표를 알므로 지도를 다시 찾지 않고 그림. 못 찾는 주소는 「직접 입력」으로 옛 방식을 씀. - 회사 목록 SQL 이 business_address·business_owner 를 안 가져와 수정 모달이 비어 열리고 저장 시 빈 값으로 덮어쓰던 것 수정 - 지도 기본 배율 15 → 17, +·- 단계 조절 추가 - 라벨·입력·버튼을 한 줄에 눕혀 줄 어긋남 해소 - 모달 안 휠이 뒤 대시보드로 새던 것 차단 - 회사 패널에 주소 한 줄 표시 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJC56e4osweKJ4vafm9ReM
221 lines
6.9 KiB
TypeScript
221 lines
6.9 KiB
TypeScript
import { createButton, createTag } from "@ui/ui_template_elements";
|
|
import {
|
|
fetchCompanyAssets,
|
|
processJoinRequest,
|
|
setCompanyLogo,
|
|
type CompanyInfo,
|
|
type DashboardUser,
|
|
type JoinRequest,
|
|
type Member,
|
|
} from "./B01_Dashboard_Api_Fetch";
|
|
import { createAssetField, openAssetPicker } from "./B01_Dashboard_UI_AssetPicker";
|
|
import { canChangeRole, canDeleteUser } from "./B01_Dashboard_UI_Helper";
|
|
import {
|
|
openChangeRoleModal,
|
|
openEditCompanyModal,
|
|
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}`),
|
|
// 저장한 주소가 화면에 안 보여 「저장이 안 된다」로 읽혔다 (2026-09-13 사용자 지시).
|
|
text(`${L("B01_Dashboard_Field_Address")}: ${state.company.business_address ?? "-"}`),
|
|
);
|
|
// 회사 정보 수정 (2026-09-06 사용자 지시) — 관리자만 보인다.
|
|
if (state.user.role !== "USER" && state.company) {
|
|
const company = state.company;
|
|
wrap.append(
|
|
createButton({
|
|
label: "회사 정보 수정",
|
|
variant: "ghost",
|
|
onClick: () => openEditCompanyModal(company),
|
|
}),
|
|
);
|
|
}
|
|
// 회사 대표 로고 — 등록 단계에서 받은 것을 여기서 바꾼다 (2026-09-02 사용자 확정).
|
|
// 프로젝트가 따로 고르지 않으면 도면이 이 로고를 쓴다.
|
|
if (state.user.role !== "USER") {
|
|
const company = state.company;
|
|
const slot = document.createElement("div");
|
|
void fetchCompanyAssets(company.id).then((assets) => {
|
|
slot.append(
|
|
createAssetField(
|
|
"회사 로고 (도면 표제란)",
|
|
"LOGO",
|
|
assets,
|
|
company.logo_asset_id ?? null,
|
|
company.id,
|
|
state.user,
|
|
{ onChange: (assetId) => setCompanyLogo(assetId, company.id).then(() => undefined) },
|
|
).root,
|
|
);
|
|
});
|
|
wrap.append(slot);
|
|
}
|
|
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[], user?: DashboardUser): HTMLElement {
|
|
// 로고는 회사 등록 단계에서 받고 여기서 바꾼다 (2026-09-02 사용자 확정).
|
|
const logoCell = (company: CompanyInfo): HTMLElement => {
|
|
if (!user) return text("");
|
|
const button = createButton({
|
|
label: company.logo_asset_id ? "로고 변경…" : "로고 지정…",
|
|
variant: "ghost",
|
|
onClick: () =>
|
|
void openAssetPicker(
|
|
"LOGO",
|
|
company.id,
|
|
user,
|
|
company.logo_asset_id ?? null,
|
|
async (id) => {
|
|
await setCompanyLogo(id, company.id);
|
|
company.logo_asset_id = id;
|
|
button.textContent = id ? "로고 변경…" : "로고 지정…";
|
|
},
|
|
),
|
|
});
|
|
return button;
|
|
};
|
|
return table(
|
|
[
|
|
L("B01_Dashboard_Table_Company"),
|
|
L("B01_Dashboard_Field_BusinessNumber"),
|
|
L("B01_Dashboard_Table_Status"),
|
|
"로고",
|
|
L("B01_Dashboard_Table_Action"),
|
|
],
|
|
companies.map((company) => [
|
|
text(company.name),
|
|
text(company.business_registration_number),
|
|
text(company.business_status),
|
|
logoCell(company),
|
|
user
|
|
? createButton({
|
|
label: L("Common_Btn_Edit"),
|
|
variant: "ghost",
|
|
onClick: () => openEditCompanyModal(company),
|
|
})
|
|
: text(""),
|
|
]),
|
|
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"));
|
|
}
|