68346: bitstream edit bugfix

This commit is contained in:
Kristof De Langhe
2020-03-14 01:19:00 +01:00
parent 0f55ee8adb
commit 7fce3df3b4

View File

@@ -429,7 +429,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
*/ */
onSubmit() { onSubmit() {
const updatedValues = this.formGroup.getRawValue(); 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 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;
@@ -456,7 +456,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
bitstream$.pipe( bitstream$.pipe(
switchMap(() => { switchMap(() => {
return this.bitstreamService.update(this.bitstream).pipe( return this.bitstreamService.update(updatedBitstream).pipe(
getFirstSucceededRemoteDataPayload() getFirstSucceededRemoteDataPayload()
); );
}) })
@@ -473,8 +473,9 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
* Parse form data to an updated bitstream object * Parse form data to an updated bitstream object
* @param rawForm Raw form data * @param rawForm Raw form data
*/ */
formToBitstream(rawForm) { formToBitstream(rawForm): Bitstream {
const newMetadata = cloneDeep(this.bitstream.metadata); const updatedBitstream = cloneDeep(this.bitstream);
const newMetadata = updatedBitstream.metadata;
// TODO: Set bitstream to primary when supported // TODO: Set bitstream to primary when supported
const primary = rawForm.fileNamePrimaryContainer.primaryBitstream; const primary = rawForm.fileNamePrimaryContainer.primaryBitstream;
Metadata.setFirstValue(newMetadata, 'dc.title', rawForm.fileNamePrimaryContainer.fileName); Metadata.setFirstValue(newMetadata, 'dc.title', rawForm.fileNamePrimaryContainer.fileName);
@@ -482,7 +483,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
if (isNotEmpty(rawForm.formatContainer.newFormat)) { if (isNotEmpty(rawForm.formatContainer.newFormat)) {
Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.newFormat); Metadata.setFirstValue(newMetadata, 'dc.format', rawForm.formatContainer.newFormat);
} }
this.bitstream.metadata = newMetadata; updatedBitstream.metadata = newMetadata;
return updatedBitstream;
} }
/** /**