From d1fbfc3ab46cfd9fea69b356cb5b8825625ab299 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Thu, 22 Aug 2019 12:37:15 -0400 Subject: only shows children option if working entirely with collections --- src/client/views/MetadataEntryMenu.tsx | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/MetadataEntryMenu.tsx b/src/client/views/MetadataEntryMenu.tsx index 06084aac0..df6b7f721 100644 --- a/src/client/views/MetadataEntryMenu.tsx +++ b/src/client/views/MetadataEntryMenu.tsx @@ -97,7 +97,6 @@ export class MetadataEntryMenu extends React.Component{ } else { let childSuccess = true; if (this._addChildren) { - console.log(this._currentKey); for (let document of doc) { let collectionChildren = await DocListCastAsync(document.data); if (collectionChildren) { @@ -173,6 +172,29 @@ export class MetadataEntryMenu extends React.Component{ this._addChildren = !this._addChildren; } + private get considerChildOptions() { + let docSource = this.props.docs; + if (typeof docSource === "function") { + docSource = docSource(); + } + docSource = docSource as Doc[] | Doc; + if (docSource instanceof Doc) { + if (docSource.viewType === undefined) { + return (null); + } + } else if (Array.isArray(docSource)) { + if (!docSource.every(doc => doc.viewType !== undefined)) { + return null; + } + } + return ( +
+ Children: + +
+ ); + } + render() { return (
@@ -187,8 +209,7 @@ export class MetadataEntryMenu extends React.Component{ ref={this.autosuggestRef} /> Value: - Children: - + {this.considerChildOptions}
); } -- cgit v1.2.3-70-g09d2