1578: primaryBitstream implementation

This commit is contained in:
lotte
2023-04-25 16:12:00 +02:00
parent 4847fc6f7a
commit 7008afd05f
3 changed files with 243 additions and 53 deletions

View File

@@ -24,6 +24,8 @@ import { createPaginatedList } from '../../shared/testing/utils.test';
import { Item } from '../../core/shared/item.model'; import { Item } from '../../core/shared/item.model';
import { MetadataValueFilter } from '../../core/shared/metadata.models'; import { MetadataValueFilter } from '../../core/shared/metadata.models';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service'; import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { Bundle } from '../../core/shared/bundle.model';
import { BundleDataService } from '../../core/data/bundle-data.service';
const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info'); const infoNotification: INotification = new Notification('id', NotificationType.Info, 'info');
const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning'); const warningNotification: INotification = new Notification('id', NotificationType.Warning, 'warning');
@@ -35,9 +37,14 @@ let bitstreamService: BitstreamDataService;
let bitstreamFormatService: BitstreamFormatDataService; let bitstreamFormatService: BitstreamFormatDataService;
let dsoNameService: DSONameService; let dsoNameService: DSONameService;
let bitstream: Bitstream; let bitstream: Bitstream;
let bitstreamID: string;
let selectedFormat: BitstreamFormat; let selectedFormat: BitstreamFormat;
let allFormats: BitstreamFormat[]; let allFormats: BitstreamFormat[];
let router: Router; let router: Router;
let bundleDataService;
let bundleWithCurrentPrimary: Bundle;
let bundleWithDifferentPrimary: Bundle;
let bundleWithNoPrimary: Bundle;
let comp: EditBitstreamPageComponent; let comp: EditBitstreamPageComponent;
let fixture: ComponentFixture<EditBitstreamPageComponent>; let fixture: ComponentFixture<EditBitstreamPageComponent>;
@@ -45,6 +52,12 @@ let fixture: ComponentFixture<EditBitstreamPageComponent>;
describe('EditBitstreamPageComponent', () => { describe('EditBitstreamPageComponent', () => {
beforeEach(() => { beforeEach(() => {
bitstreamID = 'current-bitstream-id';
bundleWithCurrentPrimary = Object.assign(new Bundle(), { 'primaryBitstreamUUID': bitstreamID });
bundleWithDifferentPrimary = Object.assign(new Bundle(), { 'primaryBitstreamUUID': '12345-abcde-54321-edcba' });
bundleWithNoPrimary = Object.assign(new Bundle(), { 'primaryBitstreamUUID': null });
bundleDataService = jasmine.createSpyObj('BundleDataService', ['patch']);
bundleDataService.patch.and.callFake((a, b) => createSuccessfulRemoteDataObject$(a));
allFormats = [ allFormats = [
Object.assign({ Object.assign({
id: '1', id: '1',
@@ -53,7 +66,7 @@ describe('EditBitstreamPageComponent', () => {
supportLevel: BitstreamFormatSupportLevel.Unknown, supportLevel: BitstreamFormatSupportLevel.Unknown,
mimetype: 'application/octet-stream', mimetype: 'application/octet-stream',
_links: { _links: {
self: {href: 'format-selflink-1'} self: { href: 'format-selflink-1' }
} }
}), }),
Object.assign({ Object.assign({
@@ -63,7 +76,7 @@ describe('EditBitstreamPageComponent', () => {
supportLevel: BitstreamFormatSupportLevel.Known, supportLevel: BitstreamFormatSupportLevel.Known,
mimetype: 'image/png', mimetype: 'image/png',
_links: { _links: {
self: {href: 'format-selflink-2'} self: { href: 'format-selflink-2' }
} }
}), }),
Object.assign({ Object.assign({
@@ -73,7 +86,7 @@ describe('EditBitstreamPageComponent', () => {
supportLevel: BitstreamFormatSupportLevel.Known, supportLevel: BitstreamFormatSupportLevel.Known,
mimetype: 'image/gif', mimetype: 'image/gif',
_links: { _links: {
self: {href: 'format-selflink-3'} self: { href: 'format-selflink-3' }
} }
}) })
] as BitstreamFormat[]; ] as BitstreamFormat[];
@@ -112,6 +125,8 @@ describe('EditBitstreamPageComponent', () => {
const bundleName = 'ORIGINAL'; const bundleName = 'ORIGINAL';
bitstream = Object.assign(new Bitstream(), { bitstream = Object.assign(new Bitstream(), {
uuid: bitstreamID,
id: bitstreamID,
metadata: { metadata: {
'dc.description': [ 'dc.description': [
{ {
@@ -155,17 +170,19 @@ describe('EditBitstreamPageComponent', () => {
imports: [TranslateModule.forRoot(), RouterTestingModule], imports: [TranslateModule.forRoot(), RouterTestingModule],
declarations: [EditBitstreamPageComponent, FileSizePipe, VarDirective], declarations: [EditBitstreamPageComponent, FileSizePipe, VarDirective],
providers: [ providers: [
{provide: NotificationsService, useValue: notificationsService}, { provide: NotificationsService, useValue: notificationsService },
{provide: DynamicFormService, useValue: formService}, { provide: DynamicFormService, useValue: formService },
{provide: ActivatedRoute, {
provide: ActivatedRoute,
useValue: { useValue: {
data: observableOf({bitstream: createSuccessfulRemoteDataObject(bitstream)}), data: observableOf({ bitstream: createSuccessfulRemoteDataObject(bitstream) }),
snapshot: {queryParams: {}} snapshot: { queryParams: {} }
} }
}, },
{provide: BitstreamDataService, useValue: bitstreamService}, { provide: BitstreamDataService, useValue: bitstreamService },
{provide: DSONameService, useValue: dsoNameService}, { provide: DSONameService, useValue: dsoNameService },
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService}, { provide: BitstreamFormatDataService, useValue: bitstreamFormatService },
{ provide: BundleDataService, useValue: bundleDataService },
ChangeDetectorRef ChangeDetectorRef
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
@@ -203,6 +220,27 @@ describe('EditBitstreamPageComponent', () => {
it('should put the \"New Format\" input on invisible', () => { it('should put the \"New Format\" input on invisible', () => {
expect(comp.formLayout.newFormat.grid.host).toContain('invisible'); expect(comp.formLayout.newFormat.grid.host).toContain('invisible');
}); });
describe('when the bitstream is the primary bitstream on the bundle', () => {
beforeEach(() => {
(comp as any).bundle = bundleWithCurrentPrimary;
comp.setForm();
rawForm = comp.formGroup.getRawValue();
});
it('should enable the primary bitstream toggle', () => {
expect(rawForm.fileNamePrimaryContainer.primaryBitstream).toEqual(true);
});
});
describe('when the bitstream is not the primary bitstream on the bundle', () => {
beforeEach(() => {
(comp as any).bundle = bundleWithDifferentPrimary;
comp.setForm();
rawForm = comp.formGroup.getRawValue();
});
it('should disable the primary bitstream toggle', () => {
expect(rawForm.fileNamePrimaryContainer.primaryBitstream).toEqual(false);
});
});
}); });
describe('when an unknown format is selected', () => { describe('when an unknown format is selected', () => {
@@ -216,6 +254,95 @@ describe('EditBitstreamPageComponent', () => {
}); });
describe('onSubmit', () => { describe('onSubmit', () => {
describe('when the primaryBitstream changed', () => {
describe('to the current bitstream', () => {
beforeEach(() => {
const rawValue = Object.assign(comp.formGroup.getRawValue(), { fileNamePrimaryContainer: { primaryBitstream: true } });
spyOn(comp.formGroup, 'getRawValue').and.returnValue(rawValue);
});
describe('from a different primary bitstream', () => {
beforeEach(() => {
(comp as any).bundle = bundleWithDifferentPrimary;
comp.onSubmit();
});
it('should call patch with a replace operation', () => {
expect(bundleDataService.patch).toHaveBeenCalledWith(bundleWithDifferentPrimary, [jasmine.objectContaining({
op: 'replace'
})]);
});
it('should call patch with the correct bitstream uuid', () => {
expect(bundleDataService.patch).toHaveBeenCalledWith(bundleWithDifferentPrimary, [jasmine.objectContaining({
value: bitstreamID
})]);
});
});
describe('from no primary bitstream', () => {
beforeEach(() => {
(comp as any).bundle = bundleWithNoPrimary;
comp.onSubmit();
});
it('should call patch with an add operation', () => {
expect(bundleDataService.patch).toHaveBeenCalledWith(bundleWithNoPrimary, [jasmine.objectContaining({
op: 'add'
})]);
});
it('should call patch with the correct bitstream uuid', () => {
expect(bundleDataService.patch).toHaveBeenCalledWith(bundleWithNoPrimary, [jasmine.objectContaining({
value: bitstreamID
})]);
});
});
});
describe('to no primary bitstream', () => {
beforeEach(() => {
const rawValue = Object.assign(comp.formGroup.getRawValue(), { fileNamePrimaryContainer: { primaryBitstream: false } });
spyOn(comp.formGroup, 'getRawValue').and.returnValue(rawValue);
});
describe('from the current bitstream', () => {
beforeEach(() => {
(comp as any).bundle = bundleWithCurrentPrimary;
comp.onSubmit();
});
it('should call patch with a remove operation', () => {
expect(bundleDataService.patch).toHaveBeenCalledWith(bundleWithCurrentPrimary, [jasmine.objectContaining({
op: 'remove'
})]);
});
});
});
});
describe('when the primaryBitstream did not changed', () => {
describe('the current bitstream stayed the primary bitstream', () => {
beforeEach(() => {
const rawValue = Object.assign(comp.formGroup.getRawValue(), { fileNamePrimaryContainer: { primaryBitstream: true } });
spyOn(comp.formGroup, 'getRawValue').and.returnValue(rawValue);
(comp as any).bundle = bundleWithCurrentPrimary;
comp.onSubmit();
});
it('should not call patch on the bundle data service', () => {
expect(bundleDataService.patch).not.toHaveBeenCalled();
});
});
describe('the bitstream was not and did not become the primary bitstream', () => {
beforeEach(() => {
const rawValue = Object.assign(comp.formGroup.getRawValue(), { fileNamePrimaryContainer: { primaryBitstream: false } });
spyOn(comp.formGroup, 'getRawValue').and.returnValue(rawValue);
(comp as any).bundle = bundleWithDifferentPrimary;
comp.onSubmit();
});
it('should not call patch on the bundle data service', () => {
expect(bundleDataService.patch).not.toHaveBeenCalled();
});
});
});
describe('when selected format hasn\'t changed', () => { describe('when selected format hasn\'t changed', () => {
beforeEach(() => { beforeEach(() => {
comp.onSubmit(); comp.onSubmit();
@@ -357,6 +484,7 @@ describe('EditBitstreamPageComponent', () => {
{provide: BitstreamDataService, useValue: bitstreamService}, {provide: BitstreamDataService, useValue: bitstreamService},
{provide: DSONameService, useValue: dsoNameService}, {provide: DSONameService, useValue: dsoNameService},
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService}, {provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
{ provide: BundleDataService, useValue: bundleDataService },
ChangeDetectorRef ChangeDetectorRef
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
@@ -371,7 +499,6 @@ describe('EditBitstreamPageComponent', () => {
spyOn(router, 'navigate'); spyOn(router, 'navigate');
}); });
describe('on startup', () => { describe('on startup', () => {
let rawForm; let rawForm;
@@ -475,6 +602,7 @@ describe('EditBitstreamPageComponent', () => {
{provide: BitstreamDataService, useValue: bitstreamService}, {provide: BitstreamDataService, useValue: bitstreamService},
{provide: DSONameService, useValue: dsoNameService}, {provide: DSONameService, useValue: dsoNameService},
{provide: BitstreamFormatDataService, useValue: bitstreamFormatService}, {provide: BitstreamFormatDataService, useValue: bitstreamFormatService},
{ provide: BundleDataService, useValue: bundleDataService },
ChangeDetectorRef ChangeDetectorRef
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]

View File

@@ -52,6 +52,7 @@ import {
DsDynamicInputModel DsDynamicInputModel
} from '../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-input.model'; } from '../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-input.model';
import { DsDynamicTextAreaModel } from '../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-textarea.model'; import { DsDynamicTextAreaModel } from '../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
import { BundleDataService } from '../../core/data/bundle-data.service';
@Component({ @Component({
selector: 'ds-edit-bitstream-page', selector: 'ds-edit-bitstream-page',
@@ -191,19 +192,19 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
* The Dynamic Input Model for the iiif label * The Dynamic Input Model for the iiif label
*/ */
iiifLabelModel = new DsDynamicInputModel({ iiifLabelModel = new DsDynamicInputModel({
hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '', hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '',
id: 'iiifLabel', id: 'iiifLabel',
name: 'iiifLabel' name: 'iiifLabel'
}, },
{ {
grid: { grid: {
host: 'col col-lg-6 d-inline-block' host: 'col col-lg-6 d-inline-block'
} }
}); });
iiifLabelContainer = new DynamicFormGroupModel({ iiifLabelContainer = new DynamicFormGroupModel({
id: 'iiifLabelContainer', id: 'iiifLabelContainer',
group: [this.iiifLabelModel] group: [this.iiifLabelModel]
},{ }, {
grid: { grid: {
host: 'form-row' host: 'form-row'
} }
@@ -213,7 +214,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '', hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '',
id: 'iiifToc', id: 'iiifToc',
name: 'iiifToc', name: 'iiifToc',
},{ }, {
grid: { grid: {
host: 'col col-lg-6 d-inline-block' host: 'col col-lg-6 d-inline-block'
} }
@@ -221,7 +222,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
iiifTocContainer = new DynamicFormGroupModel({ iiifTocContainer = new DynamicFormGroupModel({
id: 'iiifTocContainer', id: 'iiifTocContainer',
group: [this.iiifTocModel] group: [this.iiifTocModel]
},{ }, {
grid: { grid: {
host: 'form-row' host: 'form-row'
} }
@@ -231,7 +232,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '', hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '',
id: 'iiifWidth', id: 'iiifWidth',
name: 'iiifWidth', name: 'iiifWidth',
},{ }, {
grid: { grid: {
host: 'col col-lg-6 d-inline-block' host: 'col col-lg-6 d-inline-block'
} }
@@ -239,7 +240,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
iiifWidthContainer = new DynamicFormGroupModel({ iiifWidthContainer = new DynamicFormGroupModel({
id: 'iiifWidthContainer', id: 'iiifWidthContainer',
group: [this.iiifWidthModel] group: [this.iiifWidthModel]
},{ }, {
grid: { grid: {
host: 'form-row' host: 'form-row'
} }
@@ -249,7 +250,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '', hasSelectableMetadata: false, metadataFields: [], repeatable: false, submissionId: '',
id: 'iiifHeight', id: 'iiifHeight',
name: 'iiifHeight' name: 'iiifHeight'
},{ }, {
grid: { grid: {
host: 'col col-lg-6 d-inline-block' host: 'col col-lg-6 d-inline-block'
} }
@@ -257,7 +258,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
iiifHeightContainer = new DynamicFormGroupModel({ iiifHeightContainer = new DynamicFormGroupModel({
id: 'iiifHeightContainer', id: 'iiifHeightContainer',
group: [this.iiifHeightModel] group: [this.iiifHeightModel]
},{ }, {
grid: { grid: {
host: 'form-row' host: 'form-row'
} }
@@ -280,11 +281,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
this.fileNameModel, this.fileNameModel,
this.primaryBitstreamModel this.primaryBitstreamModel
] ]
},{ }, {
grid: { grid: {
host: 'form-row' host: 'form-row'
} }
}), }),
new DynamicFormGroupModel({ new DynamicFormGroupModel({
id: 'descriptionContainer', id: 'descriptionContainer',
group: [ group: [
@@ -380,13 +381,23 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
*/ */
isIIIF = false; isIIIF = false;
/** /**
* Array to track all subscriptions and unsubscribe them onDestroy * Array to track all subscriptions and unsubscribe them onDestroy
* @type {Array} * @type {Array}
*/ */
protected subs: Subscription[] = []; protected subs: Subscription[] = [];
/**
* The parent bundle containing the Bitstream
* @private
*/
private bundle: Bundle;
/**
* Path to patch primary bitstream on the bundle
* @private
*/
private readonly primaryBitstreamPath = '/primarybitstream';
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
@@ -397,7 +408,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
private bitstreamService: BitstreamDataService, private bitstreamService: BitstreamDataService,
private dsoNameService: DSONameService, private dsoNameService: DSONameService,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private bitstreamFormatService: BitstreamFormatDataService) { private bitstreamFormatService: BitstreamFormatDataService,
private bundleService: BundleDataService) {
} }
/** /**
@@ -423,13 +435,20 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
getRemoteDataPayload() getRemoteDataPayload()
); );
const bundle$ = bitstream$.pipe(
switchMap((bitstream: Bitstream) => bitstream.bundle),
getFirstSucceededRemoteDataPayload(),
);
this.subs.push( this.subs.push(
observableCombineLatest( observableCombineLatest(
bitstream$, bitstream$,
allFormats$ allFormats$,
).subscribe(([bitstream, allFormats]) => { bundle$
).subscribe(([bitstream, allFormats, bundle]) => {
this.bitstream = bitstream as Bitstream; this.bitstream = bitstream as Bitstream;
this.formats = allFormats.page; this.formats = allFormats.page;
this.bundle = bundle;
this.setIiifStatus(this.bitstream); this.setIiifStatus(this.bitstream);
}) })
); );
@@ -437,8 +456,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
this.subs.push( this.subs.push(
this.translate.onLangChange this.translate.onLangChange
.subscribe(() => { .subscribe(() => {
this.updateFieldTranslations(); this.updateFieldTranslations();
}) })
); );
} }
@@ -460,7 +479,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
this.formGroup.patchValue({ this.formGroup.patchValue({
fileNamePrimaryContainer: { fileNamePrimaryContainer: {
fileName: bitstream.name, fileName: bitstream.name,
primaryBitstream: false primaryBitstream: this.bundle.primaryBitstreamUUID === bitstream.uuid
}, },
descriptionContainer: { descriptionContainer: {
description: bitstream.firstMetadataValue('dc.description') description: bitstream.firstMetadataValue('dc.description')
@@ -563,6 +582,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
} }
} }
/** /**
* Check for changes against the bitstream and send update requests to the REST API * Check for changes against the bitstream and send update requests to the REST API
*/ */
@@ -571,9 +591,45 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
const updatedBitstream = this.formToBitstream(updatedValues); const updatedBitstream = this.formToBitstream(updatedValues);
const selectedFormat = this.formats.find((f: BitstreamFormat) => f.id === updatedValues.formatContainer.selectedFormat); const selectedFormat = this.formats.find((f: BitstreamFormat) => f.id === updatedValues.formatContainer.selectedFormat);
const isNewFormat = selectedFormat.id !== this.originalFormat.id; const isNewFormat = selectedFormat.id !== this.originalFormat.id;
const isPrimary = updatedValues.fileNamePrimaryContainer.primaryBitstream;
const wasPrimary = this.bundle.primaryBitstreamUUID === this.bitstream.uuid;
let bitstream$; let bitstream$;
let bundle$: Observable<Bundle>;
if (wasPrimary !== isPrimary) {
let patchOperation;
// No longer primary bitstream: remove
if (wasPrimary) {
patchOperation = {
path: this.primaryBitstreamPath,
op: 'remove'
};
} else {
// Has become primary bitstream
// If it already had a value: replace, otherwise: add
patchOperation = {
path: this.primaryBitstreamPath,
op: hasValue(this.bundle.primaryBitstreamUUID) ? 'replace' : 'add',
value: this.bitstream.uuid
};
}
bundle$ = this.bundleService.patch(this.bundle, [patchOperation]).pipe(
getFirstCompletedRemoteData(),
map((bundleResponse: RemoteData<Bundle>) => {
if (hasValue(bundleResponse) && bundleResponse.hasFailed) {
this.notificationsService.error(
this.translate.instant(this.NOTIFICATIONS_PREFIX + 'error.primaryBitstream.title'),
bundleResponse.errorMessage
);
} else {
return bundleResponse.payload;
}
})
);
} else {
bundle$ = observableOf(this.bundle);
}
if (isNewFormat) { if (isNewFormat) {
bitstream$ = this.bitstreamService.updateFormat(this.bitstream, selectedFormat).pipe( bitstream$ = this.bitstreamService.updateFormat(this.bitstream, selectedFormat).pipe(
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),
@@ -592,7 +648,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
bitstream$ = observableOf(this.bitstream); bitstream$ = observableOf(this.bitstream);
} }
bitstream$.pipe( combineLatest([bundle$, bitstream$]).pipe(
switchMap(() => { switchMap(() => {
return this.bitstreamService.update(updatedBitstream).pipe( return this.bitstreamService.update(updatedBitstream).pipe(
getFirstSucceededRemoteDataPayload() getFirstSucceededRemoteDataPayload()
@@ -633,11 +689,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
} else { } else {
Metadata.setFirstValue(newMetadata, this.IIIF_LABEL_METADATA, rawForm.iiifLabelContainer.iiifLabel); Metadata.setFirstValue(newMetadata, this.IIIF_LABEL_METADATA, rawForm.iiifLabelContainer.iiifLabel);
} }
if (isEmpty(rawForm.iiifTocContainer.iiifToc)) { if (isEmpty(rawForm.iiifTocContainer.iiifToc)) {
delete newMetadata[this.IIIF_TOC_METADATA]; delete newMetadata[this.IIIF_TOC_METADATA];
} else { } else {
Metadata.setFirstValue(newMetadata, this.IIIF_TOC_METADATA, rawForm.iiifTocContainer.iiifToc); Metadata.setFirstValue(newMetadata, this.IIIF_TOC_METADATA, rawForm.iiifTocContainer.iiifToc);
} }
if (isEmpty(rawForm.iiifWidthContainer.iiifWidth)) { if (isEmpty(rawForm.iiifWidthContainer.iiifWidth)) {
delete newMetadata[this.IMAGE_WIDTH_METADATA]; delete newMetadata[this.IMAGE_WIDTH_METADATA];
} else { } else {
@@ -672,10 +728,10 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
this.router.navigate([getEntityEditRoute(this.entityType, this.itemId), 'bitstreams']); this.router.navigate([getEntityEditRoute(this.entityType, this.itemId), 'bitstreams']);
} else { } else {
this.bitstream.bundle.pipe(getFirstSucceededRemoteDataPayload(), this.bitstream.bundle.pipe(getFirstSucceededRemoteDataPayload(),
mergeMap((bundle: Bundle) => bundle.item.pipe(getFirstSucceededRemoteDataPayload()))) mergeMap((bundle: Bundle) => bundle.item.pipe(getFirstSucceededRemoteDataPayload())))
.subscribe((item) => { .subscribe((item) => {
this.router.navigate(([getItemEditRoute(item), 'bitstreams'])); this.router.navigate(([getItemEditRoute(item), 'bitstreams']));
}); });
} }
} }
@@ -701,11 +757,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
const isEnabled$ = this.bitstream.bundle.pipe( const isEnabled$ = this.bitstream.bundle.pipe(
getFirstSucceededRemoteData(), getFirstSucceededRemoteData(),
map((bundle: RemoteData<Bundle>) => bundle.payload.item.pipe( map((bundle: RemoteData<Bundle>) => bundle.payload.item.pipe(
getFirstSucceededRemoteData(), getFirstSucceededRemoteData(),
map((item: RemoteData<Item>) => map((item: RemoteData<Item>) =>
(item.payload.firstMetadataValue('dspace.iiif.enabled') && (item.payload.firstMetadataValue('dspace.iiif.enabled') &&
item.payload.firstMetadataValue('dspace.iiif.enabled').match(regexIIIFItem) !== null) item.payload.firstMetadataValue('dspace.iiif.enabled').match(regexIIIFItem) !== null)
)))); ))));
const iiifSub = combineLatest( const iiifSub = combineLatest(
isImage$, isImage$,

View File

@@ -1,4 +1,4 @@
import { deserialize, inheritSerialization } from 'cerialize'; import { autoserializeAs, deserialize, inheritSerialization } from 'cerialize';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@@ -29,6 +29,12 @@ export class Bundle extends DSpaceObject {
item: HALLink; item: HALLink;
}; };
/**
* The ID of the primaryBitstream of this Bundle
*/
@autoserializeAs('primarybitstream')
primaryBitstreamUUID: string;
/** /**
* The primary Bitstream of this Bundle * The primary Bitstream of this Bundle
* Will be undefined unless the primaryBitstream {@link HALLink} has been resolved. * Will be undefined unless the primaryBitstream {@link HALLink} has been resolved.