diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/MetadataEntryMenu.tsx | 18 | ||||
-rw-r--r-- | src/client/views/TemplateMenu.tsx | 18 | ||||
-rw-r--r-- | src/client/views/collections/CollectionTimeView.tsx | 2 |
3 files changed, 27 insertions, 11 deletions
diff --git a/src/client/views/MetadataEntryMenu.tsx b/src/client/views/MetadataEntryMenu.tsx index ac152bf67..23b21ae0c 100644 --- a/src/client/views/MetadataEntryMenu.tsx +++ b/src/client/views/MetadataEntryMenu.tsx @@ -133,7 +133,23 @@ export class MetadataEntryMenu extends React.Component<MetadataEntryProps>{ } getKeySuggestions = async (value: string): Promise<string[]> => { - return []; + value = value.toLowerCase(); + let docs = this.props.docs; + if (typeof docs === "function") { + if (this.props.suggestWithFunction) { + docs = docs(); + } else { + return []; + } + } + docs = await docs; + if (docs instanceof Doc) { + return Object.keys(docs).filter(key => key.toLowerCase().startsWith(value)); + } else { + const keys = new Set<string>(); + docs.forEach(doc => Doc.allKeys(doc).forEach(key => keys.add(key))); + return Array.from(keys).filter(key => key.toLowerCase().startsWith(value)); + } } getSuggestionValue = (suggestion: string) => suggestion; diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx index 9b0199eac..f61eb9cd0 100644 --- a/src/client/views/TemplateMenu.tsx +++ b/src/client/views/TemplateMenu.tsx @@ -94,15 +94,15 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> { } } componentDidMount() { - // !this._addedKeys && (this._addedKeys = new ObservableSet()); - // Array.from(Object.keys(Doc.GetProto(this.props.docViews[0].props.Document))). - // filter(key => key.startsWith("layout_")). - // map(key => runInAction(() => this._addedKeys.add(key.replace("layout_", "")))); - // DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => { - // if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) { - // runInAction(() => this._addedKeys.add(StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title))); - // } - // }); + !this._addedKeys && (this._addedKeys = new ObservableSet()); + Array.from(Object.keys(Doc.GetProto(this.props.docViews[0].props.Document))). + filter(key => key.startsWith("layout_")). + map(key => runInAction(() => this._addedKeys.add(key.replace("layout_", "")))); + DocListCast(Cast(CurrentUserUtils.UserDocument.expandingButtons, Doc, null)?.data)?.map(btnDoc => { + if (StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title)) { + runInAction(() => this._addedKeys.add(StrCast(Cast(btnDoc?.dragFactory, Doc, null)?.title))); + } + }); } _addedKeys = new ObservableSet(); diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index d1e2844df..253dfa890 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -43,7 +43,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { @computed get _allFacets() { const facets = new Set<string>(); - //this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key))); + this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key))); return facets.toArray(); } |