diff options
author | bobzel <zzzman@gmail.com> | 2022-08-04 11:01:37 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2022-08-04 11:01:37 -0400 |
commit | dbf21b19ecc70047a580023104d05aed0d43c946 (patch) | |
tree | 469124f73d55a6d0cd0e53dbd2918e49abfdc77f /src/client/views/collections/CollectionNoteTakingView.tsx | |
parent | 29d0c334b0bb28b6ae6e1f94fae12d1b4ee0e545 (diff) |
fixed notetaking view to have an 'unset' category for unassigned notes. fixed pivot view to not fail when docs have no width.
Diffstat (limited to 'src/client/views/collections/CollectionNoteTakingView.tsx')
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingView.tsx | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 989719c80..f24b98621 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -55,10 +55,18 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti return this.props.chromeHidden || BoolCast(this.layoutDoc.chromeHidden); } @computed get columnHeaders() { - return Cast(this.dataDoc.columnHeaders, listSpec(SchemaHeaderField), null); + const columnHeaders = Cast(this.dataDoc.columnHeaders, listSpec(SchemaHeaderField), null); + let docs = this.childDocs; + const needsUnsetCategory = docs.some(d => { + return !d[this.notetakingCategoryField] && !columnHeaders.find(sh => sh.heading === 'unset'); + }); + if (needsUnsetCategory) { + columnHeaders.push(new SchemaHeaderField('unset')); + } + return columnHeaders; } @computed get notetakingCategoryField() { - return 'noteTakingCategory'; + return 'NotetakingCategory'; } @computed get filteredChildren() { return this.childLayoutPairs.filter(pair => pair.layout instanceof Doc && !pair.layout.hidden).map(pair => pair.layout); @@ -120,8 +128,8 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti // (2) documentView gets unmounted as you remove it from the list get Sections() { const columnHeaders = this.columnHeaders; - const sections = new Map<SchemaHeaderField, Doc[]>(columnHeaders.map(sh => [sh, []] as [SchemaHeaderField, []])); let docs = this.childDocs; + const sections = new Map<SchemaHeaderField, Doc[]>(columnHeaders.map(sh => [sh, []] as [SchemaHeaderField, []])); const rowCol = this.docsDraggedRowCol; // filter out the currently dragged docs from the child docs, since we will insert them later @@ -133,10 +141,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti // this will sort the docs into the correct columns (minus the ones you're currently dragging) docs.map(d => { - if (!d[this.notetakingCategoryField]) { - d[this.notetakingCategoryField] = columnHeaders.length > 0 ? columnHeaders[0].heading : `New Column`; - } - const sectionValue = d[this.notetakingCategoryField] as object; + const sectionValue = (d[this.notetakingCategoryField] as object) ?? `unset`; // look for if header exists already const existingHeader = columnHeaders.find(sh => sh.heading === sectionValue.toString()); @@ -310,7 +315,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti // how to get the width of a document. Currently returns the width of the column (minus margins) // if a note doc. Otherwise, returns the normal width (for graphs, images, etc...) getDocWidth(d: Doc) { - const heading = d[this.notetakingCategoryField] as object; + const heading = (d[this.notetakingCategoryField] as object) ?? 'unset'; const castedSectionValue = heading.toString(); const existingHeader = this.columnHeaders.find(sh => sh.heading === castedSectionValue); const colStartXCoords = this.columnStartXCoords; @@ -364,7 +369,6 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti // This function is used to preview where a document will drop in a column once a drag is complete. @action onPointerOver = (ex: number, ey: number) => { - console.log('Pover9ing = '); if (this.childDocList) { // get the current docs for the column based on the mouse's x coordinate // will use again later, which is why we're saving as local @@ -386,7 +390,6 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti } pos0 = pos1; }); - console.log('Pover = ' + dropInd + ' ' + this.getColumnFromXCoord(xCoord)); // we alter the pivot fields of the docs in case they are moved to a new column. const colIndex = this.getColumnFromXCoord(xCoord); const colHeader = StrCast(this.columnHeaders[colIndex].heading); @@ -422,7 +425,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti if (docs) { docs.map(d => { if (d instanceof Promise) return; - const sectionValue = d[this.notetakingCategoryField] as object; + const sectionValue = (d[this.notetakingCategoryField] as object) ?? 'unset'; if (sectionValue.toString() == colHeader) { docsMatchingHeader.push(d); } @@ -619,7 +622,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti const col = this.sectionNoteTaking(sections[i][0], sections[i][1]); eles.push(col); if (i < sections.length - 1) { - eles.push(<CollectionNoteTakingViewDivider index={i + 1} setColumnStartXCoords={this.setColumnStartXCoords.bind(this)} xMargin={this.xMargin} />); + eles.push(<CollectionNoteTakingViewDivider key={`divider${i}`} index={i + 1} setColumnStartXCoords={this.setColumnStartXCoords.bind(this)} xMargin={this.xMargin} />); } } return eles; @@ -686,7 +689,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti return ( <> {buttonMenu || noviceExplainer ? ( - <div className="documentButtonMenu"> + <div className="documentButtonMenu" key="buttons"> {buttonMenu ? this.buttonMenu : null} {Doc.UserDoc().noviceMode && noviceExplainer ? <div className="documentExplanation">{noviceExplainer}</div> : null} </div> @@ -694,6 +697,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti <div className="collectionNoteTakingView" ref={this.createRef} + key="notes" style={{ overflowY: this.props.isContentActive() ? 'auto' : 'hidden', background: this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor), |