Skip to content

Commit

Permalink
add to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Saira-A committed Sep 4, 2024
1 parent 77d5856 commit 9dd4044
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type ContentLeftPanelOptions = ExpandPanelOptions & {
defaultToTreeEnabled: boolean;
/** Number of items to default to tree view */
defaultToTreeIfGreaterThan: number;
/** Determines if collection should default to tree view */
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 Expand Up @@ -350,7 +351,7 @@
"maxZoomPixelRatio": 1.25,
"mostSpecificRequiredStatement": true,
"navigatorPosition": "BOTTOM_RIGHT",
"pageGap": 50,
"pageGap": 500,
"requiredStatementEnabled": true,
"showHomeControl": false,
"subtitleEnabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
}

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

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

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

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

if (defaultToTreeIfCollection && this.isCollection()) {
return false; // Default to tree view if the manifest is a collection
}

if (defaultToTreeEnabled) {
if (treeData && treeData.nodes.length > defaultToTreeIfGreaterThan) {
return false;
Expand Down Expand Up @@ -817,7 +830,7 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
let nodeFound: boolean = false;

allNodes.map((node) => {
if (node.isCollection() && node.data.index === collectionIndex) {
if (this.config.options.defaultToTreeIfCollection && node.isCollection() && node.data.index === collectionIndex) {
this.treeView.selectNode(node as TreeNode);
this.treeView.expandNode(node as TreeNode, true);
nodeFound = true;
Expand Down

0 comments on commit 9dd4044

Please sign in to comment.