Skip to content
Snippets Groups Projects
Commit 7fce3df3 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

68346: bitstream edit bugfix

parent 0f55ee8a
No related branches found
No related tags found
No related merge requests found
......@@ -429,7 +429,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
*/
onSubmit() {
const updatedValues = this.formGroup.getRawValue();
this.formToBitstream(updatedValues);
const updatedBitstream = this.formToBitstream(updatedValues);
const selectedFormat = this.formats.find((f: BitstreamFormat) => f.id === updatedValues.formatContainer.selectedFormat);
const isNewFormat = selectedFormat.id !== this.originalFormat.id;
......@@ -456,7 +456,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
bitstream$.pipe(
switchMap(() => {
return this.bitstreamService.update(this.bitstream).pipe(
return this.bitstreamService.update(updatedBitstream).pipe(
getFirstSucceededRemoteDataPayload()
);
})
......@@ -473,8 +473,9 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
* Parse form data to an updated bitstream object
* @param rawForm Raw form data
*/
formToBitstream(rawForm) {
const newMetadata = cloneDeep(this.bitstream.metadata);
formToBitstream(rawForm): Bitstream {
const updatedBitstream = cloneDeep(this.bitstream);
const newMetadata = updatedBitstream.metadata;
// TODO: Set bitstream to primary when supported
const primary = rawForm.fileNamePrimaryContainer.primaryBitstream;
Metadata.setFirstValue(newMetadata, 'dc.title', rawForm.fileNamePrimaryContainer.fileName);
......@@ -482,7 +483,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
if (isNotEmpty(rawForm.formatContainer.newFormat)) {
Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.newFormat);
}
this.bitstream.metadata = newMetadata;
updatedBitstream.metadata = newMetadata;
return updatedBitstream;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment