feat(copy): 속성 복사 항목을 선택한 부재에 해당하는 것만 표시
- 부재별 복사 항목 대응표(MEMBER_COPY_ITEMS)를 core/copy-targets.ts에 두고 테스트 추가 코핑 → 폭·길이, 확대기초·말뚝 → 말뚝 길이·열별 본수, 지반 → 위치·지하수위, 기둥·받침 → 없음 - 항목은 선택된 부재(state.member) 기준으로 그려지고, 체크 상태는 부재를 바꿔도 유지 - 기둥·받침은 "복사 항목 없음"을 표시하고 적용 버튼을 비활성화 - ①은 복사 패널 안의 부재 선택으로, ②는 부재 목록으로 같은 부재를 고름 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ccc1f494bc
commit
3a16ee59da
4 files changed
+87
-34
No files matched your search
@@ -1,3 +1,6 @@
|
||||
import type { CopyItem } from './copy';
|
||||
import type { MemberId } from './shape-options';
|
||||
|
||||
/** One pier as a target of 속성 복사. */
|
||||
export interface CopyCandidate {
|
||||
name: string;
|
||||
@@ -26,3 +29,17 @@ export function selectedTargets(piers: CopyCandidate[], sourceName: string, same
|
||||
.filter((c) => c.selectable && ticked.has(c.name))
|
||||
.map((c) => c.name);
|
||||
}
|
||||
|
||||
/** 부재 → 복사 항목. A member with no copy items (기둥, 받침) copies nothing yet. */
|
||||
export const MEMBER_COPY_ITEMS: Record<MemberId, CopyItem[]> = {
|
||||
bearing: [],
|
||||
coping: ['coping-width', 'coping-length'],
|
||||
column: [],
|
||||
footing: ['pile-length', 'pile-rows'],
|
||||
ground: ['ground-position'],
|
||||
};
|
||||
|
||||
/** The copy items for the selected 부재. */
|
||||
export function copyItemsFor(member: MemberId): CopyItem[] {
|
||||
return MEMBER_COPY_ITEMS[member];
|
||||
}
|
||||
+40
-16
@@ -8,8 +8,8 @@ import { NOT_IMPLEMENTED_RULES, validateInput, validatePier } from './core/valid
|
||||
import { buildTemplateWorkbook } from './core/template';
|
||||
import { EDITABLE_FIELDS, FIELD_LABELS, overrideKeys, pendingKeys, revertDraft, type EditableKey, type PierValues } from './core/changes';
|
||||
import { adjustRow, layoutText, resolveRowCounts, rowLayout, totalPiles } from './core/piles';
|
||||
import { applyCopy, DEFAULT_COPY_ITEMS, planCopy, type CopyItem } from './core/copy';
|
||||
import { copyCandidates, selectedTargets, type CopyCandidate } from './core/copy-targets';
|
||||
import { applyCopy, COPY_ITEMS, DEFAULT_COPY_ITEMS, planCopy, type CopyItem } from './core/copy';
|
||||
import { copyCandidates, copyItemsFor, selectedTargets, type CopyCandidate } from './core/copy-targets';
|
||||
import { pileGeometry } from './core/geometry';
|
||||
import { rebarSummary, type RebarRow } from './core/rebar/summary';
|
||||
import { shearSegments } from './core/rebar/coping';
|
||||
@@ -644,10 +644,37 @@ function selectedCopyTargets(): Pier[] {
|
||||
return state.piers.filter((p) => names.has(p.input.name));
|
||||
}
|
||||
|
||||
/** Copy items ticked by the user, limited to the items of the selected 부재. */
|
||||
function chosenCopyItems(): CopyItem[] {
|
||||
return Array.from(document.querySelectorAll<HTMLInputElement>('#copy-panel input[data-item]'))
|
||||
.filter((i) => i.checked)
|
||||
.map((i) => i.dataset.item as CopyItem);
|
||||
return copyItemsFor(state.member).filter((item) => copyItemChoice.has(item));
|
||||
}
|
||||
|
||||
/** The items ticked by the user; kept across 부재 changes. */
|
||||
let copyItemChoice = new Set<CopyItem>(DEFAULT_COPY_ITEMS);
|
||||
|
||||
/** Shows the copy items of the selected 부재 only. A 부재 without items shows a note instead. */
|
||||
function renderCopyItems(): void {
|
||||
const box = $('cp-items');
|
||||
box.replaceChildren();
|
||||
const select = $<HTMLSelectElement>('cp-member');
|
||||
if (select.options.length === 0) for (const m of MEMBERS) select.appendChild(new Option(m.label, m.id));
|
||||
const items = copyItemsFor(state.member);
|
||||
for (const item of items) {
|
||||
const label = el('label', undefined, 'chk');
|
||||
const check = el('input');
|
||||
check.type = 'checkbox';
|
||||
check.dataset.item = item;
|
||||
check.checked = copyItemChoice.has(item);
|
||||
check.addEventListener('change', () => {
|
||||
if (check.checked) copyItemChoice.add(item);
|
||||
else copyItemChoice.delete(item);
|
||||
renderCopyPreview();
|
||||
});
|
||||
label.append(check, document.createTextNode(COPY_ITEMS[item].label));
|
||||
box.appendChild(label);
|
||||
}
|
||||
$('cp-none').hidden = items.length > 0;
|
||||
select.value = state.member;
|
||||
}
|
||||
|
||||
function renderCopyTargets(): void {
|
||||
@@ -703,23 +730,18 @@ function renderCopyPreview(): void {
|
||||
const apply = $<HTMLButtonElement>('cp-apply');
|
||||
apply.textContent = selected.length === 0 ? '대상을 고르세요' : `${selected.map((t) => t.input.name).join(', ')} ${selected.length}기에만 적용`;
|
||||
apply.disabled = applied === 0;
|
||||
if (items.length === 0) apply.textContent = '복사 항목 없음';
|
||||
}
|
||||
|
||||
/** The inline 속성 복사 panel: source is the 기준 pier; targets are ticked inside the panel only. */
|
||||
function renderCopyPanel(): void {
|
||||
const src = activePier();
|
||||
$('cp-source').textContent = src ? `${src.input.name} · ${src.input.type} · ${src.input.foundationType}` : '교각을 선택하세요';
|
||||
renderCopyItems();
|
||||
renderCopyTargets();
|
||||
renderCopyPreview();
|
||||
}
|
||||
|
||||
/** Default copy items, set once at start-up. */
|
||||
function resetCopyItems(): void {
|
||||
for (const i of document.querySelectorAll<HTMLInputElement>('#copy-panel input[data-item]')) {
|
||||
i.checked = (DEFAULT_COPY_ITEMS as string[]).includes(i.dataset.item ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
function applyCopyPanel(): void {
|
||||
const src = activePier();
|
||||
if (!src) return;
|
||||
@@ -1064,6 +1086,8 @@ function wireRebarPicking(): void {
|
||||
function placeCopyPanel(): void {
|
||||
const host = state.stage === 'plan' ? $('member-regen').parentElement : $('edit-regen').parentElement;
|
||||
if (host) host.appendChild($('copy-panel'));
|
||||
// ① has no 부재 list of its own, so the copy panel carries the selector; ② uses its 부재 list.
|
||||
$('cp-member-row').hidden = state.stage !== 'shape';
|
||||
}
|
||||
|
||||
function setStage(stage: Stage): void {
|
||||
@@ -3079,9 +3103,10 @@ $<HTMLButtonElement>('cp-clear').addEventListener('click', () => {
|
||||
renderCopyTargets();
|
||||
renderCopyPreview();
|
||||
});
|
||||
for (const i of document.querySelectorAll<HTMLInputElement>('#copy-panel input[data-item]')) {
|
||||
i.addEventListener('change', renderCopyPreview);
|
||||
}
|
||||
$<HTMLSelectElement>('cp-member').addEventListener('change', (ev) => {
|
||||
state.member = (ev.target as HTMLSelectElement).value as MemberId;
|
||||
renderAll();
|
||||
});
|
||||
$<HTMLInputElement>('cp-regen').addEventListener('change', renderCopyPreview);
|
||||
$<HTMLButtonElement>('cp-apply').addEventListener('click', applyCopyPanel);
|
||||
$<HTMLButtonElement>('sv-save').addEventListener('click', confirmSaveDialog);
|
||||
@@ -3238,7 +3263,6 @@ function restorePanel(id: string): void {
|
||||
}
|
||||
restorePanel('parts-info');
|
||||
restorePanel('color-info');
|
||||
resetCopyItems();
|
||||
|
||||
$<HTMLButtonElement>('all-toggle').addEventListener('click', () => {
|
||||
state.allView = !state.allView;
|
||||
|
||||
Reference in new issue
Block a user