From b0961e96df0d1edce29be1009d672ddad1f73d58 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Fri, 6 Dec 2024 14:33:53 +0100 Subject: [PATCH] geocat: define global props when importing the web components module --- .../src/app/webcomponents.module.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/webcomponents/src/app/webcomponents.module.ts b/apps/webcomponents/src/app/webcomponents.module.ts index dc9db6efa..1b29facb8 100644 --- a/apps/webcomponents/src/app/webcomponents.module.ts +++ b/apps/webcomponents/src/app/webcomponents.module.ts @@ -1,6 +1,11 @@ import { OverlayContainer } from '@angular/cdk/overlay' import { CommonModule } from '@angular/common' -import { CUSTOM_ELEMENTS_SCHEMA, Injector, NgModule } from '@angular/core' +import { + CUSTOM_ELEMENTS_SCHEMA, + inject, + Injector, + NgModule, +} from '@angular/core' import { createCustomElement } from '@angular/elements' import { BrowserModule } from '@angular/platform-browser' import { Configuration } from '@geonetwork-ui/data-access/gn4' @@ -39,6 +44,8 @@ import { provideGn4 } from '@geonetwork-ui/api/repository' import { GnFigureDatasetsComponent } from './components/gn-figure-datasets/gn-figure-datasets.component' import { UiDatavizModule } from '@geonetwork-ui/ui/dataviz' import { GnDatasetViewMapComponent } from './components/gn-dataset-view-map/gn-dataset-view-map.component' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [ [GnFacetsComponent, 'gn-facets'], @@ -120,6 +127,14 @@ export class WebcomponentsModule { customElements.define(ceTagName, customElement) } }) + + // define global props + const recordsRepository = inject(RecordsRepositoryInterface) + const platformService = inject(PlatformServiceInterface) + window['GNUI'] = { + recordsRepository, + platformService, + } } // eslint-disable-next-line @angular-eslint/no-empty-lifecycle-method, @angular-eslint/use-lifecycle-interface, @typescript-eslint/no-empty-function