Fix export preferences HTML tree

This commit is contained in:
Adomas Venčkauskas 2021-08-30 12:05:57 +03:00
parent aa7f5289a3
commit 873846261e
2 changed files with 16 additions and 4 deletions

View file

@ -197,8 +197,11 @@ Zotero_Preferences.Export = {
document.getElementById('quickCopy-delete').disabled = false; document.getElementById('quickCopy-delete').disabled = false;
}, },
showQuickCopySiteEditor: async function () { showQuickCopySiteEditor: async function (editExisting) {
const index = this._tree.selection.focused; var index;
if (editExisting) {
index = this._tree.selection.focused;
}
var formattedName = document.getElementById('zotero-quickCopy-menu').label; var formattedName = document.getElementById('zotero-quickCopy-menu').label;
var locale = this._lastSelectedLocale; var locale = this._lastSelectedLocale;
var asHTML = document.getElementById('zotero-quickCopy-copyAsHTML').checked; var asHTML = document.getElementById('zotero-quickCopy-copyAsHTML').checked;
@ -291,6 +294,15 @@ Zotero_Preferences.Export = {
Zotero_Preferences.Export.deleteSelectedQuickCopySite(); Zotero_Preferences.Export.deleteSelectedQuickCopySite();
} }
}; };
var handleSelectionChange = (selection) => {
if (selection.count) {
Zotero_Preferences.Export.enableQuickCopySiteButtons()
}
else {
Zotero_Preferences.Export.disableQuickCopySiteButtons();
}
};
let elem = ( let elem = (
<IntlProvider locale={Zotero.locale} messages={Zotero.Intl.strings}> <IntlProvider locale={Zotero.locale} messages={Zotero.Intl.strings}>
<VirtualizedTable <VirtualizedTable
@ -302,7 +314,7 @@ Zotero_Preferences.Export = {
columns={columns} columns={columns}
staticColumns={true} staticColumns={true}
disableFontSizeScaling={true} disableFontSizeScaling={true}
onSelectionChange={() => Zotero_Preferences.Export.enableQuickCopySiteButtons()} onSelectionChange={handleSelectionChange}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
onActivate={(event, indices) => Zotero_Preferences.Export.showQuickCopySiteEditor()} onActivate={(event, indices) => Zotero_Preferences.Export.showQuickCopySiteEditor()}
/> />

View file

@ -75,7 +75,7 @@
<separator class="thin"/> <separator class="thin"/>
<hbox> <hbox>
<button disabled="true" id="quickCopy-edit" label="&zotero.general.edit;" <button disabled="true" id="quickCopy-edit" label="&zotero.general.edit;"
onclick="Zotero_Preferences.Export.showQuickCopySiteEditor(document.getElementById('quickCopy-siteSettings').currentIndex)"/> onclick="Zotero_Preferences.Export.showQuickCopySiteEditor(true)"/>
<spacer flex="1"/> <spacer flex="1"/>
<button disabled="true" id="quickCopy-delete" label="-" onclick="Zotero_Preferences.Export.deleteSelectedQuickCopySite()"/> <button disabled="true" id="quickCopy-delete" label="-" onclick="Zotero_Preferences.Export.deleteSelectedQuickCopySite()"/>
<button label="+" <button label="+"