From 8127616d06b4db2b29de0b13068810fd19e77b5e Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 17 Apr 2023 09:26:45 -0400
Subject: minor cleanup of CollectionView

---
 src/client/views/collections/CollectionView.tsx | 90 +++++++------------------
 1 file changed, 25 insertions(+), 65 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index d7a889362..cfb9310b6 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -99,18 +99,6 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
         return viewField as any as CollectionViewType;
     }
 
-    showIsTagged = () => {
-        return null;
-        // this section would display an icon in the bototm right of a collection to indicate that all
-        // photos had been processed through Google's content analysis API and Google's tags had been
-        // assigned to the documents googlePhotosTags field.
-        // const children = DocListCast(this.rootDoc[this.props.fieldKey]);
-        // const imageProtos = children.filter(doc => Cast(doc.data, ImageField)).map(Doc.GetProto);
-        // const allTagged = imageProtos.length > 0 && imageProtos.every(image => image.googlePhotosTags);
-        // return !allTagged ? (null) : <img id={"google-tags"} src={"/assets/google_tags.png"} />;
-        //this.isContentActive();
-    };
-
     screenToLocalTransform = () => (this.props.renderDepth ? this.props.ScreenToLocalTransform() : this.props.ScreenToLocalTransform().scale(this.props.PanelWidth() / this.bodyPanelWidth()));
     // prettier-ignore
     private renderSubView = (type: CollectionViewType | undefined, props: SubCollectionViewProps) => {
@@ -138,26 +126,25 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
         }
     };
 
