aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-02-22 00:56:22 -0500
committerBob Zeleznik <zzzman@gmail.com>2020-02-22 00:56:22 -0500
commitc53d6c5df8b98bcf1c88316312497ea4198ae30a (patch)
treeabc75bfd50906ffdc4840fdf05073a46d4584595
parent1d13687df6acc2e575d0d8ddfbfec2b50f639dd5 (diff)
fixed freeform view to update its documents when a non-rendering (eg onClick script) property changes
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx8
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx11
2 files changed, 9 insertions, 10 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
index 8132d2f7c..7e37f646d 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
@@ -314,7 +314,7 @@ export function computeTimelineLayout(
function normalizeResults(panelDim: number[], fontHeight: number, childPairs: { data?: Doc, layout: Doc }[], docMap: Map<Doc, ViewDefBounds>,
poolData: Map<string, PoolData>, viewDefsToJSX: (views: ViewDefBounds[]) => ViewDefResult[], groupNames: ViewDefBounds[], minWidth: number, extras: ViewDefBounds[],
- extraDocs: Doc[]) {
+ extraDocs: Doc[]):ViewDefResult[] {
const grpEles = groupNames.map(gn => ({ x: gn.x, y: gn.y, width: gn.width, height: gn.height }) as ViewDefBounds);
const docEles = childPairs.filter(d => docMap.get(d.layout)).map(pair => docMap.get(pair.layout) as ViewDefBounds);
@@ -341,8 +341,7 @@ function normalizeResults(panelDim: number[], fontHeight: number, childPairs: {
});
extraDocs.map(ed => poolData.set(ed[Id], { x: 0, y: 0, zIndex: -99 }));
- return {
- elements: viewDefsToJSX(extras.concat(groupNames).map(gname => ({
+ return viewDefsToJSX(extras.concat(groupNames).map(gname => ({
type: gname.type,
text: gname.text,
x: gname.x * scale,
@@ -352,8 +351,7 @@ function normalizeResults(panelDim: number[], fontHeight: number, childPairs: {
height: gname.height === -1 ? 1 : Math.max(fontHeight, (gname.height || 0) * scale),
fontSize: gname.fontSize,
payload: gname.payload
- })))
- };
+ })));
}
export function AddCustomFreeFormLayout(doc: Doc, dataKey: string): () => void {
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index fa8a203b4..5902cc22e 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -808,7 +808,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
const pos = this.getCalculatedPositions({ doc: pair.layout, index: i, collection: this.Document, docs: layoutDocs, state });
poolData.set(pair.layout[Id], pos);
});
- return { elements: elements };
+ return elements;
}
@computed get doInternalLayoutComputation() {
@@ -869,8 +869,9 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
}));
this._cachedPool.clear();
Array.from(newPool.keys()).forEach(k => this._cachedPool.set(k, newPool.get(k)));
- this.childLayoutPairs.filter((pair, i) => this.isCurrent(pair.layout)).forEach(pair =>
- computedElementData.elements.push({
+ const elements:ViewDefResult[] = computedElementData.slice();
+ this.childLayoutPairs.filter(pair => this.isCurrent(pair.layout)).forEach(pair =>
+ elements.push({
ele: <CollectionFreeFormDocumentView key={pair.layout[Id]} {...this.getChildDocumentViewProps(pair.layout, pair.data)}
dataProvider={this.childDataProvider}
LayoutDoc={this.childLayoutDocFunc}
@@ -879,13 +880,13 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
bounds: this.childDataProvider(pair.layout)
}));
- return computedElementData;
+ return elements;
}
componentDidMount() {
super.componentDidMount();
this._layoutComputeReaction = reaction(() => this.doLayoutComputation,
- (computation) => this._layoutElements = computation?.elements.slice() || [],
+ (elements) => this._layoutElements = elements || [],
{ fireImmediately: true, name: "doLayout" });
}
componentWillUnmount() {