-
Notifications
You must be signed in to change notification settings - Fork 396
Catalog search provider #7834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Catalog search provider #7834
Changes from 4 commits
f5c5ae4
db4ce66
c23f9b2
6e098bc
a4f7c2e
ae8c379
b9deaa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,18 +7,33 @@ import Terria from "../Terria"; | |
| import Group from "./Group"; | ||
| import { BaseModel } from "../Definition/Model"; | ||
| import isDefined from "../../Core/isDefined"; | ||
| import CatalogSearchProviderMixin from "../../ModelMixins/SearchProviders/CatalogSearchProviderMixin"; | ||
| import CatalogSearchProvider from "../SearchProviders/CatalogSearchProvider"; | ||
|
|
||
| export default class Catalog { | ||
| @observable | ||
| group: Group & BaseModel; | ||
|
|
||
| @observable | ||
| searchProvider: CatalogSearchProviderMixin.Instance | undefined; | ||
|
|
||
| readonly terria: Terria; | ||
|
|
||
| private _disposeCreateUserAddedGroup: () => void; | ||
|
|
||
| constructor(terria: Terria) { | ||
| constructor( | ||
| terria: Terria, | ||
| searchProvider?: CatalogSearchProviderMixin.Instance | ||
| ) { | ||
| makeObservable(this); | ||
| this.terria = terria; | ||
| this.searchProvider = | ||
| searchProvider ?? | ||
| new CatalogSearchProvider( | ||
| "catalog-search-provider", | ||
| terria, | ||
| terria.searchBarModel.minCharacters | ||
| ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: I know we have done this elsewhere in the past but it might be a good idea to stick with standard Constructor parameters for models? Using custom constructor parameters is fine if the model is always initialised manually but if at some point we do automatic initialisation from some config, it could create problems. One other pattern to make creating the instance easier would be to define a static method like |
||
| this.group = new CatalogGroup("/", this.terria); | ||
| this.terria.addModel(this.group); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be
undefinedif always intialised in constructor?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to detect differently if the catalogue search provider should be initialised, so we can give the possibility to make it undefined