Add a Restore Column Order choice in the column picker
This commit is contained in:
parent
2b6c7277f7
commit
82f87a0d8d
2 changed files with 20 additions and 3 deletions
|
@ -1269,7 +1269,6 @@ var Columns = class {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
setOrder = (index, insertBefore) => {
|
||||
const column = this._columns[index];
|
||||
if (column.ordinal == insertBefore) return;
|
||||
|
@ -1288,6 +1287,18 @@ var Columns = class {
|
|||
this._storePrefs(prefs);
|
||||
this._updateVirtualizedTable();
|
||||
}
|
||||
|
||||
restoreDefaultOrder = () => {
|
||||
let prefs = this._getPrefs();
|
||||
for (const column of this._columns) {
|
||||
column.ordinal = this._virtualizedTable.props.columns.findIndex(
|
||||
col => col.dataKey == column.dataKey);
|
||||
prefs[column.dataKey].ordinal = column.ordinal;
|
||||
}
|
||||
this._columns.sort((a, b) => a.ordinal - b.ordinal);
|
||||
this._storePrefs(prefs);
|
||||
this._updateVirtualizedTable();
|
||||
}
|
||||
|
||||
toggleHidden(index) {
|
||||
const column = this._columns[index];
|
||||
|
|
|
@ -3275,11 +3275,17 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
}
|
||||
|
||||
let sep = doc.createElementNS(ns, 'menuseparator');
|
||||
sep.setAttribute('anonid', prefix + 'sep');
|
||||
// sep.setAttribute('anonid', prefix + 'sep');
|
||||
menupopup.appendChild(sep);
|
||||
|
||||
// TODO: RESTORE DEFAULT ORDER option
|
||||
//
|
||||
// Restore Default Column Order
|
||||
//
|
||||
let menuitem = doc.createElementNS(ns, 'menuitem');
|
||||
menuitem.setAttribute('label', Zotero.Intl.strings['zotero.items.restoreColumnOrder.label']);
|
||||
menuitem.setAttribute('anonid', prefix + 'restore-order');
|
||||
menuitem.addEventListener('command', () => this.tree._columns.restoreDefaultOrder());
|
||||
menupopup.appendChild(menuitem);
|
||||
|
||||
document.children[0].appendChild(menupopup);
|
||||
menupopup.openPopup(null, null, event.clientX + 2, event.clientY + 2);
|
||||
|
|
Loading…
Add table
Reference in a new issue