From 5ba1920aba81abbd4d5680a4f8e42bb19c5f89e6 Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Sun, 24 May 2020 20:26:57 +0530 Subject: passing callback instead of CollectionGridView (this) --- .../collectionGrid/CollectionGridView.tsx | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/client/views/collections/collectionGrid/CollectionGridView.tsx') diff --git a/src/client/views/collections/collectionGrid/CollectionGridView.tsx b/src/client/views/collections/collectionGrid/CollectionGridView.tsx index ebb710af6..d06bb3192 100644 --- a/src/client/views/collections/collectionGrid/CollectionGridView.tsx +++ b/src/client/views/collections/collectionGrid/CollectionGridView.tsx @@ -112,12 +112,13 @@ export class CollectionGridView extends CollectionSubView(GridSchema) { />; } - //@action + /** * Saves the layouts received from the Grid to the Document. * @param layouts `Layout[]` */ - set layout(layouts: Layout[]) { + @undoBatch + setLayout(layouts: Layout[]) { console.log("setting layout in CollectionGridView"); console.log(layouts?.[0].w); @@ -197,6 +198,7 @@ export class CollectionGridView extends CollectionSubView(GridSchema) { /** * Checks whether a new node has been added to the grid and updates the Document accordingly. */ + @undoBatch checkUpdate() { const previousLength = (this.props.Document.gridLayouts as List)?.length; if (this.childLayoutPairs.length > previousLength) { @@ -216,16 +218,18 @@ export class CollectionGridView extends CollectionSubView(GridSchema) { this.checkUpdate(); + const docList: Doc[] = DocListCast(this.props.Document.gridLayouts); + const contents: JSX.Element[] = this.contents; - const layout: Layout[] = this.toLayoutList(DocListCast(this.props.Document.gridLayouts)); + const layout: Layout[] = this.toLayoutList(docList); - if (layout.length === 0) { - console.log("layouts not loaded"); - } - else { - console.log("rendering with this"); - console.log(layout[0].w); - } + // if (layout.length === 0) { + // console.log("layouts not loaded"); + // } + // else { + // console.log("rendering with this"); + // console.log(layout[0].w); + // } return ( @@ -235,15 +239,15 @@ export class CollectionGridView extends CollectionSubView(GridSchema) { marginTop: NumCast(this.props.Document._yMargin), marginBottom: NumCast(this.props.Document._yMargin) }} ref={this.createDashEventsTarget} - onPointerDown={(e: React.PointerEvent) => e.stopPropagation()} + //onPointerDown={(e: React.PointerEvent) => e.stopPropagation()} > this.setLayout(layout)} /> ); -- cgit v1.2.3-70-g09d2