Skip to content

Commit 3f8f702

Browse files
Mattia Vianellivins01-4science
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-1817_fix (pull request DSpace#3789)
Task/dspace cris 2023 02 x/DSC-1817 fix Approved-by: Andrea Barbasso
2 parents f43a55a + 76f8981 commit 3f8f702

File tree

25 files changed

+632
-9
lines changed

25 files changed

+632
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ds-item-page-cc-license-field
2+
[item]="item"
3+
[variant]="'full'"
4+
[ccLicenseUriField]="dcRightsUri"
5+
[ccLicenseNameField]="dcRights"
6+
[showLabel]="false"
7+
[showUrl]="true">
8+
</ds-item-page-cc-license-field>

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/cc-license-large/cc-license-large.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { TranslateModule } from '@ngx-translate/core';
3+
import { CcLicenseLargeComponent } from './cc-license-large.component';
4+
5+
describe('CcLicenseLargeComponent', () => {
6+
let component: CcLicenseLargeComponent;
7+
let fixture: ComponentFixture<CcLicenseLargeComponent>;
8+
9+
const mockItem = {
10+
firstMetadataValue: jasmine.createSpy('firstMetadataValue').and.returnValue(''),
11+
metadata: {},
12+
findMetadataSortedByPlace: jasmine.createSpy('findMetadataSortedByPlace').and.returnValue([]),
13+
};
14+
15+
const mockField = {
16+
metadataGroup: { elements: [] },
17+
styleValue: '',
18+
};
19+
20+
beforeEach(async () => {
21+
await TestBed.configureTestingModule({
22+
imports: [TranslateModule.forRoot()],
23+
declarations: [CcLicenseLargeComponent],
24+
providers: [
25+
{ provide: 'fieldProvider', useValue: mockField },
26+
{ provide: 'itemProvider', useValue: mockItem },
27+
{ provide: 'metadataValueProvider', useValue: {} },
28+
{ provide: 'renderingSubTypeProvider', useValue: '' },
29+
{ provide: 'tabNameProvider', useValue: '' },
30+
],
31+
}).compileComponents();
32+
33+
fixture = TestBed.createComponent(CcLicenseLargeComponent);
34+
component = fixture.componentInstance;
35+
36+
component.componentsToBeRenderedMap.set(0, [
37+
{ field: { metadata: 'dc.rights' } as any, value: {} as any },
38+
{ field: { metadata: 'dc.rights.uri' } as any, value: {} as any },
39+
] as any);
40+
41+
fixture.detectChanges();
42+
});
43+
44+
it('should create', () => {
45+
expect(component).toBeTruthy();
46+
});
47+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {Component, Inject, OnInit} from '@angular/core';
2+
import {FieldRenderingType, MetadataBoxFieldRendering} from '../metadata-box.decorator';
3+
import {MetadataGroupComponent} from '../metadataGroup/metadata-group.component';
4+
import {LayoutField} from '../../../../../../../core/layout/models/box.model';
5+
import {Item} from '../../../../../../../core/shared/item.model';
6+
import {TranslateService} from '@ngx-translate/core';
7+
8+
@Component({
9+
selector: 'ds-cc-license-large',
10+
templateUrl: './cc-license-large.component.html',
11+
styleUrls: ['./cc-license-large.component.scss']
12+
})
13+
@MetadataBoxFieldRendering(FieldRenderingType.CCLICENSEFULL)
14+
export class CcLicenseLargeComponent extends MetadataGroupComponent implements OnInit {
15+
16+
dcRights: any;
17+
dcRightsUri: any;
18+
19+
constructor(
20+
@Inject('fieldProvider') public fieldProvider: LayoutField,
21+
@Inject('itemProvider') public itemProvider: Item,
22+
@Inject('renderingSubTypeProvider') public renderingSubTypeProvider: string,
23+
@Inject('tabNameProvider') public tabNameProvider: string,
24+
protected translateService: TranslateService,
25+
) {
26+
super(fieldProvider, itemProvider, renderingSubTypeProvider, tabNameProvider, translateService);
27+
}
28+
ngOnInit(): void {
29+
super.ngOnInit();
30+
const ccLicenseEntryMetadata = this.componentsToBeRenderedMap.get(0);
31+
[this.dcRights, this.dcRightsUri] = ccLicenseEntryMetadata.map((entryMeta) => entryMeta.field.metadata);
32+
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ds-item-page-cc-license-field
2+
[item]="item"
3+
[variant]="'small'"
4+
[ccLicenseUriField]="dcRightsUri"
5+
[ccLicenseNameField]="dcRights"
6+
[showLabel]="false"
7+
[showUrl]="false">
8+
</ds-item-page-cc-license-field>

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/cc-license-small/cc-license-small.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { TranslateModule } from '@ngx-translate/core';
3+
4+
import { CcLicenseSmallComponent } from './cc-license-small.component';
5+
6+
describe('CcLicenseSmallComponent', () => {
7+
let component: CcLicenseSmallComponent;
8+
let fixture: ComponentFixture<CcLicenseSmallComponent>;
9+
10+
const mockItem = {
11+
firstMetadataValue: jasmine.createSpy('firstMetadataValue').and.returnValue(''),
12+
metadata: {},
13+
findMetadataSortedByPlace: jasmine.createSpy('findMetadataSortedByPlace').and.returnValue([]),
14+
};
15+
16+
const mockField = {
17+
metadataGroup: { elements: [] },
18+
styleValue: '',
19+
};
20+
21+
beforeEach(async () => {
22+
await TestBed.configureTestingModule({
23+
imports: [TranslateModule.forRoot()],
24+
declarations: [CcLicenseSmallComponent],
25+
providers: [
26+
{ provide: 'fieldProvider', useValue: mockField },
27+
{ provide: 'itemProvider', useValue: mockItem },
28+
{ provide: 'metadataValueProvider', useValue: {} },
29+
{ provide: 'renderingSubTypeProvider', useValue: '' },
30+
{ provide: 'tabNameProvider', useValue: '' },
31+
],
32+
}).compileComponents();
33+
34+
fixture = TestBed.createComponent(CcLicenseSmallComponent);
35+
component = fixture.componentInstance;
36+
37+
component.componentsToBeRenderedMap.set(0, [
38+
{ field: { metadata: 'dc.rights' } as any, value: {} as any },
39+
{ field: { metadata: 'dc.rights.uri' } as any, value: {} as any },
40+
] as any);
41+
42+
fixture.detectChanges();
43+
44+
});
45+
46+
it('should create', () => {
47+
expect(component).toBeTruthy();
48+
});
49+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {Component, Inject, OnInit} from '@angular/core';
2+
import {FieldRenderingType, MetadataBoxFieldRendering} from '../metadata-box.decorator';
3+
import {MetadataGroupComponent} from '../metadataGroup/metadata-group.component';
4+
import {LayoutField} from '../../../../../../../core/layout/models/box.model';
5+
import {Item} from '../../../../../../../core/shared/item.model';
6+
import {TranslateService} from '@ngx-translate/core';
7+
8+
@Component({
9+
selector: 'ds-cc-license-small',
10+
templateUrl: './cc-license-small.component.html',
11+
styleUrls: ['./cc-license-small.component.scss']
12+
})
13+
@MetadataBoxFieldRendering(FieldRenderingType.CCLICENSE)
14+
export class CcLicenseSmallComponent extends MetadataGroupComponent implements OnInit {
15+
16+
17+
dcRights: any;
18+
dcRightsUri: any;
19+
20+
constructor(
21+
@Inject('fieldProvider') public fieldProvider: LayoutField,
22+
@Inject('itemProvider') public itemProvider: Item,
23+
@Inject('renderingSubTypeProvider') public renderingSubTypeProvider: string,
24+
@Inject('tabNameProvider') public tabNameProvider: string,
25+
protected translateService: TranslateService,
26+
) {
27+
super(fieldProvider, itemProvider, renderingSubTypeProvider, tabNameProvider, translateService);
28+
}
29+
ngOnInit(): void {
30+
super.ngOnInit();
31+
const ccLicenseEntryMetadata = this.componentsToBeRenderedMap.get(0);
32+
[this.dcRights, this.dcRightsUri] = ccLicenseEntryMetadata.map((entryMeta) => entryMeta.field.metadata);
33+
34+
}
35+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export enum FieldRenderingType {
2121
ADVANCEDATTACHMENT = 'ADVANCEDATTACHMENT',
2222
SIMPLEATTACHMENT = 'SIMPLEATTACHMENT',
2323
AUTHORITYLINK = 'AUTHORITYLINK',
24+
CCLICENSEFULL = 'CCLICENSEFULL',
25+
CCLICENSE = 'CCLICENSE'
2426
}
2527

2628
const fieldType = new Map();

src/app/cris-layout/cris-layout.module.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ import {
120120
import {
121121
LonghtmlComponent
122122
} from './cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/longhtml/longhtml.component';
123+
import {
124+
CcLicenseLargeComponent
125+
} from './cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/cc-license-large/cc-license-large.component';
126+
import {ItemSharedModule} from '../item-page/item-shared.module';
127+
import {
128+
CcLicenseSmallComponent
129+
} from './cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/cc-license-small/cc-license-small.component';
123130

124131
const ENTRY_COMPONENTS = [
125132
// put only entry components that use custom decorator
@@ -136,6 +143,8 @@ const ENTRY_COMPONENTS = [
136143
LinkComponent,
137144
IdentifierComponent,
138145
CrisrefComponent,
146+
CcLicenseLargeComponent,
147+
CcLicenseSmallComponent,
139148
ThumbnailComponent,
140149
AttachmentComponent,
141150
CrisLayoutMetricsBoxComponent,
@@ -186,11 +195,14 @@ const ENTRY_COMPONENTS = [
186195
MiradorViewerModule,
187196
MetricsModule,
188197
AttachmentRenderingModule,
189-
FormModule
198+
FormModule,
199+
ItemSharedModule
190200
],
191201
exports: [
192202
CrisLayoutComponent,
193203
CrisrefComponent,
204+
CcLicenseLargeComponent,
205+
CcLicenseSmallComponent
194206
]
195207
})
196208
export class CrisLayoutModule {

0 commit comments

Comments
 (0)