From 20beef06518bfa08db60b8c5a06c637dab0f2b92 Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Mon, 27 Apr 2020 18:18:21 +0530 Subject: update to pull from master --- .../collectionGrid/CollectionGridView.scss | 4 +- .../collectionGrid/CollectionGridView.tsx | 52 +++++++++++++++------- .../views/collections/collectionGrid/Grid.tsx | 35 ++++++++++----- 3 files changed, 61 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionGrid/CollectionGridView.scss b/src/client/views/collections/collectionGrid/CollectionGridView.scss index 0f1b64fa6..8f12c1a24 100644 --- a/src/client/views/collections/collectionGrid/CollectionGridView.scss +++ b/src/client/views/collections/collectionGrid/CollectionGridView.scss @@ -8,7 +8,7 @@ .document-wrapper { display: flex; flex-direction: column; - width: 100px; - height: 100px; + width: 100%; + height: 100%; } } \ No newline at end of file diff --git a/src/client/views/collections/collectionGrid/CollectionGridView.tsx b/src/client/views/collections/collectionGrid/CollectionGridView.tsx index 70e0d41b9..b94bd02a1 100644 --- a/src/client/views/collections/collectionGrid/CollectionGridView.tsx +++ b/src/client/views/collections/collectionGrid/CollectionGridView.tsx @@ -1,4 +1,4 @@ -import { action, computed } from 'mobx'; +import { action, computed, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from "react"; import { Doc } from '../../../../new_fields/Doc'; @@ -13,23 +13,16 @@ import { CollectionSubView } from '../CollectionSubView'; import { List } from '../../../../new_fields/List'; import { returnZero } from '../../../../Utils'; import Grid from "./Grid"; +import { Layout } from "./Grid"; type GridSchema = makeInterface<[typeof documentSchema]>; const GridSchema = makeInterface(documentSchema); -interface Layout { - i: string; - x: number; - y: number; - w: number; - h: number; -} - - - export class CollectionGridView extends CollectionSubView(GridSchema) { + @observable private layouts: Layout[] | undefined; + /** * @returns the transform that will correctly place * the document decorations box, shifted to the right by @@ -46,7 +39,7 @@ export class CollectionGridView extends CollectionSubView(GridSchema) { if (candidate === layout) { return this.props.ScreenToLocalTransform().translate(-offset, 0); } - //offset += this.lookupPixels(candidate) + resizerWidth; + offset += 194 + 10; } return Transform.Identity(); // type coersion, this case should never be hit } @@ -82,17 +75,37 @@ export class CollectionGridView extends CollectionSubView(GridSchema) { />; } + //@action + set layout(layouts: Layout[]) { + this.layouts = layouts; + console.log(this.layouts[0]); + } + + @computed + get layout() { + if (this.layouts === undefined) { + this.layouts = []; + console.log("empty"); + for (let i = 0; i < this.childLayoutPairs.length; i++) { + this.layouts.push( + { i: 'wrapper' + i, x: 2 * (i % 5), y: 2 * Math.floor(i / 5), w: 2, h: 2 } + ); + } + } + return this.layouts; + } + @computed private get contents(): [JSX.Element[], Layout[]] { const { childLayoutPairs } = this; const { Document } = this.props; const collector: JSX.Element[] = []; - const layoutArray = []; + const layoutArray: Layout[] = []; for (let i = 0; i < childLayoutPairs.length; i++) { const { layout } = childLayoutPairs[i]; const dxf = () => this.lookupIndividualTransform(layout).translate(-NumCast(Document._xMargin), -NumCast(Document._yMargin)); - const width = () => this.props.PanelWidth() / 5 - 20; //this.lookupPixels(layout); - const height = () => 200;//PanelHeight() - 2 * NumCast(Document._yMargin) - (BoolCast(Document.showWidthLabels) ? 20 : 0); + const width = () => 300; //this.lookupPixels(layout); + const height = () => 300;//PanelHeight() - 2 * NumCast(Document._yMargin) - (BoolCast(Document.showWidthLabels) ? 20 : 0); collector.push(