Skip to content

Commit

Permalink
Make the CC license field component configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgomez committed Jul 4, 2024
1 parent 9ecc447 commit d7b19f3
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 10 deletions.
17 changes: 16 additions & 1 deletion config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,22 @@ notifyMetrics:
config: 'NOTIFY.outgoing.delivered'
description: 'admin-notify-dashboard.NOTIFY.outgoing.delivered.description'


# Creative Commons metadata fields
ccLicense:
# Icon variant:
# 'full' variant shows image, a disclaimer (optional) and name (always), better for the item page content.
# 'small' (default) variant shows image and name (optional), better for the item page sidebar
variant: small
# Field name containing the CC license URI, as configured in the back-end, in the 'dspace.cfg' file, property 'cc.license.uri'
# Defaults to 'dc.rights.uri'
uriField: dc.rights.uri
# Field name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, property 'cc.license'
# Defaults to 'dc.rights'
nameField: dc.rights
# Shows the CC license name with the image. Always show if image fails to load
showName: true
# Shows the disclaimer in the 'full' variant of the component
showDisclaimer: true



Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import {
} from '@angular/common';
import {
Component,
Inject,
Input,
OnInit,
} from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { Item } from 'src/app/core/shared/item.model';
import { MetadataFieldWrapperComponent } from 'src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component';
import { APP_CONFIG, AppConfig } from 'src/config/app-config.interface';

Check failure on line 15 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Imports must be broken into multiple lines if there are more than 1 elements

Check failure on line 15 in src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

View workflow job for this annotation

GitHub Actions / tests (20.x)

Imports must be broken into multiple lines if there are more than 1 elements

@Component({
selector: 'ds-item-page-cc-license-field',
Expand All @@ -31,35 +33,38 @@ export class ItemPageCcLicenseFieldComponent implements OnInit {
* 'full' variant shows image, a disclaimer (optional) and name (always), better for the item page content.
* 'small' variant shows image and name (optional), better for the item page sidebar
*/
@Input() variant?: 'small' | 'full' = 'small';
@Input() variant?: 'small' | 'full' = this.appConfig.ccLicense.variant;

/**
* Filed name containing the CC license URI, as configured in the back-end, in the 'dspace.cfg' file, propertie
* 'cc.license.uri'
* Field name containing the CC license URI
*/
@Input() ccLicenseUriField? = 'dc.rights.uri';
@Input() ccLicenseUriField? = this.appConfig.ccLicense.uriField;

/**
* Filed name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, propertie
* 'cc.license.name'
* Field name containing the CC license name
*/
@Input() ccLicenseNameField? = 'dc.rights.license';
@Input() ccLicenseNameField? = this.appConfig.ccLicense.nameField;

/**
* Shows the CC license name with the image. Always show if image fails to load
*/
@Input() showName? = true;
@Input() showName? = this.appConfig.ccLicense.showName;

/**
* Shows the disclaimer in the 'full' variant of the component
*/
@Input() showDisclaimer? = true;
@Input() showDisclaimer? = this.appConfig.ccLicense.showDisclaimer;

uri: string;
name: string;
showImage = true;
imgSrc: string;

constructor(
@Inject(APP_CONFIG) public appConfig: AppConfig,
) {
}

ngOnInit() {
this.uri = this.item.firstMetadataValue(this.ccLicenseUriField);
this.name = this.item.firstMetadataValue(this.ccLicenseNameField);
Expand Down
2 changes: 2 additions & 0 deletions src/config/app-config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CollectionPageConfig } from './collection-page-config.interface';
import { CommunityListConfig } from './community-list-config.interface';
import { CommunityPageConfig } from './community-page-config.interface';
import { Config } from './config.interface';
import { CreativeCommonsLicenseConfig } from './creative-commons-license-config.interface';
import { DiscoverySortConfig } from './discovery-sort.config';
import { FilterVocabularyConfig } from './filter-vocabulary-config';
import { FormConfig } from './form-config.interfaces';
Expand Down Expand Up @@ -67,6 +68,7 @@ interface AppConfig extends Config {
qualityAssuranceConfig: QualityAssuranceConfig;
search: SearchConfig;
notifyMetrics: AdminNotifyMetricsRow[];
ccLicense: CreativeCommonsLicenseConfig;
// BEGIN: Sistedes
sistedes: SistedesConfig;
// END: Sistedes
Expand Down
34 changes: 34 additions & 0 deletions src/config/creative-commons-license-config.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Config } from './config.interface';

export interface CreativeCommonsLicenseConfig extends Config {

/**
* CC icon variant ('small' or 'full')
* Used by {@link ItemPageCcLicenseFieldComponent}.
*/
variant: 'small' | 'full';

/**
* Field name containing the CC license URI
* Used by {@link ItemPageCcLicenseFieldComponent}.
*/
uriField: string;

/**
* Field name containing the CC license URI
* Used by {@link ItemPageCcLicenseFieldComponent}.
*/
nameField: string;

/**
* Shows the CC license name with the image. Always show if image fails to load
* Used by {@link ItemPageCcLicenseFieldComponent}.
*/
showName: boolean;

/**
* Show the disclaimer in the 'full' variant of the component
* Used by {@link ItemPageCcLicenseFieldComponent}.
*/
showDisclaimer: boolean;
}
9 changes: 9 additions & 0 deletions src/config/default-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CacheConfig } from './cache-config.interface';
import { CollectionPageConfig } from './collection-page-config.interface';
import { CommunityListConfig } from './community-list-config.interface';
import { CommunityPageConfig } from './community-page-config.interface';
import { CreativeCommonsLicenseConfig } from './creative-commons-license-config.interface';
import { DiscoverySortConfig } from './discovery-sort.config';
import { FilterVocabularyConfig } from './filter-vocabulary-config';
import { FormConfig } from './form-config.interfaces';
Expand Down Expand Up @@ -597,6 +598,14 @@ export class DefaultAppConfig implements AppConfig {
],
},
];
// Metadatafields to determine the CC license variant
ccLicense: CreativeCommonsLicenseConfig = {
variant: 'small',
uriField: 'dc.rights.uri',
nameField: 'dc.rights',
showName: true,
showDisclaimer: true,
};
// BEGIN: Sistedes
sistedes: SistedesConfig = {
highlightedCommunities: {
Expand Down
7 changes: 7 additions & 0 deletions src/environments/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ export const environment: BuildConfig = {
],
},
],
ccLicense: {
variant: 'small',
uriField: 'dc.rights.uri',
nameField: 'dc.rights',
showName: true,
showDisclaimer: true,
},
// BEGIN: Sistedes
sistedes: {
highlightedCommunities: {
Expand Down

0 comments on commit d7b19f3

Please sign in to comment.