From 1404b81b7ef679b12a4b99cd5c82da4339a8efaf Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 22 Aug 2022 13:17:41 -0400 Subject: fixed undo of add/remove column in notetaking view by reordering @action @undoBatch to @undoBatch @action --- .../views/collections/CollectionNoteTakingView.tsx | 31 +++++++++++----------- .../collections/CollectionNoteTakingViewColumn.tsx | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 16fefc55a..81ca4dd98 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -40,7 +40,7 @@ export type collectionNoteTakingViewProps = { /** * CollectionNoteTakingView is a column-based view for displaying documents. In this view, the user can (1) * add and remove columns (2) change column sizes and (3) move documents within and between columns. This - * view is reminiscent of Kanban-style web apps like Trello, or the 'Board' view in Notion. Each column is + * view is reminiscent of Kanban-style web apps like Trello, or the 'Board' view in Notion. Each column is * headed by a SchemaHeaderField followed by the column's documents. SchemaHeaderFields are NOT present in * the rest of Dash, so it may be worthwhile to transition the headers to simple documents. */ @@ -51,7 +51,7 @@ export class CollectionNoteTakingView extends CollectionSubView(); @observable docsDraggedRowCol: number[] = []; @observable _cursor: CursorProperty = 'grab'; - @observable _scroll = 0; + @observable _scroll = 0; @computed get chromeHidden() { return this.props.chromeHidden || BoolCast(this.layoutDoc.chromeHidden); } @@ -96,7 +96,7 @@ export class CollectionNoteTakingView extends CollectionSubView user deletes the final column --> column widths are [0.625, 0.375]. @@ -400,7 +400,7 @@ export class CollectionNoteTakingView extends CollectionSubView { const numColumns = this.columnHeaders.length; @@ -479,8 +479,7 @@ export class CollectionNoteTakingView extends CollectionSubView { const type = 'number'; return ( @@ -585,16 +584,16 @@ 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; - } + 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); @@ -623,7 +622,7 @@ export class CollectionNoteTakingView extends CollectionSubView { const columnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null); if (columnHeaders && this.props.headingObject) { -- cgit v1.2.3-70-g09d2 From 007cc5159e3e624352bdb686c82b11d1173a5ad7 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 22 Aug 2022 13:44:05 -0400 Subject: from last --- src/fields/util.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fields/util.ts b/src/fields/util.ts index d87bb6656..b3cbbe241 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -445,8 +445,13 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any undo: action(() => { // console.log("undo $add: " + prop, diff.items) // bcz: uncomment to log undo diff.items.forEach((item: any) => { - const ind = receiver[prop].indexOf(item.value ? item.value() : item); - ind !== -1 && receiver[prop].splice(ind, 1); + if (item instanceof SchemaHeaderField) { + const ind = receiver[prop].findIndex((ele: any) => ele instanceof SchemaHeaderField && ele.heading === item.heading); + ind !== -1 && receiver[prop].splice(ind, 1); + } else { + const ind = receiver[prop].indexOf(item.value ? item.value() : item); + ind !== -1 && receiver[prop].splice(ind, 1); + } }); lastValue = ObjectField.MakeCopy(receiver[prop]); }), -- cgit v1.2.3-70-g09d2