Skip to content

Commit

Permalink
Add new config option for collections (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saira-A authored Oct 9, 2024
1 parent b5feace commit 8e95f9f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ type ContentLeftPanelOptions = ExpandPanelOptions & {
branchNodesSelectable: boolean;
/** Determines if tree is the default view */
defaultToTreeEnabled: boolean;
/** Number of items to default to tree view */
/** Number of items to default to tree view (when defaultToTreeEnabled = true; defaults to 0) */
defaultToTreeIfGreaterThan: number;
/** Determines if collection should default to tree view (even if defaultToTreeEnabled = false) */
defaultToTreeIfCollection: boolean;
/** Number of characters to elide at */
elideCount: number;
/** Threshold for gallery thumb chunked resizing */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"branchNodesSelectable": true,
"defaultToTreeEnabled": false,
"defaultToTreeIfGreaterThan": 0,
"defaultToTreeIfCollection": true,
"elideCount": 40,
"expandFullEnabled": true,
"galleryThumbChunkedResizingThreshold": 400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"branchNodesSelectable": false,
"defaultToTreeEnabled": false,
"defaultToTreeIfGreaterThan": 0,
"defaultToTreeIfCollection": true,
"elideCount": 40,
"expandFullEnabled": true,
"galleryThumbChunkedResizingThreshold": 400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,7 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
if (!treeData) {
return;
}

if (
this.isCollection() &&
this.extension.helper.treeHasNavDates(treeData)
) {
if (!this.defaultToThumbsView()) {
this.$treeViewOptions.show();
} else {
this.$treeViewOptions.hide();
Expand Down Expand Up @@ -616,9 +612,17 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
);
const defaultToTreeIfGreaterThan: number =
this.config.options.defaultToTreeIfGreaterThan || 0;

const defaultToTreeIfCollection: boolean = Bools.getBool(
this.config.options.defaultToTreeIfCollection,
false
);

const treeData: TreeNode | null = this.getTree();


if (this.isCollection() && (defaultToTreeIfCollection || (treeData && this.extension.helper.treeHasNavDates(treeData)))) {
return false;
}

if (defaultToTreeEnabled) {
if (treeData && treeData.nodes.length > defaultToTreeIfGreaterThan) {
return false;
Expand Down

0 comments on commit 8e95f9f

Please sign in to comment.