Skip to content

Commit e475361

Browse files
Mattia VianelliMattia Vianelli
authored andcommitted
DSC-1817 Refactor the rendering from metadata to metadatagroup
1 parent e4a64ca commit e475361

8 files changed

Lines changed: 72 additions & 26 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<ds-item-page-cc-license-field
22
[item]="item"
3-
variant="full"
4-
[ccLicenseNameField]="ccLicenseNameField"
5-
[showTitle]="false"
6-
[showName]="true">
3+
[variant]="'full'"
4+
[ccLicenseUriField]="dcRightsUri"
5+
[ccLicenseNameField]="dcRights"
6+
[showLabel]="false"
7+
[showUrl]="true">
78
</ds-item-page-cc-license-field>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import {
2-
Component,
2+
Component, Inject,
33
Input,
44
} from '@angular/core';
55

66
import { ItemPageCcLicenseFieldComponent } from '../../../../../../../item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component';
77
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model';
8+
import {MetadataGroupComponent} from "../metadataGroup/metadata-group.component";
9+
import {LayoutField} from "../../../../../../../core/layout/models/box.model";
10+
import {Item} from "../../../../../../../core/shared/item.model";
11+
import {TranslateService} from "@ngx-translate/core";
812

913
@Component({
1014
selector: 'ds-cc-license-large',
@@ -13,11 +17,24 @@ import { RenderingTypeValueModelComponent } from '../rendering-type-value.model'
1317
templateUrl: './cc-license-large.component.html',
1418
styleUrl: './cc-license-large.component.scss',
1519
})
16-
export class CcLicenseLargeComponent extends RenderingTypeValueModelComponent {
20+
export class CcLicenseLargeComponent extends MetadataGroupComponent {
1721

18-
/**
19-
* Filed name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, propertie
20-
* 'cc.license.name'
21-
*/
22-
@Input() ccLicenseNameField? = 'dc.rights';
22+
dcRights: any;
23+
dcRightsUri: any;
24+
25+
constructor(
26+
@Inject('fieldProvider') public fieldProvider: LayoutField,
27+
@Inject('itemProvider') public itemProvider: Item,
28+
@Inject('renderingSubTypeProvider') public renderingSubTypeProvider: string,
29+
@Inject('tabNameProvider') public tabNameProvider: string,
30+
protected translateService: TranslateService,
31+
) {
32+
super(fieldProvider, itemProvider, renderingSubTypeProvider, tabNameProvider, translateService);
33+
}
34+
ngOnInit(): void {
35+
super.ngOnInit();
36+
const ccLicenseEntryMetadata = this.componentsToBeRenderedMap.get(0);
37+
[this.dcRights, this.dcRightsUri] = ccLicenseEntryMetadata.map((entryMeta) => entryMeta.field.metadata);
38+
39+
}
2340
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<ds-item-page-cc-license-field
22
[item]="item"
3-
variant="small"
4-
[ccLicenseNameField]="ccLicenseNameField"
5-
[showTitle]="false"
6-
[showName]="false">
3+
[variant]="'small'"
4+
[ccLicenseUriField]="dcRightsUri"
5+
[ccLicenseNameField]="dcRights"
6+
[showLabel]="false"
7+
[showUrl]="false">
78
</ds-item-page-cc-license-field>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import {
2-
Component,
2+
Component, Inject,
33
Input,
44
} from '@angular/core';
55

66
import { ItemPageCcLicenseFieldComponent } from '../../../../../../../item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component';
77
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model';
8+
import {MetadataGroupComponent} from "../metadataGroup/metadata-group.component";
9+
import {LayoutField} from "../../../../../../../core/layout/models/box.model";
10+
import {Item} from "../../../../../../../core/shared/item.model";
11+
import {TranslateService} from "@ngx-translate/core";
812

913
@Component({
1014
selector: 'ds-cc-license-small',
@@ -13,11 +17,24 @@ import { RenderingTypeValueModelComponent } from '../rendering-type-value.model'
1317
templateUrl: './cc-license-small.component.html',
1418
styleUrl: './cc-license-small.component.scss',
1519
})
16-
export class CcLicenseSmallComponent extends RenderingTypeValueModelComponent {
20+
export class CcLicenseSmallComponent extends MetadataGroupComponent {
1721

18-
/**
19-
* Filed name containing the CC license name, as configured in the back-end, in the 'dspace.cfg' file, propertie
20-
* 'cc.license.name'
21-
*/
22-
@Input() ccLicenseNameField? = 'dc.rights';
22+
dcRights: any;
23+
dcRightsUri: any;
24+
25+
constructor(
26+
@Inject('fieldProvider') public fieldProvider: LayoutField,
27+
@Inject('itemProvider') public itemProvider: Item,
28+
@Inject('renderingSubTypeProvider') public renderingSubTypeProvider: string,
29+
@Inject('tabNameProvider') public tabNameProvider: string,
30+
protected translateService: TranslateService,
31+
) {
32+
super(fieldProvider, itemProvider, renderingSubTypeProvider, tabNameProvider, translateService);
33+
}
34+
ngOnInit(): void {
35+
super.ngOnInit();
36+
const ccLicenseEntryMetadata = this.componentsToBeRenderedMap.get(0);
37+
[this.dcRights, this.dcRightsUri] = ccLicenseEntryMetadata.map((entryMeta) => entryMeta.field.metadata);
38+
39+
}
2340
}

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/field-rendering-type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export enum FieldRenderingType {
1919
SIMPLEATTACHMENT = 'SIMPLEATTACHMENT',
2020
AUTHORITYLINK = 'AUTHORITYLINK',
2121
CCLICENSEFULL = 'CCLICENSEFULL',
22-
CCLICENSESMALL = 'CCLICENSESMALL',
22+
CCLICENSE = 'CCLICENSE',
2323

2424
}

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/metadata-box-rendering-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const layoutBoxesMap = new Map<FieldRenderingType, MetadataBoxFieldRender
7171
componentRef: CcLicenseLargeComponent,
7272
structured: false,
7373
} as MetadataBoxFieldRenderOptions],
74-
[FieldRenderingType.CCLICENSESMALL, {
74+
[FieldRenderingType.CCLICENSE, {
7575
componentRef: CcLicenseSmallComponent,
7676
structured: false,
7777
} as MetadataBoxFieldRenderOptions],

src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div *ngIf="uri && name" class="item-page-field">
2-
<ds-metadata-field-wrapper [hideIfNoTextContent]="false" [label]="showTitle && ('item.page.cc.license.title' | translate)">
2+
<ds-metadata-field-wrapper [hideIfNoTextContent]="false" [label]="showLabel && ('item.page.cc.license.title' | translate)">
33
<div [ngClass]="{'row': variant === 'full', 'col': variant === 'small'}">
44

55
<!-- 'img' tag is not rendered if any errors occurs when loading it -->
@@ -20,7 +20,7 @@
2020
<div [ngClass]="{ 'row': variant === 'small', 'col': variant === 'full' }">
2121
<span>
2222
{{ variant === 'full' && showDisclaimer ? ('item.page.cc.license.disclaimer' | translate) : '' }}
23-
<a *ngIf="showName || !showImage" [href]="uri" target="_blank" id="cc-name">{{ name }}</a>
23+
<a *ngIf="(showName || !showImage) && showUrl" [href]="uri" target="_blank" id="cc-name">{{ name }}</a>
2424
</span>
2525
</div>
2626
</div>

src/app/item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ export class ItemPageCcLicenseFieldComponent implements OnInit {
6060
*/
6161
@Input() showTitle? = true;
6262

63+
/**
64+
* Shows the label
65+
*/
66+
@Input() showLabel? = true;
67+
68+
/**
69+
* Shows the url
70+
*/
71+
@Input() showUrl? = true;
72+
6373
uri: string;
6474
name: string;
6575
showImage = true;

0 commit comments

Comments
 (0)