Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e92349e111 |
@@ -1087,18 +1087,38 @@ INDEX_TEMPLATE = '''
|
||||
.folder-list a i { margin-right: 5px; }
|
||||
.folder-list .folder-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 10px;
|
||||
position: relative;
|
||||
}
|
||||
.folder-list .folder-item a {
|
||||
padding: 0 10px;
|
||||
padding: 6px 10px;
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.folder-list .folder-actions {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
display: none;
|
||||
gap: 4px;
|
||||
background: #343a40;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.folder-list .folder-item:hover .folder-actions {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
}
|
||||
.folder-list .folder-actions .btn {
|
||||
padding: 2px 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
}
|
||||
.folder-list .folder-item:hover {
|
||||
background: #495057;
|
||||
}
|
||||
.folder-list .folder-item:hover a {
|
||||
color: #fff;
|
||||
}
|
||||
.folder-action {
|
||||
font-size: 12px;
|
||||
@@ -2664,6 +2684,9 @@ function showAddModal(type) {
|
||||
// 设置类型
|
||||
document.getElementById('addType').value = type;
|
||||
|
||||
// 重置文件夹ID(从顶部按钮添加时不指定文件夹)
|
||||
currentAddFolderId = null;
|
||||
|
||||
// 只有不是编辑草稿时才重置
|
||||
// currentDraftId 在 editDraft 中已设置,不要覆盖
|
||||
|
||||
@@ -2720,7 +2743,8 @@ async function addItem() {
|
||||
due_date: type === 'todo' ? document.getElementById('addDueDate').value : null,
|
||||
note: document.getElementById('addNote').value,
|
||||
tags: document.getElementById('addTags').value.split(',').map(t => t.trim()).filter(t => t),
|
||||
is_starred: document.getElementById('addStarred').checked
|
||||
is_starred: document.getElementById('addStarred').checked,
|
||||
folder_id: currentAddFolderId // 如果从文件夹添加,带上文件夹ID
|
||||
};
|
||||
|
||||
const res = await fetch(`${API_BASE}/items`, {
|
||||
@@ -2741,6 +2765,7 @@ async function addItem() {
|
||||
|
||||
stopAutoSave();
|
||||
hideDraftIndicator();
|
||||
currentAddFolderId = null; // 重置文件夹ID
|
||||
refreshData();
|
||||
}
|
||||
}
|
||||
@@ -4194,10 +4219,13 @@ function renderFolderList(type) {
|
||||
<i class="bi bi-folder"></i> ${f.name} <small class="text-muted">(${f.item_count || 0})</small>
|
||||
</a>
|
||||
<div class="folder-actions">
|
||||
<button class="btn btn-sm btn-outline-secondary py-0 px-1" onclick="event.stopPropagation(); showEditFolderModal(${f.id}, '${f.name}'); return false;" title="重命名">
|
||||
<button class="btn btn-outline-success" onclick="event.stopPropagation(); showAddToFolderModal('${type}', ${f.id}); return false;" title="新增数据到此文件夹">
|
||||
<i class="bi bi-plus"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="event.stopPropagation(); showEditFolderModal(${f.id}, '${f.name}'); return false;" title="重命名">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-danger py-0 px-1" onclick="event.stopPropagation(); deleteFolderConfirm(${f.id}, '${f.name}'); return false;" title="删除">
|
||||
<button class="btn btn-outline-danger" onclick="event.stopPropagation(); deleteFolderConfirm(${f.id}, '${f.name}'); return false;" title="删除">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -4327,6 +4355,55 @@ async function deleteFolderConfirm(folderId, folderName) {
|
||||
}
|
||||
}
|
||||
|
||||
// 显示新增数据到文件夹的模态框
|
||||
function showAddToFolderModal(type, folderId) {
|
||||
// 离线检查
|
||||
if (!checkOnlineBeforeAction('添加数据')) return;
|
||||
|
||||
// 设置类型
|
||||
document.getElementById('addType').value = type;
|
||||
document.getElementById('editFolderId').value = ''; // 重置编辑ID
|
||||
|
||||
// 设置弹窗标题和图标
|
||||
const typeInfo = {
|
||||
text: { icon: '📝', title: '添加文本' },
|
||||
link: { icon: '🔗', title: '添加链接' },
|
||||
column: { icon: '📰', title: '添加专栏' },
|
||||
todo: { icon: '✅', title: '添加待办' }
|
||||
};
|
||||
|
||||
document.getElementById('addModalIcon').textContent = typeInfo[type].icon;
|
||||
document.getElementById('addModalTitle').textContent = typeInfo[type].title;
|
||||
|
||||
// 显示/隐藏对应字段
|
||||
document.getElementById('contentGroup').style.display = type === 'text' ? 'block' : 'none';
|
||||
document.getElementById('urlGroup').style.display = ['link', 'column'].includes(type) ? 'block' : 'none';
|
||||
document.getElementById('sourceGroup').style.display = type === 'column' ? 'block' : 'none';
|
||||
document.getElementById('todoFields').style.display = type === 'todo' ? 'block' : 'none';
|
||||
|
||||
// 清空表单
|
||||
document.getElementById('addForm').reset();
|
||||
hideDraftIndicator();
|
||||
|
||||
// 设置默认文件夹(隐藏字段,需要在提交时带上)
|
||||
currentAddFolderId = folderId;
|
||||
|
||||
// 打开弹窗
|
||||
new bootstrap.Modal(document.getElementById('addModal')).show();
|
||||
|
||||
// 启动自动保存
|
||||
startAutoSave();
|
||||
|
||||
// 弹框关闭时停止自动保存并重置文件夹ID
|
||||
document.getElementById('addModal').addEventListener('hidden.bs.modal', () => {
|
||||
stopAutoSave();
|
||||
currentAddFolderId = null;
|
||||
}, { once: true });
|
||||
}
|
||||
|
||||
// 当前新增时的文件夹ID
|
||||
let currentAddFolderId = null;
|
||||
|
||||
function filterByFolder(type, folderId) {
|
||||
// 更新侧边栏选中状态
|
||||
document.querySelectorAll('.sidebar a').forEach(a => a.classList.remove('active'));
|
||||
|
||||
Reference in New Issue
Block a user