aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionNoteTakingView.tsx14
-rw-r--r--src/client/views/collections/CollectionNoteTakingViewColumn.tsx12
2 files changed, 12 insertions, 14 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 95aafce94..ec849d89d 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -2,7 +2,7 @@ import React = require('react');
import { CursorProperty } from 'csstype';
import { action, computed, IReactionDisposer, observable, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
-import { DataSym, Doc, HeightSym, Opt, WidthSym } from '../../../fields/Doc';
+import { DataSym, Doc, Field, HeightSym, Opt, WidthSym } from '../../../fields/Doc';
import { Id } from '../../../fields/FieldSymbols';
import { List } from '../../../fields/List';
import { listSpec } from '../../../fields/Schema';
@@ -327,15 +327,11 @@ 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 = StrCast(d[this.notetakingCategoryField], 'unset');
+ const heading = !d[this.notetakingCategoryField] ? 'unset' : Field.toString(d[this.notetakingCategoryField] as Field);
const existingHeader = this.columnHeaders.find(sh => sh.heading === heading);
- const colStartXCoords = this.columnStartXCoords;
- if (!existingHeader) {
- return 1000;
- }
- const index = this.columnHeaders.indexOf(existingHeader);
- const endColValue = index == this.columnHeaders.length - 1 ? this.PanelWidth : this.columnStartXCoords[index + 1];
- const maxWidth = endColValue - colStartXCoords[index] - 3 * this.xMargin;
+ const index = existingHeader ? this.columnHeaders.indexOf(existingHeader) : 0;
+ const endColValue = index === this.columnHeaders.length - 1 || index > this.columnStartXCoords.length - 1 ? this.PanelWidth : this.columnStartXCoords[index + 1];
+ const maxWidth = index > this.columnStartXCoords.length - 1 ? this.PanelWidth : endColValue - this.columnStartXCoords[index] - 3 * this.xMargin;
if (d.type === DocumentType.RTF) {
return maxWidth;
}
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index 62d954b9c..624beca96 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -21,6 +21,8 @@ import { ContextMenuProps } from '../ContextMenuItem';
import { EditableView } from '../EditableView';
import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
import './CollectionNoteTakingView.scss';
+import { listSpec } from '../../../fields/Schema';
+import { Cast } from '../../../fields/Types';
const higflyout = require('@hig/flyout');
export const { anchorPoints } = higflyout;
export const Flyout = higflyout.default;
@@ -67,7 +69,7 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
return this.props.maxColWidth;
}
const i = this.props.columnHeaders.indexOf(this.props.headingObject);
- if (i < 0) {
+ if (i < 0 || i > this.props.columnStartXCoords.length - 1) {
return this.props.maxColWidth;
}
const endColValue = i == this.props.numGroupColumns - 1 ? this.props.PanelWidth : this.props.columnStartXCoords[i + 1];
@@ -147,11 +149,11 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
@undoBatch
@action
deleteColumn = () => {
- if (this.props.columnHeaders && this.props.headingObject) {
- const index = this.props.columnHeaders.indexOf(this.props.headingObject);
+ const columnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null);
+ if (columnHeaders && this.props.headingObject) {
+ const index = columnHeaders.indexOf(this.props.headingObject);
this.props.docList.forEach(d => (d[this.props.pivotField] = 'unset'));
- this.props.columnHeaders.splice(index, 1);
- this.props.resizeColumns(this.props.columnHeaders.length);
+ columnHeaders.splice(index, 1);
}
};