(docList);
+ }
}
- // _.reject() on item removal?
-
-
/**
* @returns a list of `ContentFittingDocumentView`s inside wrapper divs.
* The key of the wrapper div must be the same as the `i` value of the corresponding layout.
@@ -165,12 +217,13 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
for (let i = 0; i < childLayoutPairs.length; i++) {
const { layout } = childLayoutPairs[i];
- const dxf = () => this.lookupIndividualTransform(docList?.[i]);
- const width = () => this.width(docList?.[i]);
- const height = () => this.height(docList?.[i]);
+ const dxf = () => this.lookupIndividualTransform(docList[i]);
+ const width = () => this.width(docList[i]);
+ const height = () => this.height(docList[i]);
collector.push(
{this.getDisplayDoc(layout, dxf, width, height)}
@@ -187,10 +240,20 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
toLayoutList(docLayoutList: Doc[]): Layout[] {
const layouts: Layout[] = [];
- for (const layout of docLayoutList) {
- layouts.push(
- { i: layout.i as string, x: layout.x as number, y: layout.y as number, w: layout.w as number, h: layout.h as number }
- );
+
+ if (this.props.Document.flexGrid) {
+ for (const layout of docLayoutList) {
+ layouts.push(
+ { i: layout.i as string, x: layout.x as number, y: layout.y as number, w: layout.w as number, h: layout.h as number, static: !(this.props.Document.flexGrid as boolean) }
+ );
+ }
+ }
+ else {
+ for (let i = 0; i < docLayoutList.length; i++) {
+ layouts.push(
+ { i: docLayoutList[i].i as string, x: 2 * (i % Math.floor(this.props.Document.numCols as number / 2)), y: 2 * Math.floor(i / Math.floor(this.props.Document.numCols as number / 2)), w: 2, h: 2, static: true }
+ );
+ }
}
return layouts;
}
@@ -204,9 +267,9 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
if (this.childLayoutPairs.length > previousLength) {
console.log("adding doc");
const layoutDoc: Doc = new Doc();
- layoutDoc.i = layoutDoc[Id];
- layoutDoc.x = 2 * (previousLength % 5);
- layoutDoc.y = 2 * Math.floor(previousLength / 5);
+ layoutDoc.i = this.childLayoutPairs[this.childLayoutPairs.length - 1].layout[Id];
+ layoutDoc.x = 2 * (previousLength % Math.floor(this.props.Document.numCols as number / 2));
+ layoutDoc.y = 2 * Math.floor(previousLength / Math.floor(this.props.Document.numCols as number / 2));
layoutDoc.w = 2;
layoutDoc.h = 2;
@@ -218,11 +281,18 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
this.checkUpdate();
+ //console.log("here first?");
+
const docList: Doc[] = DocListCast(this.props.Document.gridLayouts);
+ //console.log("doclist length:::" + docList.length);
const contents: JSX.Element[] = this.contents;
const layout: Layout[] = this.toLayoutList(docList);
+ // for (const doc of docList) {
+ // console.log(doc.i);
+ // }
+
// if (layout.length === 0) {
// console.log("layouts not loaded");
// }
@@ -247,7 +317,8 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
layout={layout}
numCols={this.props.Document.numCols as number}
rowHeight={this.props.Document.rowHeight as number}
- setLayout={(layout: Layout[]) => this.setLayout(layout)}
+ setLayout={this.setLayout}
+ flex={this.props.Document.flexGrid as boolean}
/>
);
--
cgit v1.2.3-70-g09d2