From 862f7fdbddd37bc1cd818cff247c51278f35f4fc Mon Sep 17 00:00:00 2001 From: ljungster Date: Thu, 14 Apr 2022 11:52:25 -0400 Subject: commiting to go back --- .../views/collections/CollectionNoteTakingView.tsx | 56 ++++++++++------------ .../CollectionNoteTakingViewFieldColumn.tsx | 5 +- 2 files changed, 29 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 86b0aeed7..a441354d2 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -135,30 +135,23 @@ export class CollectionNoteTakingView extends CollectionSubView(); - // 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; this.filteredChildren.map(d => { if (!d[this.pivotField]) { - d[this.pivotField] = `1` + d[this.pivotField] = `First Column` }; const sectionValue = d[this.pivotField] as object; - // the next five lines ensures that floating point rounding errors don't create more than one section -syip - const parsed = parseInt(sectionValue.toString()); - const castedSectionValue = !isNaN(parsed) ? parsed : sectionValue; + const castedSectionValue = sectionValue.toString() // look for if header exists already - const existingHeader = columnHeaders.find(sh => sh.heading === (castedSectionValue ? castedSectionValue.toString() : `0`)); + const existingHeader = columnHeaders.find(sh => sh.heading === (castedSectionValue)); if (existingHeader) { fields.get(existingHeader)!.push(d); } else { - const newSchemaHeader = new SchemaHeaderField(castedSectionValue ? castedSectionValue.toString() : `0`); + const newSchemaHeader = new SchemaHeaderField(castedSectionValue.toString()); fields.set(newSchemaHeader, [d]); columnHeaders.push(newSchemaHeader); changed = true; @@ -219,9 +212,9 @@ export class CollectionNoteTakingView extends CollectionSubView { - smoothScroll(500, this._mainCont!, this._mainCont!.scrollHeight); - } + // scrollToBottom = () => { + // smoothScroll(500, this._mainCont!, this._mainCont!.scrollHeight); + // } // let's dive in and get the actual document we want to drag/move around focusDocument = (doc: Doc, options?: DocFocusOptions) => { @@ -263,7 +256,7 @@ export class CollectionNoteTakingView extends CollectionSubView this.getDocHeight(doc); let dref: Opt; - const stackedDocTransform = () => this.getDocTransform(doc, dref); + const stackedDocTransform = () => this.getDocTransform(doc); this._docXfs.push({ stackedDocTransform, width, height }); //DocumentView is how the node will be rendered return dref = r || undefined} @@ -317,21 +310,26 @@ export class CollectionNoteTakingView extends CollectionSubView Array.from(this.Sections); - const h = headings(); - const uniqueHeadings = h.map((i, idx) => h.indexOf(i) === idx); - const width = this.columnWidth / ((uniqueHeadings.length) || 1); - return width - 25; + getDocWidth(d: Doc) { + const heading = d[this.pivotField] as object + const castedSectionValue = heading.toString() + const existingHeader = this.columnHeaders.find(sh => sh.heading === (castedSectionValue)); + if (existingHeader) { + const index = this.columnHeaders.indexOf(existingHeader) + if (index == this.columnHeaders.length) { + // The -25 is arbitray and just looked nice + return this.props.PanelWidth() - this.columnStartXCoords[index] - 2 * this.gridGap + } + return this.columnStartXCoords[index + 1] - this.columnStartXCoords[index] - 2 * this.gridGap + } + return 1000; } getDocHeight(d?: Doc) { @@ -419,11 +417,6 @@ export class CollectionNoteTakingView extends CollectionSubView this.filteredChildren.find((fdoc, i) => ndoc === fdoc && i < insertInd) ? off + 1 : off, 0); newDocs.filter(ndoc => docs.indexOf(ndoc) !== -1).forEach(ndoc => docs.splice(docs.indexOf(ndoc), 1)); - // doesn't appear to be causing issues, but potentially could create - // if (this.placeHolderDown) { - // docs.splice(0, 1); - // this.placeHolderDown = false - // } docs.splice(insertInd - offset, 0, ...newDocs); } } @@ -583,6 +576,7 @@ export class CollectionNoteTakingView extends CollectionSubView void; unobserveHeight: (myref: any) => void; editableViewProps: any; + // resizeColumns: (n: number) => void } @observer @@ -143,12 +144,14 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component d[this.props.pivotField] = newHeader.heading.toString()) this.props.columnHeaders.splice(index, 1); + // this.props.resizeColumns(this.props.columnHeaders.length) } } @@ -327,7 +330,7 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component - {this.props.numGroupColumns > 1 && + {(this.props.columnHeaders?.length && this.props.columnHeaders.length > 1) && -- cgit v1.2.3-70-g09d2