From c4fe80267042de738ea18f2dadd4046d9a8607e3 Mon Sep 17 00:00:00 2001 From: ljungster Date: Thu, 21 Apr 2022 10:54:45 -0400 Subject: cleaned up --- .../collections/CollectionNoteTakingView.scss | 112 +++++----------- .../views/collections/CollectionNoteTakingView.tsx | 146 ++++++--------------- .../CollectionNoteTakingViewFieldColumn.tsx | 129 ++++++++---------- 3 files changed, 126 insertions(+), 261 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionNoteTakingView.scss b/src/client/views/collections/CollectionNoteTakingView.scss index b6bb8ce2b..c0297a648 100644 --- a/src/client/views/collections/CollectionNoteTakingView.scss +++ b/src/client/views/collections/CollectionNoteTakingView.scss @@ -47,20 +47,10 @@ } } -.collectionMasonryView { - display: inline; -} - -.collectionStackingView { +.collectionNoteTakingView { display: flex; } -.collectionStackingMasonry-cont { - position: relative; - height: 100%; - width: 100%; -} - // TODO:glr Turn this into a seperate class .documentButtonMenu { position: relative; @@ -85,8 +75,7 @@ } } -.collectionStackingView, -.collectionMasonryView { +.collectionNoteTakingView { height: 100%; width: 100%; position: absolute; @@ -101,11 +90,11 @@ display: block; } - .collectionStackingViewFieldColumn { + .collectionNoteTakingViewFieldColumn { height: max-content; } - .collectionStackingViewFieldColumnDragging { + .collectionNoteTakingViewFieldColumnDragging { height: 100%; } @@ -114,41 +103,14 @@ position: absolute; } - .collectionStackingView-docView-container { + .collectionNoteTakingView-docView-container { width: 45%; margin: 5% 2.5%; padding-left: 2.5%; height: auto; } - .collectionStackingView-flexCont { - display: flex; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - } - - .collectionStackingView-masonrySingle, - .collectionStackingView-masonryGrid { - width: 100%; - display: grid; - top: 0; - left: 0; - } - - .collectionStackingView-masonrySingle { - height: 100%; - position: absolute; - } - - .collectionStackingView-masonryGrid { - margin: auto; - height: max-content; - position: relative; - grid-auto-rows: 0px; - } - - .collectionStackingView-masonrySingle { + .collectionNoteTakingView-Nodes { width: 100%; height: 100%; position: absolute; @@ -160,7 +122,7 @@ position: absolute; } - .collectionStackingView-description { + .collectionNoteTakingView-description { font-size: 100%; margin-bottom: 1vw; padding: 10px; @@ -171,15 +133,15 @@ color: $white; } - .collectionStackingView-columnDragger { + .collectionNoteTakingView-columnDragger { width: 15; height: 15; position: absolute; margin-left: -5; } - // Documents in stacking view - .collectionStackingView-columnDoc { + // Documents in NoteTaking view + .collectionNoteTakingView-columnDoc { display: flex; // margin: auto; // Removed auto so that it is no longer center aligned - this could be something we change position: relative; @@ -211,19 +173,7 @@ } } - .collectionStackingView-masonryDoc { - transform-origin: top left; - grid-column-end: span 1; - height: 100%; - margin: auto; - display: inline-grid; - } - - .collectionStackingView-masonrySection { - margin: auto; - } - - .collectionStackingView-collapseBar { + .collectionNoteTakingView-collapseBar { margin-left: 2px; margin-right: 2px; margin-top: 2px; @@ -237,7 +187,7 @@ } } - .collectionStackingView-miniHeader { + .collectionNoteTakingView-miniHeader { width: 100%; .editableView-container-editing-oneLine { @@ -276,7 +226,7 @@ } } - .collectionStackingView-sectionHeader { + .collectionNoteTakingView-sectionHeader { text-align: center; margin: auto; margin-bottom: 10px; @@ -293,7 +243,7 @@ cursor: text } - .collectionStackingView-sectionHeader-subCont { + .collectionNoteTakingView-sectionHeader-subCont { outline: none; border: 0px; width: 100%; @@ -329,7 +279,7 @@ } } - .collectionStackingView-sectionColor { + .collectionNoteTakingView-sectionColor { position: absolute; left: 0; top: 0; @@ -340,12 +290,12 @@ max-width: 102px; } - .collectionStackingView-sectionColorButton { + .collectionNoteTakingView-sectionColorButton { height: 30px; display: inherit; } - .collectionStackingView-colorPicker { + .collectionNoteTakingView-colorPicker { width: 78px; z-index: 10; position: relative; @@ -371,7 +321,7 @@ } } - .collectionStackingView-sectionOptions { + .collectionNoteTakingView-sectionOptions { position: absolute; right: 0; top: 0; @@ -382,11 +332,11 @@ max-width: 102px; } - .collectionStackingView-sectionOptionButton { + .collectionNoteTakingView-sectionOptionButton { height: 30px; } - .collectionStackingView-optionPicker { + .collectionNoteTakingView-optionPicker { .optionOptions { display: inline; @@ -406,7 +356,7 @@ } } - .collectionStackingView-sectionDelete { + .collectionNoteTakingView-sectionDelete { position: absolute; right: 25px; top: 0; @@ -415,22 +365,22 @@ } } - .collectionStackingView-sectionHeader:hover { - .collectionStackingView-sectionColor { + .collectionNoteTakingView-sectionHeader:hover { + .collectionNoteTakingView-sectionColor { display: unset; } - .collectionStackingView-sectionOptions { + .collectionNoteTakingView-sectionOptions { display: unset; } - .collectionStackingView-sectionDelete { + .collectionNoteTakingView-sectionDelete { display: unset; } } - .collectionStackingView-addDocumentButton, - .collectionStackingView-addGroupButton { + .collectionNoteTakingView-addDocumentButton, + .collectionNoteTakingView-addGroupButton { display: flex; overflow: hidden; margin: auto; @@ -459,7 +409,7 @@ } } - .collectionStackingView-addDocumentButton { + .collectionNoteTakingView-addDocumentButton { font-size: 75%; letter-spacing: 2px; cursor: pointer; @@ -473,7 +423,7 @@ } } - .collectionStackingView-addGroupButton { + .collectionNoteTakingView-addGroupButton { background: rgb(238, 238, 238); font-size: 75%; text-align: center; @@ -531,8 +481,8 @@ @media only screen and (max-device-width: 480px) { - .collectionStackingView .collectionStackingView-columnDragger, - .collectionMasonryView .collectionStackingView-columnDragger { + .collectionNoteTakingView .collectionNoteTakingView-columnDragger, + .collectionNoteTakingView-columnDragger { width: 0.1; height: 0.1; opacity: 0; diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 35f27a862..ff9e22ce1 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -45,14 +45,9 @@ export class CollectionNoteTakingView extends CollectionSubView(); // keeping track of documents. Updated on internal and external drops. What's the difference? - _docXfs: { height: () => number, width: () => number, stackedDocTransform: () => Transform }[] = []; - // Doesn't look like this field is being used anywhere. Obsolete? - _columnStart: number = 0; - // map of node headers to their heights. Used in Masonry - @observable _heightMap = new Map(); + _docXfs: { height: () => number, width: () => number, noteTakingDocTransform: () => Transform }[] = []; // Assuming that this is the current css cursor style @observable _cursor: CursorProperty = "grab"; // gets reset whenever we scroll. Not sure what it is @@ -71,19 +66,8 @@ export class CollectionNoteTakingView extends CollectionSubView { const height = () => this.getDocHeight(d); const width = () => this.getDocWidth(d); - // assuming we need to get rowSpan because we might be dealing with many columns. Grid gap makes sense if multiple columns - const rowSpan = Math.ceil((height() + this.gridGap) / this.gridGap); - // added 50 to width. May need to change that elsewhere later - const style = this.isStackingView ? { width: width(), marginTop: i ? this.gridGap : 0, height: height() } : { gridRowEnd: `span ${rowSpan}` }; - // So we're choosing whether we're going to render a column or a masonry doc - return
+ const style = { width: width(), marginTop: i ? this.gridGap : 0, height: height() }; + return
{this.getDisplayDoc(d, width)}
; }); } - // @action - // setDocHeight = (key: string, sectionHeight: number) => { - // this._heightMap.set(key, sectionHeight); - // } get Sections() { // appears that pivot field IS actually for sorting if (!this.pivotField || this.columnHeaders instanceof Promise) return new Map(); - - // Shouldn't need, since we instantiate them in the constructor - // if (this.columnHeaders === undefined) { - // setTimeout(() => this.layoutDoc._columnHeaders = new List(), 0); - // return new Map(); - // } const columnHeaders = Array.from(this.columnHeaders); const fields = new Map(columnHeaders.map(sh => [sh, []] as [SchemaHeaderField, []])); let changed = false; @@ -187,9 +157,7 @@ export class CollectionNoteTakingView extends CollectionSubView this.layoutDoc._autoHeight, autoHeight => autoHeight && this.props.setHeight(Math.min(NumCast(this.layoutDoc._maxHeight, Number.MAX_SAFE_INTEGER), - this.headerMargin + (this.isStackingView ? - Math.max(...this.refList.map(r => Number(getComputedStyle(r).height.replace("px", "")))) : - this.refList.reduce((p, r) => p + Number(getComputedStyle(r).height.replace("px", "")), 0))))); + this.headerMargin + Math.max(...this.refList.map(r => Number(getComputedStyle(r).height.replace("px", ""))))))); } componentWillUnmount() { @@ -262,8 +230,8 @@ export class CollectionNoteTakingView extends CollectionSubView this.getDocHeight(doc); let dref: Opt; - const stackedDocTransform = () => this.getDocTransform(doc, dref); - this._docXfs.push({ stackedDocTransform, width, height }); + const noteTakingDocTransform = () => this.getDocTransform(doc, dref); + this._docXfs.push({ noteTakingDocTransform, width, height }); //DocumentView is how the node will be rendered return dref = r || undefined} Document={doc} @@ -293,7 +261,7 @@ export class CollectionNoteTakingView extends CollectionSubView - -
; - } + //TODO: currently unused. How can we make use of it? + // @computed get columnDragger() { + // return
+ // + //
; + // } resizeColumns = (n: number) => { const totalWidth = this.props.PanelWidth() @@ -402,8 +371,8 @@ export class CollectionNoteTakingView extends CollectionSubView { //TODO need to write your own function for this, or make sure you're properly updating the fields - const pos = cd.stackedDocTransform().inverse().transformPoint(0, -2 * this.gridGap); - const pos1 = cd.stackedDocTransform().inverse().transformPoint(0, cd.height()); + const pos = cd.noteTakingDocTransform().inverse().transformPoint(0, -2 * this.gridGap); + const pos1 = cd.noteTakingDocTransform().inverse().transformPoint(0, cd.height()); // checking whethere the copied element is in between the top of the doc and the grid gap // (meaning that this is the index it will be taking) const yCoordInBetween = clientY > pos[1] && (clientY < pos1[1] || i == this._docXfs.length - 1) @@ -470,19 +439,18 @@ export class CollectionNoteTakingView extends CollectionSubView { - const pos = cd.stackedDocTransform().inverse().transformPoint(-2 * this.gridGap, -2 * this.gridGap); - const pos1 = cd.stackedDocTransform().inverse().transformPoint(cd.width(), cd.height()); + const pos = cd.noteTakingDocTransform().inverse().transformPoint(-2 * this.gridGap, -2 * this.gridGap); + const pos1 = cd.noteTakingDocTransform().inverse().transformPoint(cd.width(), cd.height()); // const top = cd.height(); - // const pos = cd.stackedDocTransform().transformPoint(0, cd.height()); + // const pos = cd.noteTakingDocTransform().transformPoint(0, cd.height()); // TODO: plan // Get the top of the box // Check if there could possibly be a box below - // const pos1 = cd.stackedDocTransform().transformPoint(0, cd.height()); + // const pos1 = cd.noteTakingDocTransform().transformPoint(0, cd.height()); // if (where[0] > pos[0] && where[0] < pos1[0] && where[1] > pos[1] && (i === this._docXfs.length - 1 || where[1] < pos1[1])) { if (where[1] > pos[1] && (i === this._docXfs.length - 1 || where[1] < pos1[1])) { dropInd = i; - // const axis = this.isStackingView ? 1 : 0; const axis = 1; dropAfter = where[axis] > (pos[axis] + pos1[axis]) / 2 ? 1 : 0; } @@ -538,8 +506,8 @@ export class CollectionNoteTakingView extends CollectionSubView { - const pos = cd.stackedDocTransform().inverse().transformPoint(-2 * this.gridGap, -2 * this.gridGap); - const pos1 = cd.stackedDocTransform().inverse().transformPoint(cd.width(), cd.height()); + const pos = cd.noteTakingDocTransform().inverse().transformPoint(-2 * this.gridGap, -2 * this.gridGap); + const pos1 = cd.noteTakingDocTransform().inverse().transformPoint(cd.width(), cd.height()); if (where[0] > pos[0] && where[0] < pos1[0] && where[1] > pos[1] && where[1] < pos1[1]) { targInd = i; } @@ -558,7 +526,7 @@ export class CollectionNoteTakingView extends CollectionSubView Array.from(this.Sections); refList: any[] = []; - sectionStacking = (heading: SchemaHeaderField | undefined, docList: Doc[]) => { + sectionNoteTaking = (heading: SchemaHeaderField | undefined, docList: Doc[]) => { // const key = this.pivotField; const type = "number"; return this.isStackingView ? this.sectionStacking(section[0], section[1]) : this.sectionMasonry(section[0], section[1], i === 0)); //TODO need to add the divs in const eles: JSX.Element[] = [] for (let i = 0; i < sections.length; i++) { - const col = this.sectionStacking(sections[i][0], sections[i][1]) + const col = this.sectionNoteTaking(sections[i][0], sections[i][1]) eles.push(col) //TODO make this look pretty // if (i < sections.length - 1) { // eles.push( - //
+ //
// new div //
// ) // } } return eles - // return sections.map((section) => this.sectionStacking(section[0], section[1])); + // return sections.map((section) => this.sectionNoteTaking(section[0], section[1])); } @computed get buttonMenu() { @@ -716,13 +682,6 @@ export class CollectionNoteTakingView extends CollectionSubView "", - // SetValue: this.addGroup, - // // I don't recall ever seeing this add a group button - // contents: "+ ADD A COLUMN" - // }; const buttonMenu = this.rootDoc.buttonMenu; const noviceExplainer = this.rootDoc.explainer; return ( @@ -736,39 +695,20 @@ export class CollectionNoteTakingView extends CollectionSubView : null} -
-
this._scroll = e.currentTarget.scrollTop)} - onPointerOver={this.onPointerOver} - onPointerDown={this.onPointerDown} - onDrop={this.onExternalDrop.bind(this)} - onContextMenu={this.onContextMenu} - // Todo: what is wheel? Are we talking about a mouse wheel? - onWheel={e => this.props.isContentActive(true) && e.stopPropagation()} > - {/* so it appears that we are actually rendering the sections. Maybe this is what we're looking for? */} - {this.renderedSections} - {/* I think that showAddGroup must be passed in as false, which is why we can't find what Mehek showed - Or it's because we aren't passing a pivot field */} - {/* {!this.showAddAGroup ? (null) : -
- -
} */} - {/* {this.chromeHidden || !this.props.isSelected() ? (null) : - } */} -
+
this._scroll = e.currentTarget.scrollTop)} + onPointerOver={this.onPointerOver} + onPointerDown={this.onPointerDown} + onDrop={this.onExternalDrop.bind(this)} + onContextMenu={this.onContextMenu} + onWheel={e => this.props.isContentActive(true) && e.stopPropagation()} > + {this.renderedSections}
diff --git a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx index 605ee4b41..b4e0aac60 100644 --- a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx @@ -3,13 +3,14 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { action, computed, observable } from "mobx"; import { observer } from "mobx-react"; import { Doc, DocListCast, Opt } from "../../../fields/Doc"; +import { Id } from "../../../fields/FieldSymbols"; import { RichTextField } from "../../../fields/RichTextField"; -import { PastelSchemaPalette, SchemaHeaderField } from "../../../fields/SchemaHeaderField"; +import { SchemaHeaderField } from "../../../fields/SchemaHeaderField"; import { ScriptField } from "../../../fields/ScriptField"; -import { Cast, NumCast, StrCast } from "../../../fields/Types"; +import { NumCast } from "../../../fields/Types"; import { ImageField } from "../../../fields/URLField"; import { TraceMobx } from "../../../fields/util"; -import { emptyFunction, setupMoveUpEvents, returnFalse, returnEmptyString } from "../../../Utils"; +import { emptyFunction, returnEmptyString, setupMoveUpEvents } from "../../../Utils"; import { Docs, DocUtils } from "../../documents/Documents"; import { DocumentType } from "../../documents/DocumentTypes"; import { DragManager } from "../../util/DragManager"; @@ -19,9 +20,8 @@ import { undoBatch } from "../../util/UndoManager"; import { ContextMenu } from "../ContextMenu"; import { ContextMenuProps } from "../ContextMenuItem"; import { EditableView } from "../EditableView"; -import "./CollectionNoteTakingView.scss"; import { FormattedTextBox } from "../nodes/formattedText/FormattedTextBox"; -import { Id } from "../../../fields/FieldSymbols"; +import "./CollectionNoteTakingView.scss"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -42,7 +42,6 @@ interface CSVFieldColumnProps { gridGap: number; type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined; headings: () => object[]; - // I think that stacking view actually has a single column and then supposedly you can add more columns? Unsure renderChildren: (docs: Doc[]) => JSX.Element[]; addDocument: (doc: Doc | Doc[]) => boolean; createDropTarget: (ele: HTMLDivElement) => void; @@ -60,7 +59,6 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component = React.createRef(); - @observable _paletteOn = false; @observable _heading = this.props.headingObject ? this.props.headingObject.heading : this.props.heading; @observable _color = this.props.headingObject ? this.props.headingObject.color : "#f1efeb"; _ele: HTMLElement | null = null; @@ -75,16 +73,17 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component { const drop = { docs: de.complete.docDragData?.droppedDocuments, val: this.getValue(this._heading) }; drop.docs?.forEach(d => Doc.SetInPlace(d, this.props.pivotField, drop.val, false)); }); + getValue = (value: string): any => { const parsed = parseInt(value); if (!isNaN(parsed)) return parsed; @@ -110,12 +109,6 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component { - this.props.headingObject?.setColor(color); - this._color = color; - } - @action pointerEntered = () => SnappingManager.GetIsDragging() && (this._background = "#b4b4b4"); @action pointerLeave = () => this._background = "inherit"; textCallback = (char: string) => this.addNewTextDoc("-typed text-", false, true); @@ -154,12 +147,6 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component { - this.props.headingObject?.setCollapsed(!this.props.headingObject.collapsed); - this.toggleVisibility(); - } - headerDown = (e: React.PointerEvent) => setupMoveUpEvents(this, e, this.startDrag, emptyFunction, emptyFunction); //TODO: I think this is where I'm supposed to edit stuff @@ -181,10 +168,6 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component this.collapsed = !this.collapsed); - menuCallback = (x: number, y: number) => { ContextMenu.Instance.clearItems(); const layoutItems: ContextMenuProps[] = []; @@ -234,9 +217,9 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component headings.indexOf(i) === idx); const evContents = heading ? heading : "25"; const headingView = this.props.headingObject ? -
- {/*
*/} - {/* the default bucket (no key value) has a tooltip that describes what it is. - Further, it does not have a color and cannot be deleted. */} -
@@ -264,57 +244,52 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component - {/* {evContents === `0` ? (null) : <>} */} + />
: (null); const templatecols = `${this.props.columnWidth / this.props.numGroupColumns}px `; const type = this.props.Document.type; return <> - {this.props.Document._columnsHideIfEmpty ? (null) : headingView} - { - this.collapsed ? (null) : -
-
- {this.props.renderChildren(this.props.docList)} -
- - {!this.props.chromeHidden && type !== DocumentType.PRES ? -
-
- -
-
- -
- {(this.props.columnHeaders?.length && this.props.columnHeaders.length > 1) && - - } -
- : null} + {headingView} + {
+
+ {this.props.renderChildren(this.props.docList)} +
-
+ {!this.props.chromeHidden && type !== DocumentType.PRES ? +
+
+ +
+
+ +
+ {(this.props.columnHeaders?.length && this.props.columnHeaders.length > 1) && + + } +
+ : null} +
} ; } @@ -326,9 +301,9 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component headings.indexOf(i) === idx); return ( -