Restore libraries-to-sync UX. Closes #2156
This commit is contained in:
parent
6010390525
commit
462af98380
2 changed files with 17 additions and 11 deletions
|
@ -52,13 +52,6 @@
|
||||||
<hbox class="virtualized-table-container" flex="1" height="200" width="600">
|
<hbox class="virtualized-table-container" flex="1" height="200" width="600">
|
||||||
<html:div id="libraries-to-sync-tree"/>
|
<html:div id="libraries-to-sync-tree"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
<separator class="thin"/>
|
|
||||||
|
|
||||||
<hbox align="center">
|
|
||||||
<hbox pack="start" flex="1">
|
|
||||||
<button label="&zotero.preferences.sync.toggle;" onclick="Zotero_Preferences.Sync.toggleLibraryToSync()"/>
|
|
||||||
</hbox>
|
|
||||||
</hbox>
|
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -234,8 +234,10 @@ Zotero_Preferences.Sync = {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
toggleLibraryToSync: function () {
|
toggleLibraryToSync: function (index) {
|
||||||
const index = this._tree.selection.focused;
|
if (typeof index != "number") {
|
||||||
|
index = this._tree.selection.focused;
|
||||||
|
}
|
||||||
if (index == -1 || !this._rows[index].editable) return;
|
if (index == -1 || !this._rows[index].editable) return;
|
||||||
const row = this._rows[index];
|
const row = this._rows[index];
|
||||||
this._rows[index].checked = !this._rows[index].checked;
|
this._rows[index].checked = !this._rows[index].checked;
|
||||||
|
@ -268,7 +270,7 @@ Zotero_Preferences.Sync = {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
this._rows = [];
|
this._rows = [];
|
||||||
function renderItem(index, selection, oldDiv=null, columns) {
|
let renderItem = (index, selection, oldDiv=null, columns) => {
|
||||||
const row = this._rows[index];
|
const row = this._rows[index];
|
||||||
let div;
|
let div;
|
||||||
if (oldDiv) {
|
if (oldDiv) {
|
||||||
|
@ -289,6 +291,10 @@ Zotero_Preferences.Sync = {
|
||||||
span.innerText = row.checked ? this.checkmarkChar : this.noChar;
|
span.innerText = row.checked ? this.checkmarkChar : this.noChar;
|
||||||
span.style.textAlign = 'center';
|
span.style.textAlign = 'center';
|
||||||
}
|
}
|
||||||
|
span.addEventListener('mousedown', () => {
|
||||||
|
this.toggleLibraryToSync(index);
|
||||||
|
});
|
||||||
|
span.style.pointerEvents = 'initial';
|
||||||
div.appendChild(span);
|
div.appendChild(span);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -297,17 +303,24 @@ Zotero_Preferences.Sync = {
|
||||||
}
|
}
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
let handleKeyDown = (e) => {
|
||||||
|
if (e.key == ' ') {
|
||||||
|
this.toggleLibraryToSync();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
let elem = (
|
let elem = (
|
||||||
<IntlProvider locale={Zotero.locale} messages={Zotero.Intl.strings}>
|
<IntlProvider locale={Zotero.locale} messages={Zotero.Intl.strings}>
|
||||||
<VirtualizedTable
|
<VirtualizedTable
|
||||||
getRowCount={() => this._rows.length}
|
getRowCount={() => this._rows.length}
|
||||||
id="librariesToSync-table"
|
id="librariesToSync-table"
|
||||||
ref={ref => this._tree = ref}
|
ref={ref => this._tree = ref}
|
||||||
renderItem={renderItem.bind(this)}
|
renderItem={renderItem}
|
||||||
showHeader={true}
|
showHeader={true}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
staticColumns={true}
|
staticColumns={true}
|
||||||
onActivate={Zotero_Preferences.Sync.toggleLibraryToSync.bind(this)}
|
onActivate={Zotero_Preferences.Sync.toggleLibraryToSync.bind(this)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue