refactor: derive modal project label from canonical state
This commit is contained in:
parent
1660e1203d
commit
3667e313a4
@ -379,7 +379,6 @@
|
|||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const ABSTRACT_PREVIEW_DELAY_MS = 3000;
|
|
||||||
const IMPORT_SESSION_STORAGE_KEY = "zotero-kb.import-modal";
|
const IMPORT_SESSION_STORAGE_KEY = "zotero-kb.import-modal";
|
||||||
|
|
||||||
function readImportSessionState() {
|
function readImportSessionState() {
|
||||||
@ -400,7 +399,6 @@
|
|||||||
const state = {
|
const state = {
|
||||||
projects: [],
|
projects: [],
|
||||||
currentProjectId: null,
|
currentProjectId: null,
|
||||||
currentProjectName: null,
|
|
||||||
currentCards: [],
|
currentCards: [],
|
||||||
collectionTree: [],
|
collectionTree: [],
|
||||||
isImportModalOpen: false,
|
isImportModalOpen: false,
|
||||||
@ -596,8 +594,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function syncCurrentProjectLabels() {
|
function syncCurrentProjectLabels() {
|
||||||
if (state.currentProjectName) {
|
const currentProject = state.projects.find((project) => project.id === state.currentProjectId) || null;
|
||||||
const label = `当前项目:${state.currentProjectName}`;
|
if (currentProject) {
|
||||||
|
const label = `当前项目:${currentProject.name}`;
|
||||||
elements.currentProjectLabel.textContent = label;
|
elements.currentProjectLabel.textContent = label;
|
||||||
elements.importModalProjectLabel.textContent = label;
|
elements.importModalProjectLabel.textContent = label;
|
||||||
return;
|
return;
|
||||||
@ -921,7 +920,6 @@
|
|||||||
if (!state.currentProjectId && projects.length) {
|
if (!state.currentProjectId && projects.length) {
|
||||||
state.currentProjectId = projects[0].id;
|
state.currentProjectId = projects[0].id;
|
||||||
}
|
}
|
||||||
state.currentProjectName = state.projects.find((project) => project.id === state.currentProjectId)?.name || null;
|
|
||||||
renderProjects();
|
renderProjects();
|
||||||
updateImportActionState();
|
updateImportActionState();
|
||||||
if (state.currentProjectId) {
|
if (state.currentProjectId) {
|
||||||
@ -933,7 +931,6 @@
|
|||||||
|
|
||||||
async function selectProject(projectId, rerender = true) {
|
async function selectProject(projectId, rerender = true) {
|
||||||
state.currentProjectId = projectId;
|
state.currentProjectId = projectId;
|
||||||
state.currentProjectName = state.projects.find((project) => project.id === projectId)?.name || projectId;
|
|
||||||
updateImportActionState();
|
updateImportActionState();
|
||||||
if (rerender) {
|
if (rerender) {
|
||||||
renderProjects();
|
renderProjects();
|
||||||
|
|||||||
@ -39,13 +39,8 @@ def test_index_contains_import_modal_controls(tmp_path) -> None:
|
|||||||
assert 'id="modal-clear-selection-button"' in html
|
assert 'id="modal-clear-selection-button"' in html
|
||||||
assert 'id="modal-import-selected-items-button"' in html
|
assert 'id="modal-import-selected-items-button"' in html
|
||||||
assert 'id="item-preview-popover"' in html
|
assert 'id="item-preview-popover"' in html
|
||||||
assert 'const ABSTRACT_PREVIEW_DELAY_MS = 3000;' in html
|
|
||||||
assert 'isImportModalOpen: false' in html
|
assert 'isImportModalOpen: false' in html
|
||||||
assert "currentProjectName: null" in html
|
|
||||||
assert "collectionItemsLoaded: false" in html
|
|
||||||
assert "nextCollectionItemsRequestToken: 0" in html
|
|
||||||
assert "function openImportModal()" in html
|
assert "function openImportModal()" in html
|
||||||
assert "function closeImportModal()" in html
|
assert "function closeImportModal()" in html
|
||||||
assert "function updateImportActionState()" in html
|
assert "function updateImportActionState()" in html
|
||||||
assert "function normalizeSelectedCollectionKey()" in html
|
|
||||||
assert 'document.body.classList.toggle("modal-open"' in html
|
assert 'document.body.classList.toggle("modal-open"' in html
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user