diff --git a/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.html b/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.html index 3e6baa3d8..396b9a96e 100644 --- a/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.html +++ b/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.html @@ -54,27 +54,23 @@

{{ 'project.metadata.addMetadata.notPublishedTe }
- @if (!cedarLoaded()) { - + @if (readonly()) { + } @else { - @if (readonly()) { - - } @else { - - } + }
diff --git a/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.ts b/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.ts index 6ce949170..4faf1a9cd 100644 --- a/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.ts +++ b/src/app/features/metadata/components/cedar-template-form/cedar-template-form.component.ts @@ -6,7 +6,7 @@ import { Tooltip } from 'primeng/tooltip'; import { map, of } from 'rxjs'; -import { CommonModule, isPlatformBrowser } from '@angular/common'; +import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -16,7 +16,6 @@ import { inject, input, output, - PLATFORM_ID, signal, viewChild, ViewEncapsulation, @@ -25,7 +24,8 @@ import { toSignal } from '@angular/core/rxjs-interop'; import { ActivatedRoute } from '@angular/router'; import { ENVIRONMENT } from '@core/provider/environment.provider'; -import { LoadingSpinnerComponent } from '@osf/shared/components/loading-spinner/loading-spinner.component'; + +import 'cedar-artifact-viewer'; import { CEDAR_CONFIG, CEDAR_VIEWER_CONFIG } from '../../constants'; import { CedarMetadataHelper } from '../../helpers'; @@ -38,7 +38,7 @@ import { @Component({ selector: 'osf-cedar-template-form', - imports: [CommonModule, Button, TranslatePipe, Tooltip, Menu, LoadingSpinnerComponent], + imports: [CommonModule, Button, TranslatePipe, Tooltip, Menu], templateUrl: './cedar-template-form.component.html', styleUrl: './cedar-template-form.component.scss', schemas: [CUSTOM_ELEMENTS_SCHEMA], @@ -65,8 +65,6 @@ export class CedarTemplateFormComponent { private route = inject(ActivatedRoute); readonly environment = inject(ENVIRONMENT); - private platformId = inject(PLATFORM_ID); - readonly cedarLoaded = signal(false); readonly recordId = signal(''); readonly downloadUrl = signal(''); @@ -93,7 +91,7 @@ export class CedarTemplateFormComponent { effect(() => { const tpl = this.template(); if (tpl?.attributes?.template) { - this.loadCedarLibraries().then(() => this.initializeCedar()); + this.initializeCedar(); } }); @@ -101,7 +99,7 @@ export class CedarTemplateFormComponent { const record = this.existingRecord(); this.schemaName.set(record?.embeds?.template.data.attributes.schema_name || ''); if (record) { - this.loadCedarLibraries().then(() => this.initializeCedar()); + this.initializeCedar(); } }); } @@ -138,19 +136,6 @@ export class CedarTemplateFormComponent { } } - private async loadCedarLibraries(): Promise { - if (!isPlatformBrowser(this.platformId) || this.cedarLoaded()) { - return; - } - - try { - await Promise.all([import('cedar-artifact-viewer'), import('cedar-embeddable-editor')]); - this.cedarLoaded.set(true); - } catch { - this.cedarLoaded.set(false); - } - } - downloadMetadadaRecord() { if (this.fileGuid()) { window.open(`${this.environment.webUrl}/metadata/${this.fileGuid()}`)?.focus(); @@ -199,6 +184,7 @@ export class CedarTemplateFormComponent { this.emitData.emit(finalData as CedarRecordDataBinding); } } + handleEmailShare(): void { const url = window.location.href; window.location.href = `mailto:?subject=${this.schemaName()}&body=${url}`; diff --git a/src/main.ts b/src/main.ts index e005d74a2..1285e5af0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,8 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from '@osf/app.component'; import { appConfig } from '@osf/app.config'; +import 'cedar-embeddable-editor'; + bootstrapApplication(AppComponent, { providers: [...appConfig.providers], }).catch((err) =>