From 8f9125c784064883fdca1f8f207cb668860c1569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20G=C3=B3mez?= Date: Wed, 9 Oct 2024 21:20:13 +0200 Subject: [PATCH] Retrieve the configuration values from the backend... ... rather than from a frontend configuration --- .../item-page-cc-license-field.component.ts | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts index e06d0c25b56..cc97704c743 100644 --- a/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts +++ b/src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts @@ -9,7 +9,12 @@ import { OnInit, } from '@angular/core'; import { TranslateModule } from '@ngx-translate/core'; +import { map } from 'rxjs'; +import { ConfigurationDataService } from 'src/app/core/data/configuration-data.service'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { ConfigurationProperty } from 'src/app/core/shared/configuration-property.model'; import { Item } from 'src/app/core/shared/item.model'; +import { getFirstCompletedRemoteData, getRemoteDataPayload } from 'src/app/core/shared/operators'; import { MetadataFieldWrapperComponent } from 'src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component'; @Component({ @@ -33,18 +38,6 @@ export class ItemPageCcLicenseFieldComponent implements OnInit { */ @Input() variant?: 'small' | 'full' = 'small'; - /** - * Filed name containing the CC license URI, as configured in the back-end, in the 'dspace.cfg' file, property - * 'cc.license.uri' - */ - @Input() ccLicenseUriField? = 'dc.rights.uri'; - - /** - * Filed name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, property - * 'cc.license.name' - */ - @Input() ccLicenseNameField? = 'dc.rights'; - /** * Shows the CC license name with the image. Always show if image fails to load */ @@ -55,11 +48,32 @@ export class ItemPageCcLicenseFieldComponent implements OnInit { */ @Input() showDisclaimer? = true; + ccLicenseUriField: string; + ccLicenseNameField: string; uri: string; name: string; showImage = true; imgSrc: string; + constructor( + private configService: ConfigurationDataService, + ) { + this.configService.findByPropertyName('cc.license.uri').pipe( + getFirstCompletedRemoteData(), + getRemoteDataPayload() + ).subscribe((remoteData) => { + this.ccLicenseNameField = remoteData.values && remoteData.values.length > 0 ? remoteData.values[0] : 'dc.rights.uri'; + } + ); + this.configService.findByPropertyName('dc.rights').pipe( + getFirstCompletedRemoteData(), + getRemoteDataPayload() + ).subscribe((remoteData) => { + this.ccLicenseNameField = remoteData.values && remoteData.values.length > 0 ? remoteData.values[0] : 'dc.rights'; + } + ); + } + ngOnInit() { this.uri = this.item.firstMetadataValue(this.ccLicenseUriField); this.name = this.item.firstMetadataValue(this.ccLicenseNameField);