aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionStackingView.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-08-15 16:03:33 -0400
committerbob <bcz@cs.brown.edu>2019-08-15 16:03:33 -0400
commit2eb7d4e96a48dc841cece27afac7f6b1d2609ae9 (patch)
treeaf8b1af52019da536b3ddad02364152735df6bab /src/client/views/collections/CollectionStackingView.tsx
parentafb3e5d23e101044d148345de731285b468932b2 (diff)
added childLayout target -- only works for stackingpanel right now.
Diffstat (limited to 'src/client/views/collections/CollectionStackingView.tsx')
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 9900049c1..c3c1f2108 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -59,7 +59,8 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
if (!this.sectionFilter || this.sectionHeaders instanceof Promise) return new Map<SchemaHeaderField, Doc[]>();
if (this.sectionHeaders === undefined) {
- this.props.Document.sectionHeaders = new List<SchemaHeaderField>();
+ setTimeout(() => this.props.Document.sectionHeaders = new List<SchemaHeaderField>(), 0);
+ return new Map<SchemaHeaderField, Doc[]>();
}
const sectionHeaders = this.sectionHeaders!;
let fields = new Map<SchemaHeaderField, Doc[]>(sectionHeaders.map(sh => [sh, []] as [SchemaHeaderField, []]));
@@ -83,7 +84,19 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
return fields;
}
+ childLayoutDisposer?: IReactionDisposer;
componentDidMount() {
+ this.childLayoutDisposer = reaction(() => this.props.Document.childLayout,
+ async () => {
+ let chidlLayout = Cast(this.props.Document.childLayout, Doc);
+ if (chidlLayout instanceof Doc) {
+ const childLayout = chidlLayout;
+ let list = await this.childDocList;
+ list && list.map(async doc => {
+ !Doc.AreProtosEqual(childLayout, (await doc).layout as Doc) && Doc.ApplyTemplateTo(childLayout, (await doc), undefined);
+ });
+ }
+ });
// is there any reason this needs to exist? -syip. yes, it handles autoHeight for stacking views (masonry isn't yet supported).
this._heightDisposer = reaction(() => {
if (this.isStackingView && BoolCast(this.props.Document.autoHeight)) {
@@ -108,6 +121,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
);
}
componentWillUnmount() {
+ this.childLayoutDisposer && this.childLayoutDisposer();
this._heightDisposer && this._heightDisposer();
this._sectionFilterDisposer && this._sectionFilterDisposer();
}