-    setupViewTypes(category: string, func: (viewType: CollectionViewType) => Doc, addExtras: boolean) {
-        const subItems: ContextMenuProps[] = [];
-        subItems.push({ description: 'Freeform', event: () => func(CollectionViewType.Freeform), icon: 'signature' });
-        if (addExtras && CollectionView._safeMode) {
-            ContextMenu.Instance.addItem({ description: 'Test Freeform', event: () => func(CollectionViewType.Invalid), icon: 'project-diagram' });
-        }
-        subItems.push({ description: 'Schema', event: () => func(CollectionViewType.Schema), icon: 'th-list' });
-        subItems.push({ description: 'Tree', event: () => func(CollectionViewType.Tree), icon: 'tree' });
-        subItems.push({ description: 'Stacking', event: () => (func(CollectionViewType.Stacking)._autoHeight = true), icon: 'ellipsis-v' });
-        subItems.push({ description: 'Notetaking', event: () => (func(CollectionViewType.NoteTaking)._autoHeight = true), icon: 'ellipsis-v' });
-        subItems.push({ description: 'Multicolumn', event: () => func(CollectionViewType.Multicolumn), icon: 'columns' });
-        subItems.push({ description: 'Multirow', event: () => func(CollectionViewType.Multirow), icon: 'columns' });
-        subItems.push({ description: 'Masonry', event: () => func(CollectionViewType.Masonry), icon: 'columns' });
-        subItems.push({ description: 'Carousel', event: () => func(CollectionViewType.Carousel), icon: 'columns' });
-        subItems.push({ description: '3D Carousel', event: () => func(CollectionViewType.Carousel3D), icon: 'columns' });
-        !Doc.noviceMode && subItems.push({ description: 'Pivot/Time', event: () => func(CollectionViewType.Time), icon: 'columns' });
-        !Doc.noviceMode && subItems.push({ description: 'Map', event: () => func(CollectionViewType.Map), icon: 'globe-americas' });
-        subItems.push({ description: 'Grid', event: () => func(CollectionViewType.Grid), icon: 'th-list' });
-
+    setupViewTypes(category: string, func: (viewType: CollectionViewType) => Doc) {
         if (!Doc.IsSystem(this.rootDoc) && this.rootDoc._viewType !== CollectionViewType.Docking && !this.rootDoc.isGroup && !this.rootDoc.annotationOn) {
+            // prettier-ignore
+            const subItems: ContextMenuProps[] = [
+                { description: 'Freeform',    event: () => func(CollectionViewType.Freeform), icon: 'signature' },
+                { description: 'Schema',      event: () => func(CollectionViewType.Schema), icon: 'th-list' },
+                { description: 'Tree',        event: () => func(CollectionViewType.Tree), icon: 'tree' },
+                { description: 'Stacking',    event: () => (func(CollectionViewType.Stacking)._autoHeight = true), icon: 'ellipsis-v' },
+                { description: 'Notetaking',  event: () => (func(CollectionViewType.NoteTaking)._autoHeight = true), icon: 'ellipsis-v' },
+                { description: 'Multicolumn', event: () => func(CollectionViewType.Multicolumn), icon: 'columns' },
+                { description: 'Multirow',    event: () => func(CollectionViewType.Multirow), icon: 'columns' },
+                { description: 'Masonry',     event: () => func(CollectionViewType.Masonry), icon: 'columns' },
+                { description: 'Carousel',    event: () => func(CollectionViewType.Carousel), icon: 'columns' },
+                { description: '3D Carousel', event: () => func(CollectionViewType.Carousel3D), icon: 'columns' },
+                { description: 'Pivot/Time',  event: () => func(CollectionViewType.Time), icon: 'columns' },
+                { description: 'Map',         event: () => func(CollectionViewType.Map), icon: 'globe-americas' },
+                { description: 'Grid',        event: () => func(CollectionViewType.Grid), icon: 'th-list' },
+            ];
+
             const existingVm = ContextMenu.Instance.findByDescription(category);
             const catItems = existingVm && 'subitems' in existingVm ? existingVm.subitems : [];
             catItems.push({ description: 'Add a Perspective...', addDivider: true, noexpand: true, subitems: subItems, icon: 'eye' });
@@ -169,16 +156,12 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
         const cm = ContextMenu.Instance;
         if (cm && !e.isPropagationStopped()) {
             // need to test this because GoldenLayout causes a parallel hierarchy in the React DOM for its children and the main document view7
-            this.setupViewTypes(
-                'UI Controls...',
-                vtype => {
-                    const newRendition = Doc.MakeAlias(this.rootDoc);
-                    newRendition._viewType = vtype;
-                    this.props.addDocTab(newRendition, OpenWhere.addRight);
-                    return newRendition;
-                },
-                false
-            );
+            this.setupViewTypes('UI Controls...', vtype => {
+                const newRendition = Doc.MakeAlias(this.rootDoc);
+                newRendition._viewType = vtype;
+                this.props.addDocTab(newRendition, OpenWhere.addRight);
+                return newRendition;
+            });
 
             const options = cm.findByDescription('Options...');
             const optionItems = options && 'subitems' in options ? options.subitems : [];
@@ -191,24 +174,6 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
             }
             !Doc.noviceMode && optionItems.push({ description: `${this.rootDoc._isLightbox ? 'Unset' : 'Set'} is Lightbox`, event: () => (this.rootDoc._isLightbox = !this.rootDoc._isLightbox), icon: 'project-diagram' });
 
-            // if (!Doc.noviceMode && false) {
-            //     optionItems.push({
-            //         description: 'Create Branch',
-            //         event: async () => this.props.addDocTab(await BranchCreate(this.rootDoc), OpenWhere.addRight),
-            //         icon: 'project-diagram',
-            //     });
-            //     optionItems.push({
-            //         description: 'Pull Master',
-            //         event: () => BranchTask(this.rootDoc, 'pull'),
-            //         icon: 'project-diagram',
-            //     });
-            //     optionItems.push({
-            //         description: 'Merge Branches',
-            //         event: () => BranchTask(this.rootDoc, 'merge'),
-            //         icon: 'project-diagram',
-            //     });
-            // }
-
             !options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'hand-point-right' });
 
             if (!Doc.noviceMode && !this.rootDoc.annotationOn) {
@@ -253,10 +218,6 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
     childHideResizeHandles = () => this.props.childHideResizeHandles?.() ?? BoolCast(this.Document.childHideResizeHandles);
     childHideDecorationTitle = () => this.props.childHideDecorationTitle?.() ?? BoolCast(this.Document.childHideDecorationTitle);
     childLayoutTemplate = () => this.props.childLayoutTemplate?.() || Cast(this.rootDoc.childLayoutTemplate, Doc, null);
-    @computed get childLayoutString() {
-        return StrCast(this.rootDoc.childLayoutString, this.props.childLayoutString);
-    }
-
     isContentActive = (outsideReaction?: boolean) => this.props.isContentActive() || this.isAnyChildContentActive();
 
     render() {
@@ -273,7 +234,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
             PanelHeight: this.props.PanelHeight,
             ScreenToLocalTransform: this.screenToLocalTransform,
             childLayoutTemplate: this.childLayoutTemplate,
-            childLayoutString: this.childLayoutString,
+            childLayoutString: StrCast(this.rootDoc.childLayoutString, this.props.childLayoutString),
             childHideResizeHandles: this.childHideResizeHandles,
             childHideDecorationTitle: this.childHideDecorationTitle,
         };
@@ -282,7 +243,6 @@ export class CollectionView extends ViewBoxAnnotatableComponent<ViewBoxAnnotatab
                 className="collectionView"
                 onContextMenu={this.onContextMenu}
                 style={{ pointerEvents: this.props.DocumentView?.()?.props.docViewPath().lastElement()?.rootDoc?._viewType === CollectionViewType.Freeform && this.rootDoc._lockedPosition ? 'none' : undefined }}>
-                {this.showIsTagged()}
                 {this.renderSubView(this.collectionViewType, props)}
             </div>
         );
-- 
cgit v1.2.3-70-g09d2

