diff --git a/src/app/item-page/simple/item-page.component.html b/src/app/item-page/simple/item-page.component.html
index 8d2c9048344..362a819e57c 100644
--- a/src/app/item-page/simple/item-page.component.html
+++ b/src/app/item-page/simple/item-page.component.html
@@ -10,29 +10,31 @@
-
-
{{'item.page.files.head' | translate}}
-
diff --git a/src/app/item-page/simple/item-page.component.spec.ts b/src/app/item-page/simple/item-page.component.spec.ts
index 3058aa30f69..db251ade0f1 100644
--- a/src/app/item-page/simple/item-page.component.spec.ts
+++ b/src/app/item-page/simple/item-page.component.spec.ts
@@ -31,10 +31,16 @@ import { MetadataBitstreamDataService } from 'src/app/core/data/metadata-bitstre
import { getMockTranslateService } from 'src/app/shared/mocks/translate.service.mock';
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
+import { MetadataValue } from '../../core/shared/metadata.models';
const mockItem: Item = Object.assign(new Item(), {
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])),
- metadata: [],
+ metadata: {
+ 'local.has.files': [Object.assign(new MetadataValue(), {
+ value: 'yes',
+ language: undefined
+ })]
+ },
relationships: createRelationshipsObservable()
});
@@ -207,4 +213,16 @@ describe('ItemPageComponent', () => {
});
});
+ describe('when the item has the file', () => {
+ it('should display license and files section', waitForAsync(async () => {
+ comp.itemRD$ = createSuccessfulRemoteDataObject$(mockItem);
+ fixture.detectChanges();
+
+ void fixture.whenStable().then(() => {
+ const objectLoader = fixture.debugElement.query(By.css('ds-clarin-license-info'));
+ expect(objectLoader.nativeElement).toBeDefined();
+ });
+ }));
+ });
+
});
diff --git a/src/app/item-page/simple/item-page.component.ts b/src/app/item-page/simple/item-page.component.ts
index 9bf41a19813..d4e0443d90f 100644
--- a/src/app/item-page/simple/item-page.component.ts
+++ b/src/app/item-page/simple/item-page.component.ts
@@ -18,7 +18,7 @@ import { AuthorizationDataService } from '../../core/data/feature-authorization/
import { redirectOn4xx } from '../../core/shared/authorized.operators';
import { RegistryService } from 'src/app/core/registry/registry.service';
import { MetadataBitstream } from 'src/app/core/metadata/metadata-bitstream.model';
-import { Observable} from 'rxjs';
+import { BehaviorSubject, Observable } from 'rxjs';
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
/**
@@ -103,6 +103,11 @@ export class ItemPageComponent implements OnInit, OnDestroy {
canShowCurlDownload = false;
+ /**
+ * True if the item has files, false otherwise.
+ */
+ hasFiles: BehaviorSubject = new BehaviorSubject(false);
+
constructor(
protected route: ActivatedRoute,
private router: Router,
@@ -127,7 +132,7 @@ export class ItemPageComponent implements OnInit, OnDestroy {
map((item) => getItemPageRoute(item))
);
- this.showTombstone();
+ this.processItem();
this.registryService
.getMetadataBitstream(this.itemHandle, 'ORIGINAL,TEXT,THUMBNAIL')
@@ -139,6 +144,14 @@ export class ItemPageComponent implements OnInit, OnDestroy {
});
}
+ /**
+ * Check if the item has files and assign the result into the `hasFiles` variable.
+ * */
+ private checkIfItemHasFiles(item: Item) {
+ const hasFilesMetadata = item.metadata?.['local.has.files']?.[0]?.value;
+ this.hasFiles.next(hasFilesMetadata !== 'no');
+ }
+
sumFileSizes() {
const sizeUnits = {
B: 1,
@@ -167,7 +180,10 @@ export class ItemPageComponent implements OnInit, OnDestroy {
this.totalFileSizes = totalBytes.toFixed(2) + ' ' + finalUnit;
}
- showTombstone() {
+ /**
+ * Process the tombstone of the Item and check if it has files or not.
+ */
+ processItem() {
// if the item is withdrawn
let isWithdrawn = false;
// metadata value from `dc.relation.isreplacedby`
@@ -181,6 +197,9 @@ export class ItemPageComponent implements OnInit, OnDestroy {
this.itemHandle = item.handle;
isWithdrawn = item.isWithdrawn;
isReplaced = item.metadata['dc.relation.isreplacedby']?.[0]?.value;
+
+ // check if the item has files
+ this.checkIfItemHasFiles(item);
});
// do not show tombstone for non withdrawn items