feat(copy): 복사 항목 기본 체크를 기준 교각에서 바뀐 항목으로 설정

- 기준 교각의 되돌리기가 보이는 값에 해당하는 복사 항목을 자동으로 체크
- 기준 교각이나 부재가 바뀔 때만 다시 계산, 그 사이 사용자의 체크는 유지
- "변경 항목으로 선택" 버튼으로 언제든 같은 상태로 되돌림
- 바뀐 값이 없으면 아무 항목도 체크하지 않음 (적용 버튼 비활성)
- copyItemsWithOverrides 추가, 테스트 4건

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
ypshimandClaude Haiku 5.5 committed 2026-10-27 16:51:30 +09:00
1 parent 70fa0be86f
commit 7314da639b
4 files changed
+54 -6

No files matched your search

+11 -1
View File
@@ -1,4 +1,5 @@
import type { CopyItem } from './copy';
import { COPY_ITEMS, type CopyItem } from './copy';
import { overrideKeys, type PierValues } from './changes';
import type { MemberId } from './shape-options';
/** One pier as a target of 속성 복사. */
@@ -43,3 +44,12 @@ export const MEMBER_COPY_ITEMS: Record<MemberId, CopyItem[]> = {
export function copyItemsFor(member: MemberId): CopyItem[] {
return MEMBER_COPY_ITEMS[member];
}
/**
* The copy items whose values the 기준 pier has changed from the imported default (되돌리기가 보이는 항목).
* They are ticked by default; the user can change the ticks afterwards.
*/
export function copyItemsWithOverrides(source: PierValues): CopyItem[] {
const changed = new Set<string>(overrideKeys(source));
return (Object.keys(COPY_ITEMS) as CopyItem[]).filter((item) => COPY_ITEMS[item].keys.some((k) => changed.has(k)));
}
+17 -4
View File
@@ -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, COPY_ITEMS, DEFAULT_COPY_ITEMS, planCopy, type CopyItem } from './core/copy';
import { copyCandidates, copyItemsFor, selectedTargets, type CopyCandidate } from './core/copy-targets';
import { applyCopy, COPY_ITEMS, planCopy, type CopyItem } from './core/copy';
import { copyCandidates, copyItemsFor, copyItemsWithOverrides, 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';
@@ -649,11 +649,18 @@ function chosenCopyItems(): 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);
/** The items ticked by the user. Reset to the 기준 pier's changed items when the 기준 pier or 부재 changes. */
let copyItemChoice = new Set<CopyItem>();
let copyItemKey = '';
/** Shows the copy items of the selected 부재 only. A 부재 without items shows a note instead. */
function renderCopyItems(): void {
const src = activePier();
const key = `${src?.input.name ?? ''}|${state.member}`;
if (key !== copyItemKey) {
copyItemKey = key;
copyItemChoice = new Set(src ? copyItemsWithOverrides(src) : []);
}
const box = $('cp-items');
box.replaceChildren();
const items = copyItemsFor(state.member);
@@ -3080,6 +3087,12 @@ $<HTMLButtonElement>('cp-select-same').addEventListener('click', () => {
renderCopyTargets();
renderCopyPreview();
});
$<HTMLButtonElement>('cp-items-reset').addEventListener('click', () => {
const src = activePier();
copyItemChoice = new Set(src ? copyItemsWithOverrides(src) : []);
renderCopyItems();
renderCopyPreview();
});
$<HTMLButtonElement>('cp-clear').addEventListener('click', () => {
copySelection = new Set();
renderCopyTargets();