-
+
-
diff --git a/src/app/item-page/simple/field-components/clarin-generic-item-field/clarin-generic-item-field.component.ts b/src/app/item-page/simple/field-components/clarin-generic-item-field/clarin-generic-item-field.component.ts
index ae4120b1b96..089119cf2bb 100644
--- a/src/app/item-page/simple/field-components/clarin-generic-item-field/clarin-generic-item-field.component.ts
+++ b/src/app/item-page/simple/field-components/clarin-generic-item-field/clarin-generic-item-field.component.ts
@@ -1,6 +1,10 @@
import { Component, Input, OnInit } from '@angular/core';
import { Item } from '../../../../core/shared/item.model';
-import { isNotUndefined } from '../../../../shared/empty.util';
+import { isEmpty, isNotUndefined } from '../../../../shared/empty.util';
+import { ConfigurationProperty } from '../../../../core/shared/configuration-property.model';
+import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
+import { convertMetadataFieldIntoSearchType, getBaseUrl } from '../../../../shared/clarin-shared-util';
+import { ConfigurationDataService } from '../../../../core/data/configuration-data.service';
@Component({
selector: 'ds-clarin-generic-item-field',
@@ -40,15 +44,73 @@ export class ClarinGenericItemFieldComponent implements OnInit {
*/
@Input() label: string;
+ /**
+ * UI URL loaded from the server.
+ */
+ baseUrl = '';
+
// tslint:disable-next-line:no-empty
- constructor() { }
+ constructor(protected dsoNameService: DSONameService,
+ protected configurationService: ConfigurationDataService) { }
// tslint:disable-next-line:no-empty
- ngOnInit(): void {
+ async ngOnInit(): Promise
{
+ await this.assignBaseUrl();
}
+ /**
+ * If the metadata fields has some metadata value - show nothing if the field do not have any value.
+ */
public hasMetadataValue() {
return isNotUndefined(this.item.firstMetadataValue(this.fields));
}
+ /**
+ * Return current metadata value. The metadata field could have more metadata values, often the metadata
+ * field has only one metadata value - index is 0, but sometimes it has more values e.g. `Author`.
+ * @param index
+ */
+ public getLinkToSearch(index, value = '') {
+ let metadataValue = 'Error: value is empty';
+ if (isEmpty(value)) {
+ // Get metadata value from the Item's metadata field
+ metadataValue = this.getMetadataValue(index);
+ } else {
+ // The metadata value is passed from the parameter.
+ metadataValue = value;
+ }
+
+ const searchType = convertMetadataFieldIntoSearchType(this.fields);
+ return this.baseUrl + '/search/objects?f.' + searchType + '=' + metadataValue + ',equals';
+ }
+
+ /**
+ * If the metadata field has more than 1 value return the value based on the index.
+ * @param index of the metadata value
+ */
+ public getMetadataValue(index) {
+ let metadataValue = '';
+ if (index === 0) {
+ // Return first metadata value.
+ return this.item.firstMetadataValue(this.fields);
+ }
+ // The metadata field has more metadata values - get the actual one
+ this.item.allMetadataValues(this.fields)?.forEach((metadataValueArray, arrayIndex) => {
+ if (index !== arrayIndex) {
+ return metadataValue;
+ }
+ metadataValue = metadataValueArray;
+ });
+ return metadataValue;
+ }
+
+ /**
+ * Load base url from the configuration from the BE.
+ */
+ async assignBaseUrl() {
+ this.baseUrl = await getBaseUrl(this.configurationService)
+ .then((baseUrlResponse: ConfigurationProperty) => {
+ return baseUrlResponse?.values?.[0];
+ });
+ }
}
diff --git a/src/app/item-page/simple/item-types/untyped-item/untyped-item.component.html b/src/app/item-page/simple/item-types/untyped-item/untyped-item.component.html
index 1524db659fe..3fb68ff17d8 100644
--- a/src/app/item-page/simple/item-types/untyped-item/untyped-item.component.html
+++ b/src/app/item-page/simple/item-types/untyped-item/untyped-item.component.html
@@ -29,7 +29,8 @@
[fields]="['dc.contributor.author', 'dc.creator']"
[label]="'relationships.isAuthorOf'"
[iconName]="'fa-pen'"
- [separator]="','">
+ [separator]="','"
+ [type]="'author'">
+ [iconName]="'fa-link'"
+ [type]="'hyperlink'">
+ [iconName]="'fa-tag'"
+ [type]="'search'">
[fields]="['dc.language.iso']"
[label]="'item.page.language'"
[iconName]="'fa-flag'"
- [separator]="','">
+ [separator]="','"
+ [type]="'search'">
[iconName]="'fa-file-alt'">
+ [iconName]="'fa-copy'"
+ [type]="'search'">
[fields]="['dc.subject']"
[label]="'item.page.subject'"
[iconName]="'fa-tags'"
- [separator]="','">
+ [separator]="','"
+ [type]="'subject'">
+
+ 5">
+
+
+
+
+
+ Show everyone
+
+
+
+
+
+
diff --git a/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.scss b/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.scss
new file mode 100644
index 00000000000..6f28ee1ce79
--- /dev/null
+++ b/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.scss
@@ -0,0 +1,3 @@
+/**
+This is a styling file for the clarin-item-author-preview component.
+ */
diff --git a/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.spec.ts b/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.spec.ts
new file mode 100644
index 00000000000..f75f22ba072
--- /dev/null
+++ b/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.spec.ts
@@ -0,0 +1,34 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ClarinItemAuthorPreviewComponent } from './clarin-item-author-preview.component';
+import {of} from 'rxjs';
+import {ConfigurationDataService} from '../../core/data/configuration-data.service';
+
+describe('ClarinItemAuthorPreviewComponent', () => {
+ let component: ClarinItemAuthorPreviewComponent;
+ let fixture: ComponentFixture
;
+
+ const configurationServiceSpy = jasmine.createSpyObj('configurationService', {
+ findByPropertyName: of(true),
+ });
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ClarinItemAuthorPreviewComponent ],
+ providers: [
+ { provide: ConfigurationDataService, useValue: configurationServiceSpy }
+ ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ClarinItemAuthorPreviewComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.ts b/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.ts
new file mode 100644
index 00000000000..c7a417e9419
--- /dev/null
+++ b/src/app/shared/clarin-item-author-preview/clarin-item-author-preview.component.ts
@@ -0,0 +1,52 @@
+import { Component, Input, OnInit } from '@angular/core';
+import { BehaviorSubject } from 'rxjs';
+import { AuthorNameLink } from '../clarin-item-box-view/clarin-item-box-view.component';
+import { getBaseUrl, loadItemAuthors } from '../clarin-shared-util';
+import { Item } from '../../core/shared/item.model';
+import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
+import { ConfigurationDataService } from '../../core/data/configuration-data.service';
+
+@Component({
+ selector: 'ds-clarin-item-author-preview',
+ templateUrl: './clarin-item-author-preview.component.html',
+ styleUrls: ['./clarin-item-author-preview.component.scss']
+})
+export class ClarinItemAuthorPreviewComponent implements OnInit {
+
+ @Input() item: Item;
+
+ /**
+ * Authors of the Item.
+ */
+ itemAuthors: BehaviorSubject = new BehaviorSubject([]);
+
+ /**
+ * If the Item have a lot of authors do not show them all.
+ */
+ showEveryAuthor: BehaviorSubject = new BehaviorSubject(false);
+
+ /**
+ * UI URL loaded from the server.
+ */
+ baseUrl = '';
+
+ constructor(protected configurationService: ConfigurationDataService) { }
+
+ async ngOnInit(): Promise {
+ await this.assignBaseUrl();
+ loadItemAuthors(this.item, this.itemAuthors, this.baseUrl);
+ }
+ toggleShowEveryAuthor() {
+ this.showEveryAuthor.next(!this.showEveryAuthor.value);
+ }
+
+ /**
+ * Load base url from the configuration from the BE.
+ */
+ async assignBaseUrl() {
+ this.baseUrl = await getBaseUrl(this.configurationService)
+ .then((baseUrlResponse: ConfigurationProperty) => {
+ return baseUrlResponse?.values?.[0];
+ });
+ }
+}
diff --git a/src/app/shared/clarin-item-box-view/clarin-item-box-view.component.html b/src/app/shared/clarin-item-box-view/clarin-item-box-view.component.html
index 162406cce0b..b38709fbfbd 100644
--- a/src/app/shared/clarin-item-box-view/clarin-item-box-view.component.html
+++ b/src/app/shared/clarin-item-box-view/clarin-item-box-view.component.html
@@ -16,33 +16,7 @@