Allow a column picker and persist columns in advanced search. Closes #1118

This commit is contained in:
Adomas Venčkauskas 2023-12-12 08:34:59 +02:00
parent f4284a3579
commit 172fe371dd
2 changed files with 10 additions and 3 deletions

View file

@ -26,7 +26,7 @@
Components.utils.import("resource://gre/modules/Services.jsm");
import ItemTree from 'zotero/itemTree';
import { getColumnDefinitionsByDataKey } from 'zotero/itemTreeColumns'
import { COLUMNS } from 'zotero/itemTreeColumns';
var ZoteroAdvancedSearch = new function() {
@ -56,11 +56,18 @@ var ZoteroAdvancedSearch = new function() {
});
var elem = document.getElementById('zotero-items-tree');
const columns = COLUMNS.map((column) => {
column = Object.assign({}, column);
column.hidden = !['title', 'firstCreator'].includes(column.dataKey);
return column;
});
this.itemsView = await ItemTree.init(elem, {
id: "advanced-search",
dragAndDrop: true,
persistColumns: true,
columnPicker: true,
onActivate: this.onItemActivate.bind(this),
columns: getColumnDefinitionsByDataKey(["title", "firstCreator"]),
columns,
});
// A minimal implementation of Zotero.CollectionTreeRow

View file

@ -3200,7 +3200,7 @@ var ItemTree = class ItemTree extends LibraryTree {
if (this.props.persistColumns) {
if (column.disabledIn && column.disabledIn.includes(visibilityGroup)) continue;;
const columnSettings = columnsSettings[column.dataKey];
if (!columnSettings) {
if (!columnSettings && this.id === 'main') {
column = this._setLegacyColumnSettings(column);
}