From d466e368ad164347f82a160e7088540a78c230f6 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Tue, 10 Mar 2020 11:07:59 -0400 Subject: made stacking view hide edit/view button unless selected. get rid of columns with no documens when hideHeadings is set. --- src/client/views/collections/CollectionStackingView.tsx | 12 ++++++++++-- src/server/authentication/models/current_user_utils.ts | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index 3f7f0a352..a936582c3 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -100,6 +100,14 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { changed = true; } }); + // remove all empty columns if hideHeadings is set + if (this.props.Document.hideHeadings) { + Array.from(fields.keys()).filter(key => !fields.get(key)!.length).map(header => { + fields.delete(header); + sectionHeaders.splice(sectionHeaders.indexOf(header), 1); + changed = true; + }) + } changed && setTimeout(action(() => { if (this.sectionHeaders) { this.sectionHeaders.length = 0; this.sectionHeaders.push(...sectionHeaders); } }), 0); return fields; } @@ -276,7 +284,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { } }); } - headings = () => Array.from(this.Sections.keys()); + headings = () => Array.from(this.Sections); sectionStacking = (heading: SchemaHeaderField | undefined, docList: Doc[]) => { const key = this.pivotField; let type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined = undefined; @@ -407,7 +415,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { style={{ width: !this.isStackingView ? "100%" : this.columnWidth / this.numGroupColumns - 10, marginTop: 10 }}> } - {this.props.Document._chromeStatus !== 'disabled' ?