팝업창 수정 - 팝업창 제목, 선택 이미지 저장 경고 문구 추가
This commit is contained in:
+55
-3
@@ -5,10 +5,27 @@ import * as history from './history.js';
|
||||
|
||||
const inputPrefix = document.getElementById('input-prefix');
|
||||
const inputDigits = document.getElementById('input-digits');
|
||||
const renameConfirmModal = document.getElementById('rename-confirm-modal');
|
||||
const renameConfirmTitle = document.getElementById('rename-confirm-title');
|
||||
const renameConfirmMsg = document.getElementById('rename-confirm-msg');
|
||||
const renameConfirmWarning = document.getElementById('rename-confirm-selection-warning');
|
||||
const renameConfirmList = document.getElementById('rename-confirm-list');
|
||||
const renameConfirmCancelBtn = document.getElementById('rename-confirm-cancel');
|
||||
const renameConfirmOkBtn = document.getElementById('rename-confirm-ok');
|
||||
const renameConflictModal = document.getElementById('rename-conflict-modal');
|
||||
const renameConflictCloseBtn = document.getElementById('rename-conflict-close');
|
||||
const renameConflictList = document.getElementById('rename-conflict-list');
|
||||
|
||||
let _renameConfirmResolve = null;
|
||||
|
||||
renameConfirmCancelBtn.addEventListener('click', () => {
|
||||
closeRenameConfirm(false);
|
||||
});
|
||||
|
||||
renameConfirmOkBtn.addEventListener('click', () => {
|
||||
closeRenameConfirm(true);
|
||||
});
|
||||
|
||||
renameConflictCloseBtn.addEventListener('click', () => {
|
||||
renameConflictModal.style.display = 'none';
|
||||
});
|
||||
@@ -49,10 +66,16 @@ export async function doRename() {
|
||||
const examples = filesToRename.slice(0, 3).map((f, i) => {
|
||||
const ext = f.name.split('.').pop().toLowerCase();
|
||||
return `${f.name} → ${prefix}_${String(i + 1).padStart(digits, '0')}.${ext}`;
|
||||
}).join('\n');
|
||||
const more = filesToRename.length > 3 ? `\n... 외 ${filesToRename.length - 3}개` : '';
|
||||
});
|
||||
const more = filesToRename.length > 3 ? `... 외 ${filesToRename.length - 3}개` : '';
|
||||
|
||||
if (!confirm(`📂 ${filesToRename.length}개 파일을 이름 변경합니다:\n\n${examples}${more}\n\n계속하시겠습니까?`)) return;
|
||||
const confirmed = await showRenameConfirm({
|
||||
count: filesToRename.length,
|
||||
examples,
|
||||
more,
|
||||
isPartial: selectedArr.length > 0,
|
||||
});
|
||||
if (!confirmed) return;
|
||||
|
||||
showLoading('파일 이름 변경 중...');
|
||||
setStatus('이름 변경 중...', false);
|
||||
@@ -83,3 +106,32 @@ export async function doRename() {
|
||||
alert('오류 발생: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
function showRenameConfirm({ count, examples, more, isPartial }) {
|
||||
renameConfirmTitle.textContent = isPartial ? '선택된 이미지 저장' : '전체 이미지 저장';
|
||||
renameConfirmMsg.textContent = `${count}개 파일을 이름 변경합니다. 계속하시겠습니까?`;
|
||||
renameConfirmWarning.style.display = isPartial ? 'block' : 'none';
|
||||
|
||||
const items = [...examples];
|
||||
if (more) items.push(more);
|
||||
renameConfirmList.replaceChildren(...items.map(text => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = text;
|
||||
return li;
|
||||
}));
|
||||
|
||||
renameConfirmModal.style.display = 'flex';
|
||||
renameConfirmOkBtn.focus();
|
||||
|
||||
return new Promise(resolve => {
|
||||
_renameConfirmResolve = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
function closeRenameConfirm(confirmed) {
|
||||
renameConfirmModal.style.display = 'none';
|
||||
if (_renameConfirmResolve) {
|
||||
_renameConfirmResolve(confirmed);
|
||||
_renameConfirmResolve = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user