diff options
| author | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-05-24 20:26:57 +0530 |
|---|---|---|
| committer | usodhi <61431818+usodhi@users.noreply.github.com> | 2020-05-24 20:26:57 +0530 |
| commit | 5ba1920aba81abbd4d5680a4f8e42bb19c5f89e6 (patch) | |
| tree | a7d7c52274e45c558bc108c0e88a9f13698a290a /src/client/views/collections/collectionGrid/CollectionGridView.tsx | |
| parent | 21a967e6daba3bf7048028d3ae6d8bd36c325e29 (diff) | |
passing callback instead of CollectionGridView (this)
Diffstat (limited to 'src/client/views/collections/collectionGrid/CollectionGridView.tsx')
| -rw-r--r-- | src/client/views/collections/collectionGrid/CollectionGridView.tsx | 28 |
1 files changed, 16 insertions, 12 deletions
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<Doc>)?.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()} > <Grid width={this.props.PanelWidth()} nodeList={contents} layout={layout} - gridView={this} numCols={this.props.Document.numCols as number} rowHeight={this.props.Document.rowHeight as number} + setLayout={(layout: Layout[]) => this.setLayout(layout)} /> </div> ); |
