Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new config option for collections #1107

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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