@@ -18,11 +18,17 @@ import {
1818
1919import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service' ;
2020import { ComColDataService } from '../../../../core/data/comcol-data.service' ;
21+ import {
22+ DSPACE_OBJECT_DELETION_SCRIPT_NAME ,
23+ ScriptDataService ,
24+ } from '../../../../core/data/processes/script-data.service' ;
2125import { RemoteData } from '../../../../core/data/remote-data' ;
2226import { Collection } from '../../../../core/shared/collection.model' ;
2327import { Community } from '../../../../core/shared/community.model' ;
24- import { NoContent } from '../../../../core/shared/NoContent.model' ;
2528import { getFirstCompletedRemoteData } from '../../../../core/shared/operators' ;
29+ import { getProcessDetailRoute } from '../../../../process-page/process-page-routing.paths' ;
30+ import { Process } from '../../../../process-page/processes/process.model' ;
31+ import { ProcessParameter } from '../../../../process-page/processes/process-parameter.model' ;
2632import { NotificationsService } from '../../../notifications/notifications.service' ;
2733
2834/**
@@ -56,6 +62,7 @@ export class DeleteComColPageComponent<TDomain extends Community | Collection> i
5662 protected route : ActivatedRoute ,
5763 protected notifications : NotificationsService ,
5864 protected translate : TranslateService ,
65+ protected scriptDataService : ScriptDataService ,
5966 ) {
6067 }
6168
@@ -69,17 +76,19 @@ export class DeleteComColPageComponent<TDomain extends Community | Collection> i
6976 */
7077 onConfirm ( dso : TDomain ) {
7178 this . processing$ . next ( true ) ;
72- this . dsoDataService . delete ( dso . id )
79+ const parameterValues = [ Object . assign ( new ProcessParameter ( ) , { name : '-i' , value : dso . uuid } ) ] ;
80+ this . scriptDataService . invoke ( DSPACE_OBJECT_DELETION_SCRIPT_NAME , parameterValues , [ ] )
7381 . pipe ( getFirstCompletedRemoteData ( ) )
74- . subscribe ( ( response : RemoteData < NoContent > ) => {
75- if ( response . hasSucceeded ) {
82+ . subscribe ( ( rd : RemoteData < Process > ) => {
83+ if ( rd . hasSucceeded && rd . payload ) {
7684 const successMessage = this . translate . instant ( ( dso as any ) . type + '.delete.notification.success' ) ;
7785 this . notifications . success ( successMessage ) ;
86+ this . router . navigateByUrl ( getProcessDetailRoute ( rd . payload . processId ) ) ;
7887 } else {
7988 const errorMessage = this . translate . instant ( ( dso as any ) . type + '.delete.notification.fail' ) ;
8089 this . notifications . error ( errorMessage ) ;
90+ this . router . navigate ( [ '/' ] ) ;
8191 }
82- this . router . navigate ( [ '/' ] ) ;
8392 } ) ;
8493 }
8594
0 commit comments