@@ -20,10 +20,8 @@ import {
2020 signal ,
2121} from '@angular/core' ;
2222import { takeUntilDestroyed , toSignal } from '@angular/core/rxjs-interop' ;
23- import { FormGroup } from '@angular/forms' ;
2423import { ActivatedRoute , Router , RouterLink } from '@angular/router' ;
2524
26- import { ENVIRONMENT } from '@core/provider/environment.provider' ;
2725import { UserSelectors } from '@core/store/user' ;
2826import { CedarMetadataRecordData , CedarRecordDataBinding } from '@osf/features/metadata/models' ;
2927import {
@@ -52,7 +50,6 @@ import {
5250 ClearAddToCollectionState ,
5351 GetCurrentCollectionSubmission ,
5452 RemoveCollectionSubmission ,
55- UpdateCollectionSubmission ,
5653} from '../../store/add-to-collection' ;
5754
5855import { AddToCollectionConfirmationDialogComponent } from './add-to-collection-confirmation-dialog/add-to-collection-confirmation-dialog.component' ;
@@ -90,16 +87,13 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
9087 private readonly headerStyleHelper = inject ( HeaderStyleService ) ;
9188 private readonly platformId = inject ( PLATFORM_ID ) ;
9289 private readonly isBrowser = isPlatformBrowser ( this . platformId ) ;
93- private readonly environment = inject ( ENVIRONMENT ) ;
9490
9591 readonly selectedProjectId = toSignal < string | null > (
9692 this . route . params . pipe ( map ( ( params ) => params [ 'id' ] ) ) ?? of ( null )
9793 ) ;
9894
9995 readonly AddToCollectionSteps = AddToCollectionSteps ;
10096
101- collectionMetadataForm = new FormGroup ( { } ) ;
102-
10397 isProviderLoading = select ( CollectionsSelectors . getCollectionProviderLoading ) ;
10498 collectionProvider = select ( CollectionsSelectors . getCollectionProvider ) ;
10599 requiredMetadataTemplate = select ( CollectionsSelectors . getRequiredMetadataTemplate ) ;
@@ -123,7 +117,6 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
123117 isCollectionMetadataDisabled = computed (
124118 ( ) => ! this . selectedProject ( ) || ! this . projectMetadataSaved ( ) || ! this . projectContributorsSaved ( )
125119 ) ;
126- isCedarMode = computed ( ( ) => this . environment . collectionSubmissionWithCedar && ! ! this . requiredMetadataTemplate ( ) ) ;
127120 existingCedarRecord = computed < CedarMetadataRecordData | null > ( ( ) => {
128121 const records = this . cedarRecords ( ) ;
129122 const templateId = this . requiredMetadataTemplate ( ) ?. id ;
@@ -134,7 +127,6 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
134127 readonly actions = createDispatchMap ( {
135128 getCollectionProvider : GetCollectionProvider ,
136129 clearAddToCollectionState : ClearAddToCollectionState ,
137- updateCollectionSubmission : UpdateCollectionSubmission ,
138130 deleteCollectionSubmission : RemoveCollectionSubmission ,
139131 setSelectedProject : SetSelectedProject ,
140132 getCurrentCollectionSubmission : GetCurrentCollectionSubmission ,
@@ -191,12 +183,6 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
191183 this . projectContributorsSaved . set ( true ) ;
192184 }
193185
194- handleCollectionMetadataSaved ( form : FormGroup ) : void {
195- this . collectionMetadataForm = form ;
196- this . collectionMetadataSaved . set ( true ) ;
197- this . stepperActiveValue . set ( AddToCollectionSteps . Complete ) ;
198- }
199-
200186 handleCedarDataSaved ( data : CedarRecordDataBinding ) : void {
201187 this . pendingCedarData . set ( data ) ;
202188 this . collectionMetadataSaved . set ( true ) ;
@@ -207,19 +193,14 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
207193 const payload = {
208194 collectionId : this . primaryCollectionId ( ) || '' ,
209195 projectId : this . selectedProject ( ) ?. id || '' ,
210- collectionMetadata : this . isCedarMode ( ) ? { } : this . collectionMetadataForm . value || { } ,
211196 userId : this . currentUser ( ) ?. id || '' ,
212197 } ;
213198
214- const isEditMode = this . isEditMode ( ) ;
215-
216- if ( isEditMode ) {
199+ if ( this . isEditMode ( ) ) {
217200 this . loaderService . show ( ) ;
218201
219- this . actions
220- . updateCollectionSubmission ( payload )
202+ this . saveCedarRecordIfNeeded ( )
221203 . pipe (
222- switchMap ( ( ) => this . saveCedarRecordIfNeeded ( ) ) ,
223204 finalize ( ( ) => this . loaderService . hide ( ) ) ,
224205 takeUntilDestroyed ( this . destroyRef )
225206 )
@@ -234,15 +215,17 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
234215 } ,
235216 } ) ;
236217 } else {
237- this . customDialogService
238- . open ( AddToCollectionConfirmationDialogComponent , {
239- header : 'collections.addToCollection.confirmationDialogHeader' ,
240- width : '500px' ,
241- data : { payload, project : this . selectedProject ( ) } ,
242- } )
243- . onClose . pipe (
244- filter ( ( res ) => ! ! res ) ,
245- switchMap ( ( ) => this . saveCedarRecordIfNeeded ( ) ) ,
218+ this . saveCedarRecordIfNeeded ( )
219+ . pipe (
220+ switchMap ( ( ) =>
221+ this . customDialogService
222+ . open ( AddToCollectionConfirmationDialogComponent , {
223+ header : 'collections.addToCollection.confirmationDialogHeader' ,
224+ width : '500px' ,
225+ data : { payload, project : this . selectedProject ( ) } ,
226+ } )
227+ . onClose . pipe ( filter ( ( res ) => ! ! res ) )
228+ ) ,
246229 takeUntilDestroyed ( this . destroyRef )
247230 )
248231 . subscribe ( {
@@ -294,8 +277,6 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
294277 }
295278
296279 private saveCedarRecordIfNeeded ( ) : Observable < unknown > {
297- if ( ! this . isCedarMode ( ) ) return of ( null ) ;
298-
299280 const cedarData = this . pendingCedarData ( ) ;
300281 const projectId = this . selectedProject ( ) ?. id ;
301282 const templateId = this . requiredMetadataTemplate ( ) ?. id ;
@@ -348,8 +329,7 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
348329
349330 effect ( ( ) => {
350331 const projectId = this . selectedProjectId ( ) ;
351- const isCedar = this . isCedarMode ( ) ;
352- if ( isCedar && projectId ) {
332+ if ( projectId ) {
353333 this . actions . getCedarRecords ( projectId , ResourceType . Project ) ;
354334 }
355335 } ) ;
0 commit comments