diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingView.tsx | 56 | ||||
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx | 5 |
2 files changed, 29 insertions, 32 deletions
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<Partial<collecti // appears that pivot field IS actually for sorting if (!this.pivotField || this.columnHeaders instanceof Promise) return new Map<SchemaHeaderField, Doc[]>(); - // Shouldn't need, since we instantiate them in the constructor - // if (this.columnHeaders === undefined) { - // setTimeout(() => this.layoutDoc._columnHeaders = new List<SchemaHeaderField>(), 0); - // return new Map<SchemaHeaderField, Doc[]>(); - // } const columnHeaders = Array.from(this.columnHeaders); const fields = new Map<SchemaHeaderField, Doc[]>(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<Partial<collecti return this.props.addDocTab(doc, where); } - scrollToBottom = () => { - 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<Partial<collecti const height = () => this.getDocHeight(doc); let dref: Opt<DocumentView>; - 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 <DocumentView ref={r => dref = r || undefined} @@ -317,21 +310,26 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti } //TODO update this to - getDocTransform(doc: Doc, dref?: DocumentView) { - const y = this._scroll; // required for document decorations to update when the text box container is scrolled - const { scale, translateX, translateY } = Utils.GetScreenTransform(dref?.ContentDiv || undefined); + getDocTransform(doc: Doc) { + const {translateX, translateY } = Utils.GetScreenTransform(undefined); // the document view may center its contents and if so, will prepend that onto the screenToLocalTansform. so we have to subtract that off - return new Transform(- translateX + (dref?.centeringX || 0), - translateY + (dref?.centeringY || 0), 1).scale(this.props.ScreenToLocalTransform().Scale); + return new Transform(- translateX, - translateY, 1).scale(this.props.ScreenToLocalTransform().Scale); } //TODO do we actually want to update the doc width on this? - getDocWidth(d?: Doc) { - //TODO: defnitely a more efficient way to do this, but who cares - const headings = () => 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<Partial<collecti const insertInd = dropInd === -1 ? docs.length : dropInd + dropAfter; const offset = newDocs.reduce((off, ndoc) => 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<Partial<collecti addDocument={this.addDocument} chromeHidden={this.chromeHidden} columnHeaders={this.columnHeaders} + // resizeColumns={this.resizeColumns} Document={this.props.Document} DataDoc={this.props.DataDoc} renderChildren={this.children} diff --git a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx index 6bcd397aa..adfeab3b0 100644 --- a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx @@ -51,6 +51,7 @@ interface CSVFieldColumnProps { observeHeight: (myref: any) => void; unobserveHeight: (myref: any) => void; editableViewProps: any; + // resizeColumns: (n: number) => void } @observer @@ -143,12 +144,14 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFiel alert("You can't delete the last column! Going to remove delete button soon") return } + if (this.props.headingObject) { const index = this.props.columnHeaders.indexOf(this.props.headingObject); const newIndex = index == 0 ? 1 : index - 1 const newHeader = this.props.columnHeaders[newIndex]; this.props.docList.forEach(d => 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<CSVFiel <div key={`${this.props.Document[Id]}-addGroup`} className="collectionNoteTakingView-addDocumentButton"> <EditableView {...this.props.editableViewProps} /> </div> - {this.props.numGroupColumns > 1 && + {(this.props.columnHeaders?.length && this.props.columnHeaders.length > 1) && <button className="collectionStackingView-sectionDelete" onClick={this.deleteColumn}> <FontAwesomeIcon icon="trash" size="lg" /> </button> |