Skip to content

Commit 67ba3dc

Browse files
Mattia Vianellivins01-4science
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-1817_fix (pull request DSpace#3788)
Task/dspace cris 2024 02 x/DSC-1817 fix Approved-by: Andrea Barbasso
2 parents 751bc68 + eabaf8d commit 67ba3dc

File tree

12 files changed

+233
-2
lines changed

12 files changed

+233
-2
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,53 @@
1+
import {
2+
ComponentFixture,
3+
TestBed,
4+
} from '@angular/core/testing';
5+
import { TranslateModule } from '@ngx-translate/core';
6+
7+
import { CcLicenseLargeComponent } from './cc-license-large.component';
8+
9+
describe('CcLicenseLargeComponent', () => {
10+
let component: CcLicenseLargeComponent;
11+
let fixture: ComponentFixture<CcLicenseLargeComponent>;
12+
13+
const mockItem = {
14+
firstMetadataValue: jasmine.createSpy('firstMetadataValue').and.returnValue(''),
15+
metadata: {},
16+
findMetadataSortedByPlace: jasmine.createSpy('findMetadataSortedByPlace').and.returnValue([]),
17+
};
18+
19+
const mockField = {
20+
metadataGroup: { elements: [] },
21+
styleValue: '',
22+
};
23+
24+
beforeEach(async () => {
25+
await TestBed.configureTestingModule({
26+
imports: [
27+
CcLicenseLargeComponent,
28+
TranslateModule.forRoot(),
29+
],
30+
providers: [
31+
{ provide: 'fieldProvider', useValue: mockField },
32+
{ provide: 'itemProvider', useValue: mockItem },
33+
{ provide: 'metadataValueProvider', useValue: {} },
34+
{ provide: 'renderingSubTypeProvider', useValue: '' },
35+
{ provide: 'tabNameProvider', useValue: '' },
36+
],
37+
}).compileComponents();
38+
39+
fixture = TestBed.createComponent(CcLicenseLargeComponent);
40+
component = fixture.componentInstance;
41+
42+
component.componentsToBeRenderedMap.set(0, [
43+
{ field: { metadata: 'dc.rights' } as any, value: {} as any },
44+
{ field: { metadata: 'dc.rights.uri' } as any, value: {} as any },
45+
] as any);
46+
47+
fixture.detectChanges();
48+
});
49+
50+
it('should create', () => {
51+
expect(component).toBeTruthy();
52+
});
53+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
Component,
3+
Inject,
4+
OnInit,
5+
} from '@angular/core';
6+
import { TranslateService } from '@ngx-translate/core';
7+
8+
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
9+
import { Item } from '../../../../../../../core/shared/item.model';
10+
import { ItemPageCcLicenseFieldComponent } from '../../../../../../../item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component';
11+
import { MetadataGroupComponent } from '../metadataGroup/metadata-group.component';
12+
13+
@Component({
14+
selector: 'ds-cc-license-large',
15+
standalone: true,
16+
imports: [ItemPageCcLicenseFieldComponent],
17+
templateUrl: './cc-license-large.component.html',
18+
styleUrl: './cc-license-large.component.scss',
19+
})
20+
export class CcLicenseLargeComponent extends MetadataGroupComponent implements OnInit {
21+
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+
}
40+
}
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,54 @@
1+
import {
2+
ComponentFixture,
3+
TestBed,
4+
} from '@angular/core/testing';
5+
import { TranslateModule } from '@ngx-translate/core';
6+
7+
import { CcLicenseSmallComponent } from './cc-license-small.component';
8+
9+
describe('CcLicenseSmallComponent', () => {
10+
let component: CcLicenseSmallComponent;
11+
let fixture: ComponentFixture<CcLicenseSmallComponent>;
12+
13+
const mockItem = {
14+
firstMetadataValue: jasmine.createSpy('firstMetadataValue').and.returnValue(''),
15+
metadata: {},
16+
findMetadataSortedByPlace: jasmine.createSpy('findMetadataSortedByPlace').and.returnValue([]),
17+
};
18+
19+
const mockField = {
20+
metadataGroup: { elements: [] },
21+
styleValue: '',
22+
};
23+
24+
beforeEach(async () => {
25+
await TestBed.configureTestingModule({
26+
imports: [
27+
CcLicenseSmallComponent,
28+
TranslateModule.forRoot(),
29+
],
30+
providers: [
31+
{ provide: 'fieldProvider', useValue: mockField },
32+
{ provide: 'itemProvider', useValue: mockItem },
33+
{ provide: 'metadataValueProvider', useValue: {} },
34+
{ provide: 'renderingSubTypeProvider', useValue: '' },
35+
{ provide: 'tabNameProvider', useValue: '' },
36+
],
37+
}).compileComponents();
38+
39+
fixture = TestBed.createComponent(CcLicenseSmallComponent);
40+
component = fixture.componentInstance;
41+
42+
component.componentsToBeRenderedMap.set(0, [
43+
{ field: { metadata: 'dc.rights' } as any, value: {} as any },
44+
{ field: { metadata: 'dc.rights.uri' } as any, value: {} as any },
45+
] as any);
46+
47+
fixture.detectChanges();
48+
49+
});
50+
51+
it('should create', () => {
52+
expect(component).toBeTruthy();
53+
});
54+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
Component,
3+
Inject,
4+
OnInit,
5+
} from '@angular/core';
6+
import { TranslateService } from '@ngx-translate/core';
7+
8+
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
9+
import { Item } from '../../../../../../../core/shared/item.model';
10+
import { ItemPageCcLicenseFieldComponent } from '../../../../../../../item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component';
11+
import { MetadataGroupComponent } from '../metadataGroup/metadata-group.component';
12+
13+
@Component({
14+
selector: 'ds-cc-license-small',
15+
standalone: true,
16+
imports: [ItemPageCcLicenseFieldComponent],
17+
templateUrl: './cc-license-small.component.html',
18+
styleUrl: './cc-license-small.component.scss',
19+
})
20+
export class CcLicenseSmallComponent extends MetadataGroupComponent implements OnInit {
21+
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+
}
40+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ export enum FieldRenderingType {
1818
ADVANCEDATTACHMENT = 'ADVANCEDATTACHMENT',
1919
SIMPLEATTACHMENT = 'SIMPLEATTACHMENT',
2020
AUTHORITYLINK = 'AUTHORITYLINK',
21+
CCLICENSEFULL = 'CCLICENSEFULL',
22+
CCLICENSE = 'CCLICENSE',
23+
2124
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { AdvancedAttachmentComponent } from './advanced-attachment/advanced-attachment.component';
22
import { AttachmentComponent } from './attachment/attachment.component';
3+
import { CcLicenseLargeComponent } from './cc-license-large/cc-license-large.component';
4+
import { CcLicenseSmallComponent } from './cc-license-small/cc-license-small.component';
35
import { CrisrefComponent } from './crisref/crisref.component';
46
import { DateComponent } from './date/date.component';
57
import { FieldRenderingType } from './field-rendering-type';
@@ -65,4 +67,12 @@ export const layoutBoxesMap = new Map<FieldRenderingType, MetadataBoxFieldRender
6567
componentRef: LonghtmlComponent,
6668
structured: false,
6769
} as MetadataBoxFieldRenderOptions],
70+
[FieldRenderingType.CCLICENSEFULL, {
71+
componentRef: CcLicenseLargeComponent,
72+
structured: false,
73+
} as MetadataBoxFieldRenderOptions],
74+
[FieldRenderingType.CCLICENSE, {
75+
componentRef: CcLicenseSmallComponent,
76+
structured: false,
77+
} as MetadataBoxFieldRenderOptions],
6878
]);

0 commit comments

Comments
 (0)