Skip to content

Commit

Permalink
geocat: define global props when importing the web components module
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow committed Dec 6, 2024
1 parent 25ff56f commit b0961e9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apps/webcomponents/src/app/webcomponents.module.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b0961e9

Please sign in to comment.