diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-08-22 12:37:15 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-08-22 12:37:15 -0400 |
commit | d1fbfc3ab46cfd9fea69b356cb5b8825625ab299 (patch) | |
tree | 47b7648611fe81f4f4646d9938daabaaec2c44fa /src | |
parent | 616d71c6ad8b15b9736ada0754c557c2a81964bc (diff) |
only shows children option if working entirely with collections
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/MetadataEntryMenu.tsx | 27 |
1 files changed, 24 insertions, 3 deletions
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<MetadataEntryProps>{ } 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<MetadataEntryProps>{ 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 ( + <div style={{ display: "flex" }}> + Children: + <input type="checkbox" onChange={this.onClick} ></input> + </div> + ); + } + render() { return ( <div className="metadataEntry-outerDiv"> @@ -187,8 +209,7 @@ export class MetadataEntryMenu extends React.Component<MetadataEntryProps>{ ref={this.autosuggestRef} /> Value: <input className="metadataEntry-input" value={this._currentValue} onChange={this.onValueChange} onKeyDown={this.onValueKeyDown} /> - Children: - <input type="checkbox" onChange={this.onClick} ></input> + {this.considerChildOptions} </div > ); } |