From 3cf60a6118a5994e43c8ac9d00092992d6c83700 Mon Sep 17 00:00:00 2001 From: ljungster Date: Mon, 22 Aug 2022 11:03:31 -0400 Subject: can't add column if name in use --- src/client/views/collections/CollectionNoteTakingView.tsx | 9 +++++++-- .../views/collections/CollectionNoteTakingViewColumn.tsx | 14 ++++++++------ .../views/collections/CollectionNoteTakingViewDivider.tsx | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 9e40356d6..16fefc55a 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -587,10 +587,15 @@ export class CollectionNoteTakingView extends CollectionSubView { + for (const header of this.columnHeaders) { + if (header.heading == value) { + alert('You cannot use an existing column name. Please try a new column name'); + return value; + } + } const columnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null); const newColWidth = 1 / (this.numGroupColumns + 1); return value && columnHeaders?.push(new SchemaHeaderField(value, undefined, undefined, newColWidth)) && this.resizeColumns(true, newColWidth, this.columnHeaders.length - 1) ? true : false; @@ -607,7 +612,7 @@ export class CollectionNoteTakingView extends CollectionSubView { const movementX = this.props.ScreenToLocalTransform().transformDirection(movementXScreen, 0)[0]; diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx index a866373a9..e619b084b 100644 --- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx @@ -142,15 +142,19 @@ export class CollectionNoteTakingViewColumn extends React.Component { 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')); - // should never be 0, currently placeholder + const newColIndex = index > 0 ? index - 1 : 1; + const newColHeader = this.props.columnHeaders ? this.props.columnHeaders[newColIndex] : undefined; + const newHeading = newColHeader ? newColHeader.heading : 'unset'; + this.props.docList.forEach(d => (d[this.props.pivotField] = newHeading)); const colWidth = this.props.columnHeaders ? this.props.columnHeaders[index].width : 0; columnHeaders.splice(index, 1); this.props.resizeColumns(false, colWidth, index); @@ -279,9 +283,7 @@ export class CollectionNoteTakingViewColumn extends React.Component {!this.props.chromeHidden && type !== DocumentType.PRES ? ( -
+
diff --git a/src/client/views/collections/CollectionNoteTakingViewDivider.tsx b/src/client/views/collections/CollectionNoteTakingViewDivider.tsx index 7defeb031..8d659f790 100644 --- a/src/client/views/collections/CollectionNoteTakingViewDivider.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewDivider.tsx @@ -10,7 +10,7 @@ interface DividerProps { } /** - * CollectionNoteTakingViewDivider is a divider between CollectionNoteTakingViewColumns, + * CollectionNoteTakingViewDivider are dividers between CollectionNoteTakingViewColumns, * which only appear when there is more than 1 column in CollectionNoteTakingView. Dividers * are two simple vertical lines that allow the user to alter the widths of CollectionNoteTakingViewColumns. */ -- cgit v1.2.3-70-g09d2