@@ -36,6 +36,8 @@ export interface NewCollectionMetadataBlocksRequestPayload {
3636 metadataBlockNames ?: string [ ]
3737 facetIds ?: string [ ]
3838 inputLevels ?: NewCollectionInputLevelRequestPayload [ ]
39+ inheritMetadataBlocksFromParent ?: boolean
40+ inheritFacetsFromParent ?: boolean
3941}
4042
4143export interface NewCollectionInputLevelRequestPayload {
@@ -186,18 +188,29 @@ export class CollectionsRepository extends ApiRepository implements ICollections
186188 required : inputLevel . required
187189 } ) )
188190
191+ const metadataBlocksRequestBody : NewCollectionMetadataBlocksRequestPayload = { }
192+
193+ if ( collectionDTO . metadataBlockNames && collectionDTO . inputLevels ) {
194+ metadataBlocksRequestBody [ 'metadataBlockNames' ] = collectionDTO . metadataBlockNames
195+ metadataBlocksRequestBody [ 'inputLevels' ] = inputLevelsRequestBody
196+ } else {
197+ metadataBlocksRequestBody [ 'inheritMetadataBlocksFromParent' ] = true
198+ }
199+
200+ if ( collectionDTO . facetIds ) {
201+ metadataBlocksRequestBody [ 'facetIds' ] = collectionDTO . facetIds
202+ } else {
203+ metadataBlocksRequestBody [ 'inheritFacetsFromParent' ] = true
204+ }
205+
189206 return {
190207 alias : collectionDTO . alias ,
191208 name : collectionDTO . name ,
192209 dataverseContacts : dataverseContacts ,
193210 dataverseType : collectionDTO . type ,
194211 ...( collectionDTO . description && { description : collectionDTO . description } ) ,
195212 ...( collectionDTO . affiliation && { affiliation : collectionDTO . affiliation } ) ,
196- metadataBlocks : {
197- metadataBlockNames : collectionDTO . metadataBlockNames ,
198- facetIds : collectionDTO . facetIds ,
199- inputLevels : inputLevelsRequestBody
200- }
213+ metadataBlocks : metadataBlocksRequestBody
201214 }
202215 }
203216
0 commit comments