@@ -46,6 +46,9 @@ import {
4646 DynamicFormLayout ,
4747 DynamicFormService ,
4848 DynamicInputModel ,
49+ DynamicSelectModel ,
50+ MATCH_VISIBLE ,
51+ OR_OPERATOR ,
4952} from '@ng-dynamic-forms/core' ;
5053import {
5154 TranslateModule ,
@@ -338,11 +341,92 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
338341 } ,
339342 } ) ;
340343
344+
345+ /**
346+ * The Dynamic Select Model for the media type
347+ */
348+ mediaTypeModel = new DynamicSelectModel ( {
349+ id : 'mediaType' ,
350+ name : 'mediaType' ,
351+ options : [
352+ {
353+ label : this . translate . instant ( 'bitstream.edit.form.mediaType.option.neither' ) ,
354+ value : 'neither' ,
355+ } ,
356+ {
357+ label : this . translate . instant ( 'bitstream.edit.form.mediaType.option.audio' ) ,
358+ value : 'audio' ,
359+ } ,
360+ {
361+ label : this . translate . instant ( 'bitstream.edit.form.mediaType.option.video' ) ,
362+ value : 'video' ,
363+ } ,
364+ {
365+ label : this . translate . instant ( 'bitstream.edit.form.mediaType.option.audio-video' ) ,
366+ value : 'audio+video' ,
367+ } ,
368+ ] ,
369+ value : 'neither' ,
370+ } ) ;
371+
372+ /**
373+ * The Dynamic TextArea Model for the audio transcript
374+ */
375+ audioTranscriptModel = new DsDynamicTextAreaModel ( {
376+ hasSelectableMetadata : false , metadataFields : [ ] , repeatable : false , submissionId : '' ,
377+ id : 'audioTranscript' ,
378+ name : 'audioTranscript' ,
379+ rows : 10 ,
380+ relations : [
381+ {
382+ match : MATCH_VISIBLE ,
383+ operator : OR_OPERATOR ,
384+ when : [
385+ {
386+ id : 'mediaType' ,
387+ value : 'audio' ,
388+ } ,
389+ {
390+ id : 'mediaType' ,
391+ value : 'audio+video' ,
392+ } ,
393+ ] ,
394+ } ,
395+ ] ,
396+ } ) ;
397+
398+ /**
399+ * The Dynamic TextArea Model for the video description
400+ */
401+ videoDescriptionModel = new DsDynamicTextAreaModel ( {
402+ hasSelectableMetadata : false , metadataFields : [ ] , repeatable : false , submissionId : '' ,
403+ id : 'videoDescription' ,
404+ name : 'videoDescription' ,
405+ rows : 10 ,
406+ relations : [
407+ {
408+ match : MATCH_VISIBLE ,
409+ operator : OR_OPERATOR ,
410+ when : [
411+ {
412+ id : 'mediaType' ,
413+ value : 'video' ,
414+ } ,
415+ {
416+ id : 'mediaType' ,
417+ value : 'audio+video' ,
418+ } ,
419+ ] ,
420+ } ,
421+ ] ,
422+ } ) ;
423+
424+
341425 /**
342426 * All input models in a simple array for easier iterations
343427 */
344- inputModels = [ this . primaryBitstreamModel , this . fileNameModel , this . descriptionModel , this . selectedFormatModel ,
345- this . newFormatModel ] ;
428+ inputModels = [ this . primaryBitstreamModel , this . fileNameModel , this . descriptionModel , this . mediaTypeModel ,
429+ this . audioTranscriptModel , this . videoDescriptionModel , this . selectedFormatModel , this . newFormatModel ] ;
346430
347431 /**
348432 * The dynamic form fields used for editing the information of a bitstream
@@ -366,6 +450,18 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
366450 this . descriptionModel ,
367451 ] ,
368452 } ) ,
453+ new DynamicFormGroupModel ( {
454+ id : 'mediaInfoContainer' ,
455+ group : [
456+ this . mediaTypeModel ,
457+ this . audioTranscriptModel ,
458+ this . videoDescriptionModel ,
459+ ] ,
460+ } , {
461+ grid : {
462+ host : 'row' ,
463+ } ,
464+ } ) ,
369465 new DynamicFormGroupModel ( {
370466 id : 'formatContainer' ,
371467 group : [
@@ -417,6 +513,21 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
417513 host : this . newFormatBaseLayout + ' invisible' ,
418514 } ,
419515 } ,
516+ mediaType : {
517+ grid : {
518+ host : 'col-12 d-inline-block' ,
519+ } ,
520+ } ,
521+ audioTranscript : {
522+ grid : {
523+ host : 'col-12 d-inline-block' ,
524+ } ,
525+ } ,
526+ videoDescription : {
527+ grid : {
528+ host : 'col-12 d-inline-block' ,
529+ } ,
530+ } ,
420531 fileNamePrimaryContainer : {
421532 grid : {
422533 host : 'row position-relative' ,
@@ -427,6 +538,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
427538 host : 'row' ,
428539 } ,
429540 } ,
541+ mediaInfoContainer : {
542+ grid : {
543+ host : 'row' ,
544+ } ,
545+ } ,
430546 formatContainer : {
431547 grid : {
432548 host : 'row' ,
@@ -622,6 +738,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
622738 descriptionContainer : {
623739 description : bitstream . firstMetadataValue ( 'dc.description' ) ,
624740 } ,
741+ mediaInfoContainer : {
742+ mediaType : bitstream . firstMetadataValue ( 'dc.type' ) ?? 'neither' ,
743+ audioTranscript : bitstream . firstMetadataValue ( 'dspace.bitstream.transcript' ) ,
744+ videoDescription : bitstream . firstMetadataValue ( 'dspace.bitstream.textalternative' ) ,
745+ } ,
625746 formatContainer : {
626747 selectedFormat : this . selectedFormat . shortDescription ,
627748 newFormat : hasValue ( bitstream . firstMetadata ( 'dc.format' ) ) ? bitstream . firstMetadata ( 'dc.format' ) . value : undefined ,
@@ -800,6 +921,22 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
800921 } else {
801922 Metadata . setFirstValue ( newMetadata , 'dc.description' , rawForm . descriptionContainer . description ) ;
802923 }
924+ const mediaType = rawForm . mediaInfoContainer ?. mediaType ;
925+ if ( isEmpty ( mediaType ) || mediaType === 'neither' ) {
926+ delete newMetadata [ 'dc.type' ] ;
927+ } else {
928+ Metadata . setFirstValue ( newMetadata , 'dc.type' , mediaType ) ;
929+ }
930+ if ( isEmpty ( rawForm . mediaInfoContainer ?. audioTranscript ) ) {
931+ delete newMetadata [ 'dspace.bitstream.transcript' ] ;
932+ } else {
933+ Metadata . setFirstValue ( newMetadata , 'dspace.bitstream.transcript' , rawForm . mediaInfoContainer . audioTranscript ) ;
934+ }
935+ if ( isEmpty ( rawForm . mediaInfoContainer ?. videoDescription ) ) {
936+ delete newMetadata [ 'dspace.bitstream.textalternative' ] ;
937+ } else {
938+ Metadata . setFirstValue ( newMetadata , 'dspace.bitstream.textalternative' , rawForm . mediaInfoContainer . videoDescription ) ;
939+ }
803940 if ( this . isIIIF ) {
804941 // It's helpful to remove these metadata elements entirely when the form value is empty.
805942 // This avoids potential issues on the REST side and makes it possible to do things like
0 commit comments