feat(M02): 가져올 곳 탭 readableSources · 회사 맡음 manages — 복사 생성 · 복사해 가져오기 탭 목록(39-6 E5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013rJwJMVL4EE31y77TB11AP
This commit is contained in:
@@ -93,6 +93,78 @@ export function accessFor(
|
||||
return { canWrite: layer === "personal" || companyAdmin, needCompany: false };
|
||||
}
|
||||
|
||||
/** 회사 C 를 맡음 — 시스템 관리자 · 또는 C 의 회사 관리자(서버 `M02_Layer_Access.manages` 짝 · 39-6) */
|
||||
export function manages(company: string | null, user: SessionUser | null): boolean {
|
||||
if (!company || !user) return false;
|
||||
if (user.role === "SYSTEM_ADMIN") return true;
|
||||
const companyAdmin = user.role === "ADMIN" || !!user.is_master;
|
||||
return companyAdmin && company === ownOwner("company", user);
|
||||
}
|
||||
|
||||
/** 가져올 곳 탭 하나 — `people` = 다른 사람(주인은 부르는 쪽이 `fetchOwners` 로 고름) */
|
||||
export interface Source {
|
||||
id: "master" | "company" | "personal" | "people" | "practice";
|
||||
layer: ManageLayer;
|
||||
/** 층 주인 — 자기 층 · 마스터 · 실무문서 · 다른 사람 = null */
|
||||
owner: string | null;
|
||||
label: string;
|
||||
}
|
||||
|
||||
/** 복사 생성 · 복사해 가져오기의 탭(39-6 · 답 2) — 읽을 수 있는 곳 + 기본 탭.
|
||||
* 기본 = 시스템 관리자 마스터 · 그 밖 내 개인(회사 없으면 마스터) · `practice` = 일위대가 고를 때만 */
|
||||
export function readableSources(
|
||||
user: SessionUser | null,
|
||||
company: string | null,
|
||||
opt: { practice?: boolean } = {},
|
||||
): { tabs: Source[]; first: Source["id"] } {
|
||||
const isSystem = user?.role === "SYSTEM_ADMIN";
|
||||
const own = ownOwner("personal", user);
|
||||
const tabs: Source[] = [
|
||||
{ id: "master", layer: "system", owner: null, label: L("M02_PickerSystem") },
|
||||
...(company
|
||||
? [
|
||||
{
|
||||
id: "company" as const,
|
||||
layer: "company" as const,
|
||||
owner: company === ownOwner("company", user) ? null : company,
|
||||
label: L("M02_PickerCompany"),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(own
|
||||
? [
|
||||
{
|
||||
id: "personal" as const,
|
||||
layer: "personal" as const,
|
||||
owner: null,
|
||||
label: L("M02_PickerPersonal"),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(manages(company, user)
|
||||
? [
|
||||
{
|
||||
id: "people" as const,
|
||||
layer: "personal" as const,
|
||||
owner: null,
|
||||
label: L("M02_SourcePeople"),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(opt.practice && isSystem
|
||||
? [
|
||||
{
|
||||
id: "practice" as const,
|
||||
layer: "system" as const,
|
||||
owner: null,
|
||||
label: L("M02_SourcePractice"),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
];
|
||||
return { tabs, first: isSystem || !own ? "master" : "personal" };
|
||||
}
|
||||
|
||||
/** 회사 없음 — 개인 · 회사 층은 회사 폴더 아래라 회사부터 */
|
||||
export function buildNeedCompany(): HTMLElement {
|
||||
const go = createButton({ label: L("M02_NeedCompanyGo"), variant: "filled" });
|
||||
|
||||
Reference in New Issue
Block a user