Add initial fit and direct wheel zoom with preserved default presentation. Integrate five scoped GuardFix findings and AI generation preselection policy. Exclude Cell experiments and retain five historical guard failures.
55 lines
3.0 KiB
TypeScript
55 lines
3.0 KiB
TypeScript
import type { Employee, OrgChartDataset, Organization } from '@hm-design/org-chart';
|
|
import small from '../org-chart/data-expanded-small.json';
|
|
import medium from '../org-chart/data-expanded-medium.json';
|
|
|
|
/** Deterministic single-company dataset: 6 divisions with 5·2·4·1·3·2 teams.
|
|
* Virtual names only; no live data. Leaders are counted in `total`. */
|
|
export function createSamanDataset(total = 500): OrgChartDataset {
|
|
const organizations: Organization[] = [];
|
|
const employees: Employee[] = [];
|
|
const add = (organizationId: string, position: string) => {
|
|
const id = `saman-e${String(employees.length + 1).padStart(3, '0')}`;
|
|
employees.push({ id, organizationId, affiliationId: 'saman', name: `가상직원 ${String(employees.length + 1).padStart(3, '0')}`, position, jobTitle: null, profileImage: null, workStatus: 'active' });
|
|
return id;
|
|
};
|
|
const org = (id: string, parentId: string | null, name: string, type: Organization['type'], displayOrder: number) => {
|
|
const node: Organization = { id, companyId: 'saman', parentId, name, type, leaderId: null, displayOrder };
|
|
organizations.push(node);
|
|
return node;
|
|
};
|
|
const root = org('saman-root', null, '삼안', 'root', 0);
|
|
root.leaderId = add(root.id, '대표이사');
|
|
const teams: Organization[] = [];
|
|
[5, 2, 4, 1, 3, 2].forEach((teamCount, d) => {
|
|
const division = org(`saman-d${d + 1}`, root.id, `가상 ${d + 1}본부`, 'division', d);
|
|
division.leaderId = add(division.id, '본부장');
|
|
for (let t = 0; t < teamCount; t++) {
|
|
const team = org(`saman-d${d + 1}-t${t + 1}`, division.id, `가상 ${d + 1}-${t + 1}팀`, 'team', t);
|
|
team.leaderId = add(team.id, '팀장');
|
|
teams.push(team);
|
|
}
|
|
});
|
|
let cursor = 0;
|
|
while (employees.length < total) add(teams[cursor++ % teams.length]!.id, ['사원', '선임', '책임', '수석'][cursor % 4]!);
|
|
return {
|
|
schemaVersion: '0.1-draft', organizations, employees, affiliations: [{ id: 'saman', name: '삼안' }], relations: [],
|
|
presentation: { title: '삼안 조직도 · 가상 데이터', description: null, hubText: null,
|
|
groups: { showEmployees: true, showSummary: false, showDispatched: false, showOnLeave: false, showAffiliations: false }, organizationOrder: [] },
|
|
metadata: { asOfDate: '2026-10-13', dataVersion: `chart-only-saman-${total}`, updateNote: '가상 데이터 · 운영 정보 아님' },
|
|
} as OrgChartDataset;
|
|
}
|
|
|
|
export const datasets: Record<string, () => OrgChartDataset> = {
|
|
'20': () => structuredClone(small) as OrgChartDataset,
|
|
'100': () => structuredClone(medium) as OrgChartDataset,
|
|
'500': () => createSamanDataset(500),
|
|
};
|
|
|
|
export function readQuery() {
|
|
const query = new URLSearchParams(location.search);
|
|
const data = datasets[query.get('data') ?? ''] ? query.get('data')! : '20';
|
|
const layout = (['tb', 'lr', 'hybrid'] as const).find(type => type === query.get('layout')) ?? 'tb';
|
|
// embed=1 is a verification layout: a bounded canvas inside a scrolling page.
|
|
return { data, layout, embed: query.get('embed') === '1' };
|
|
}
|