@@ -26,6 +26,10 @@ import { Item } from '../../core/shared/item.model';
2626import { DsDynamicInputModel } from '../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-input.model' ;
2727import { DsDynamicTextAreaModel } from '../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-textarea.model' ;
2828import { PrimaryBitstreamService } from '../../core/data/primary-bitstream.service' ;
29+ import { VocabularyService } from '../../core/submission/vocabularies/vocabulary.service' ;
30+ import { VocabularyOptions } from '../../core/submission/vocabularies/models/vocabulary-options.model' ;
31+ import { PageInfo } from '../../core/shared/page-info.model' ;
32+ import { VocabularyEntry } from '../../core/submission/vocabularies/models/vocabulary-entry.model' ;
2933
3034@Component ( {
3135 selector : 'ds-edit-bitstream-page' ,
@@ -254,6 +258,8 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
254258 }
255259 } ) ;
256260
261+ hideModel : DynamicSelectModel < string > ;
262+
257263 /**
258264 * All input models in a simple array for easier iterations
259265 */
@@ -326,6 +332,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
326332 host : 'col-12 d-inline-block'
327333 }
328334 } ,
335+ hide : {
336+ grid : {
337+ host : 'col-12 d-inline-block'
338+ }
339+ } ,
329340 embargo : {
330341 grid : {
331342 host : 'col-12 d-inline-block'
@@ -405,6 +416,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
405416 private notificationsService : NotificationsService ,
406417 private bitstreamFormatService : BitstreamFormatDataService ,
407418 private primaryBitstreamService : PrimaryBitstreamService ,
419+ private vocabularyService : VocabularyService
408420 ) {
409421 }
410422
@@ -446,22 +458,32 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
446458 switchMap ( ( bundle : Bundle ) => bundle . item ) ,
447459 getFirstSucceededRemoteDataPayload ( ) ,
448460 ) ;
461+ const vocabularyOptions = new VocabularyOptions (
462+ 'truefalse' ,
463+ 'bitstream.hide' ,
464+ ) ;
465+ const pageInfo = new PageInfo ( ) ;
466+ const hide$ : Observable < VocabularyEntry [ ] > = this . vocabularyService . getVocabularyEntries ( vocabularyOptions , pageInfo ) . pipe (
467+ getFirstCompletedRemoteData ( ) ,
468+ map ( ( rq ) => rq . hasSucceeded ? rq . payload . page : [ ] ) ,
469+ ) ;
449470 this . subs . push (
450- observableCombineLatest (
471+ observableCombineLatest ( [
451472 bitstream$ ,
452473 allFormats$ ,
453474 bundle$ ,
454475 primaryBitstream$ ,
455476 item$ ,
456- ) . pipe ( )
457- . subscribe ( ( [ bitstream , allFormats , bundle , primaryBitstream , item ] ) => {
477+ hide$ ,
478+ ] ) . subscribe ( ( [ bitstream , allFormats , bundle , primaryBitstream , item , entries ] ) => {
458479 this . bitstream = bitstream as Bitstream ;
459480 this . formats = allFormats . page ;
460481 this . bundle = bundle ;
461482 // hasValue(primaryBitstream) because if there's no primaryBitstream on the bundle it will
462483 // be a success response, but empty
463484 this . primaryBitstreamUUID = hasValue ( primaryBitstream ) ? primaryBitstream . uuid : null ;
464485 this . itemId = item . uuid ;
486+ this . handleHideBitstream ( entries ) ;
465487 this . setIiifStatus ( this . bitstream ) ;
466488 } )
467489 ) ;
@@ -473,6 +495,26 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
473495 } )
474496 ) ;
475497 }
498+ handleHideBitstream ( entries : VocabularyEntry [ ] ) {
499+ if ( isEmpty ( entries ) ) {
500+ return ;
501+ }
502+ const options = entries . map ( ( entry ) => ( { label : entry . display , value : entry . value } ) ) ;
503+ let hideModel = new DynamicSelectModel ( {
504+ id : 'hide' ,
505+ name : 'hide' ,
506+ options : options
507+ } ) ;
508+ this . hideModel = hideModel ;
509+ this . inputModels . push ( this . hideModel ) ;
510+ const groupModel = new DynamicFormGroupModel ( {
511+ id : 'hideContainer' ,
512+ group : [
513+ hideModel
514+ ]
515+ } ) ;
516+ this . formModel . push ( groupModel ) ;
517+ }
476518
477519 /**
478520 * Initializes the form.
@@ -500,6 +542,9 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
500542 fileTypeContainer : {
501543 fileType : bitstream . firstMetadataValue ( 'dc.type' )
502544 } ,
545+ hideContainer : {
546+ hide : bitstream . firstMetadataValue ( 'bitstream.hide' )
547+ } ,
503548 formatContainer : {
504549 newFormat : hasValue ( bitstream . firstMetadata ( 'dc.format' ) ) ? bitstream . firstMetadata ( 'dc.format' ) . value : undefined
505550 }
@@ -711,6 +756,11 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy {
711756 } else {
712757 Metadata . setFirstValue ( newMetadata , 'dc.type' , rawForm . fileTypeContainer . fileType ) ;
713758 }
759+ if ( isEmpty ( rawForm . hideContainer . hide ) ) {
760+ delete newMetadata [ 'bitstream.hide' ] ;
761+ } else {
762+ Metadata . setFirstValue ( newMetadata , 'bitstream.hide' , rawForm . hideContainer . hide ) ;
763+ }
714764 if ( this . isIIIF ) {
715765 // It's helpful to remove these metadata elements entirely when the form value is empty.
716766 // This avoids potential issues on the REST side and makes it possible to do things like
0 commit comments