Allow a column picker and persist columns in advanced search. Closes #1118
This commit is contained in:
parent
f4284a3579
commit
172fe371dd
2 changed files with 10 additions and 3 deletions
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
import ItemTree from 'zotero/itemTree';
|
import ItemTree from 'zotero/itemTree';
|
||||||
import { getColumnDefinitionsByDataKey } from 'zotero/itemTreeColumns'
|
import { COLUMNS } from 'zotero/itemTreeColumns';
|
||||||
|
|
||||||
|
|
||||||
var ZoteroAdvancedSearch = new function() {
|
var ZoteroAdvancedSearch = new function() {
|
||||||
|
@ -56,11 +56,18 @@ var ZoteroAdvancedSearch = new function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var elem = document.getElementById('zotero-items-tree');
|
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, {
|
this.itemsView = await ItemTree.init(elem, {
|
||||||
id: "advanced-search",
|
id: "advanced-search",
|
||||||
dragAndDrop: true,
|
dragAndDrop: true,
|
||||||
|
persistColumns: true,
|
||||||
|
columnPicker: true,
|
||||||
onActivate: this.onItemActivate.bind(this),
|
onActivate: this.onItemActivate.bind(this),
|
||||||
columns: getColumnDefinitionsByDataKey(["title", "firstCreator"]),
|
columns,
|
||||||
});
|
});
|
||||||
|
|
||||||
// A minimal implementation of Zotero.CollectionTreeRow
|
// A minimal implementation of Zotero.CollectionTreeRow
|
||||||
|
|
|
@ -3200,7 +3200,7 @@ var ItemTree = class ItemTree extends LibraryTree {
|
||||||
if (this.props.persistColumns) {
|
if (this.props.persistColumns) {
|
||||||
if (column.disabledIn && column.disabledIn.includes(visibilityGroup)) continue;;
|
if (column.disabledIn && column.disabledIn.includes(visibilityGroup)) continue;;
|
||||||
const columnSettings = columnsSettings[column.dataKey];
|
const columnSettings = columnsSettings[column.dataKey];
|
||||||
if (!columnSettings) {
|
if (!columnSettings && this.id === 'main') {
|
||||||
column = this._setLegacyColumnSettings(column);
|
column = this._setLegacyColumnSettings(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue