Skip to content

Commit 959abe5

Browse files
[DSC-1634] align porting to get dynamically key for vocabulary
1 parent 45893cd commit 959abe5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/app/submission/sections/upload/file/section-upload-file.component.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit,
213213
.subscribe((bitstream) => {
214214
this.fileData = bitstream;
215215
const fileType = this.fileData.metadata['dc.type']?.map(data => data.value)[0];
216-
this.vocabularyFileType$ = !hasValue(fileType) ? of(null) : this.vocabularyService.getPublicVocabularyEntryByValue('bitstream_types', fileType).pipe(
216+
this.vocabularyFileType$ = !hasValue(fileType) ? of(null) : this.vocabularyService.getPublicVocabularyEntryByValue(this.getControlledVocabulary(this.configMetadataForm), fileType).pipe(
217217
getFirstCompletedRemoteData(),
218218
getRemoteDataPayload(),
219219
getPaginatedListPayload(),
@@ -319,4 +319,19 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit,
319319
}));
320320
}
321321

322+
/**
323+
* Retrieve vocabulary key for dc.type
324+
* @param model
325+
* @private
326+
*/
327+
private getControlledVocabulary(model: SubmissionFormsModel): string {
328+
return model.rows.filter(row =>
329+
hasValue(row.fields) &&
330+
hasValue(row.fields[0]) &&
331+
hasValue(row.fields[0].selectableMetadata) &&
332+
hasValue(row.fields[0].selectableMetadata[0]) &&
333+
row.fields[0].selectableMetadata[0].metadata === 'dc.type'
334+
).map((filteredRow) => filteredRow.fields[0].selectableMetadata[0].controlledVocabulary)[0];
335+
}
336+
322337
}

0 commit comments

Comments
 (0)