Show parent item title for child notes in context pane

Fixes #2681
This commit is contained in:
Martynas Bagdonas 2022-07-01 15:27:14 +03:00
parent 94372111f5
commit 49f9642c0d
3 changed files with 20 additions and 11 deletions

View file

@ -184,7 +184,7 @@ var ZoteroContextPane = new function () {
setTimeout(() => { setTimeout(() => {
var contextNodes = Array.from(_notesPaneDeck.children); var contextNodes = Array.from(_notesPaneDeck.children);
for (let contextNode of contextNodes) { for (let contextNode of contextNodes) {
var nodes = Array.from(contextNode.children[2].children); var nodes = Array.from(contextNode.querySelector('.zotero-context-pane-tab-notes-deck').children);
for (let node of nodes) { for (let node of nodes) {
var tabID = node.getAttribute('data-tab-id'); var tabID = node.getAttribute('data-tab-id');
if (!document.getElementById(tabID)) { if (!document.getElementById(tabID)) {
@ -233,7 +233,7 @@ var ZoteroContextPane = new function () {
notesContext.updateFromCache(); notesContext.updateFromCache();
} }
let tabNotesDeck = _notesPaneDeck.selectedPanel.children[2]; let tabNotesDeck = _notesPaneDeck.selectedPanel.querySelector('.zotero-context-pane-tab-notes-deck');
let selectedIndex = Array.from(tabNotesDeck.children).findIndex(x => x.getAttribute('data-tab-id') == ids[0]); let selectedIndex = Array.from(tabNotesDeck.children).findIndex(x => x.getAttribute('data-tab-id') == ids[0]);
if (selectedIndex != -1) { if (selectedIndex != -1) {
tabNotesDeck.setAttribute('selectedIndex', selectedIndex); tabNotesDeck.setAttribute('selectedIndex', selectedIndex);
@ -456,12 +456,16 @@ var ZoteroContextPane = new function () {
editor.setAttribute('flex', 1); editor.setAttribute('flex', 1);
noteContainer.append(title, editor); noteContainer.append(title, editor);
var tabNotesContainer = document.createElement('vbox');
var title = document.createElement('vbox');
title.className = 'zotero-context-pane-editor-parent-line';
let tabNotesDeck = document.createElement('deck'); let tabNotesDeck = document.createElement('deck');
tabNotesDeck.className = 'zotero-context-pane-tab-notes-deck'; tabNotesDeck.className = 'zotero-context-pane-tab-notes-deck';
tabNotesDeck.setAttribute('flex', 1); tabNotesDeck.setAttribute('flex', 1);
tabNotesContainer.append(title, tabNotesDeck);
let contextNode = document.createElement('deck'); let contextNode = document.createElement('deck');
contextNode.append(list, noteContainer, tabNotesDeck); contextNode.append(list, noteContainer, tabNotesContainer);
_notesPaneDeck.append(contextNode); _notesPaneDeck.append(contextNode);
contextNode.className = 'context-node'; contextNode.className = 'context-node';
@ -785,7 +789,8 @@ var ZoteroContextPane = new function () {
} }
} }
var tabNotesDeck = _notesPaneDeck.selectedPanel.children[2]; var tabNotesDeck = _notesPaneDeck.selectedPanel.querySelector('.zotero-context-pane-tab-notes-deck');
var parentTitleContainer;
if (isChild) { if (isChild) {
var vbox = document.createElement('vbox'); var vbox = document.createElement('vbox');
vbox.setAttribute('data-tab-id', Zotero_Tabs.selectedID); vbox.setAttribute('data-tab-id', Zotero_Tabs.selectedID);
@ -811,17 +816,21 @@ var ZoteroContextPane = new function () {
_notesPaneDeck.selectedPanel.setAttribute('selectedIndex', 2); _notesPaneDeck.selectedPanel.setAttribute('selectedIndex', 2);
tabNotesDeck.setAttribute('selectedIndex', tabNotesDeck.children.length - 1); tabNotesDeck.setAttribute('selectedIndex', tabNotesDeck.children.length - 1);
parentTitleContainer = _notesPaneDeck.selectedPanel.children[2].querySelector('.zotero-context-pane-editor-parent-line');
} }
else { else {
node.setAttribute('selectedIndex', 1); node.setAttribute('selectedIndex', 1);
editor.mode = readOnly ? 'view' : 'edit'; editor.mode = readOnly ? 'view' : 'edit';
editor.item = item; editor.item = item;
editor.parentItem = null; editor.parentItem = null;
parentTitleContainer = node.querySelector('.zotero-context-pane-editor-parent-line');
} }
editor.focus(); editor.focus();
node.querySelector('.zotero-context-pane-editor-parent-line').innerHTML = ''; parentTitleContainer.innerHTML = '';
var parentItem = item.parentItem; var parentItem = item.parentItem;
if (parentItem) { if (parentItem) {
var container = document.createElementNS(HTML_NS, 'div'); var container = document.createElementNS(HTML_NS, 'div');
@ -832,7 +841,7 @@ var ZoteroContextPane = new function () {
title.append(parentItem.getDisplayTitle()); title.append(parentItem.getDisplayTitle());
title.className = 'parent-title'; title.className = 'parent-title';
container.append(img, title); container.append(img, title);
node.querySelector('.zotero-context-pane-editor-parent-line').append(container); parentTitleContainer.append(container);
} }
_updateAddToNote(); _updateAddToNote();
} }

View file

@ -68,6 +68,10 @@
background-color: #d2d8e2; background-color: #d2d8e2;
} }
.zotero-context-pane-editor-parent-line {
border-bottom: 1px solid #d9d9d9;
}
.zotero-context-pane-editor-parent-line > div { .zotero-context-pane-editor-parent-line > div {
display: flex; display: flex;
align-items: center; align-items: center;

View file

@ -49,10 +49,6 @@
margin-left: 5px; margin-left: 5px;
} }
.zotero-context-pane-pinned-note {
border-top: 1px solid #d9d9d9;
}
/*.zotero-editpane-tabs {*/ /*.zotero-editpane-tabs {*/
/* background: #ececec;*/ /* background: #ececec;*/
/*}*/ /*}*/