refactor(copy): 대상 교각의 같은 형식 필터와 같은 형식 모두 선택 버튼 제거
- "원본과 같은 형식만" 체크박스와 "같은 형식 모두 선택" 버튼 삭제, "선택 해제"는 유지 - 대상 칩에 원본과 형식이 다르면 "형식 다름" 표시 - copyCandidates와 selectedTargets에서 형식 필터 인자 제거, 테스트 갱신 - 테스트 타입 오류(optional 필드) 수정 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5f3ea8d56f
commit
fb09c693c4
4 files changed
+18
-33
No files matched your search
@@ -16,17 +16,16 @@ export interface TargetCandidate {
|
||||
selectable: boolean;
|
||||
}
|
||||
|
||||
/** The piers offered as targets: every other pier, or only those of the source type. */
|
||||
export function copyCandidates(piers: CopyCandidate[], sourceName: string, sameTypeOnly: boolean): TargetCandidate[] {
|
||||
const source = piers.find((p) => p.name === sourceName);
|
||||
/** The piers offered as targets: every other pier. The type is shown so a different type is visible. */
|
||||
export function copyCandidates(piers: CopyCandidate[], sourceName: string): TargetCandidate[] {
|
||||
return piers
|
||||
.filter((p) => p.name !== sourceName && (!sameTypeOnly || p.type === source?.type))
|
||||
.filter((p) => p.name !== sourceName)
|
||||
.map((p) => ({ name: p.name, type: p.type, selectable: p.hasModel }));
|
||||
}
|
||||
|
||||
/** The targets that get the change: ticked by the user, selectable, and visible under the current filter. */
|
||||
export function selectedTargets(piers: CopyCandidate[], sourceName: string, sameTypeOnly: boolean, ticked: Set<string>): string[] {
|
||||
return copyCandidates(piers, sourceName, sameTypeOnly)
|
||||
export function selectedTargets(piers: CopyCandidate[], sourceName: string, ticked: Set<string>): string[] {
|
||||
return copyCandidates(piers, sourceName)
|
||||
.filter((c) => c.selectable && ticked.has(c.name))
|
||||
.map((c) => c.name);
|
||||
}
|
||||
|
||||
+4
-15
@@ -640,7 +640,7 @@ function copyCandidateList(): CopyCandidate[] {
|
||||
function selectedCopyTargets(): Pier[] {
|
||||
const src = activePier();
|
||||
if (!src) return [];
|
||||
const names = new Set(selectedTargets(copyCandidateList(), src.input.name, $<HTMLInputElement>('cp-same-type').checked, copySelection));
|
||||
const names = new Set(selectedTargets(copyCandidateList(), src.input.name, copySelection));
|
||||
return state.piers.filter((p) => names.has(p.input.name));
|
||||
}
|
||||
|
||||
@@ -685,8 +685,7 @@ function renderCopyTargets(): void {
|
||||
const box = $('cp-targets');
|
||||
box.replaceChildren();
|
||||
const src = activePier();
|
||||
const sameType = $<HTMLInputElement>('cp-same-type').checked;
|
||||
for (const c of copyCandidates(copyCandidateList(), src?.input.name ?? '', sameType)) {
|
||||
for (const c of copyCandidates(copyCandidateList(), src?.input.name ?? '')) {
|
||||
const label = el('label', undefined, 'chk');
|
||||
const check = el('input');
|
||||
check.type = 'checkbox';
|
||||
@@ -698,7 +697,8 @@ function renderCopyTargets(): void {
|
||||
else copySelection.delete(c.name);
|
||||
renderCopyPreview();
|
||||
});
|
||||
const text = c.selectable ? `${c.name} · ${c.type}` : `${c.name} · ${c.type} (모델 없음, 제외)`;
|
||||
const otherType = src !== undefined && c.type !== src.input.type ? ' · 형식 다름' : '';
|
||||
const text = c.selectable ? `${c.name} · ${c.type}${otherType}` : `${c.name} · ${c.type} (모델 없음, 제외)`;
|
||||
label.append(check, document.createTextNode(text));
|
||||
box.appendChild(label);
|
||||
}
|
||||
@@ -3076,17 +3076,6 @@ $<HTMLButtonElement>('member-regen').addEventListener('click', () => {
|
||||
const pier = activePier();
|
||||
if (pier) regenerateOne(pier.input.name);
|
||||
});
|
||||
$<HTMLInputElement>('cp-same-type').addEventListener('change', () => {
|
||||
renderCopyTargets();
|
||||
renderCopyPreview();
|
||||
});
|
||||
$<HTMLButtonElement>('cp-select-same').addEventListener('click', () => {
|
||||
const src = activePier();
|
||||
const sameType = $<HTMLInputElement>('cp-same-type').checked;
|
||||
copySelection = new Set(copyCandidates(copyCandidateList(), src?.input.name ?? '', sameType).filter((c) => c.selectable).map((c) => c.name));
|
||||
renderCopyTargets();
|
||||
renderCopyPreview();
|
||||
});
|
||||
$<HTMLButtonElement>('cp-items-reset').addEventListener('click', () => {
|
||||
const src = activePier();
|
||||
copyItemChoice = new Set(src ? copyItemsWithOverrides(src) : []);
|
||||
|
||||
Reference in new issue
Block a user