diff --git a/src/app/features/deposit/components/routables/deposit-detail-edit/deposit-detail-edit.routable.ts b/src/app/features/deposit/components/routables/deposit-detail-edit/deposit-detail-edit.routable.ts index caeaa87f1665ee308442a4a87a0cb4fbf6ee4264..21b0d2028ecc4acf96dbcad35f56b5700ac9873b 100644 --- a/src/app/features/deposit/components/routables/deposit-detail-edit/deposit-detail-edit.routable.ts +++ b/src/app/features/deposit/components/routables/deposit-detail-edit/deposit-detail-edit.routable.ts @@ -60,6 +60,7 @@ import { take, } from "rxjs/operators"; import { + isFalse, isNullOrUndefined, isTrue, TRANSLATE, @@ -148,6 +149,13 @@ export class DepositDetailEditRoutable extends SharedAbstractDetailEditRoutable< } private _computeCurrentUserRight(): void { + this.subscribe(this.currentObs.pipe( + filter(deposit => !isNullOrUndefined(deposit) && deposit.resId === this._resId && isFalse(this.isEdit) && deposit.status === Deposit.StatusEnum.INPROGRESS), + tap(deposit => { + this.canReserveDoiAction = isNullOrUndefined(deposit.doi); + }), + )); + this.subscribe(this.currentObs.pipe( distinctUntilChanged(), filter(deposit => !isNullOrUndefined(deposit) && deposit.resId === this._resId), @@ -157,9 +165,6 @@ export class DepositDetailEditRoutable extends SharedAbstractDetailEditRoutable< const canDoValidatorActions = this._securityService.depositInValidationStep(deposit); const canDoAlterationActions = this._securityService.depositInEditionStep(deposit); - if (deposit.status === Deposit.StatusEnum.INPROGRESS && isNullOrUndefined(deposit.doi)) { - this.canReserveDoiAction = true; - } this.subscribe(combineLatest(this.numberFilesObs, this.numberFilesInErrorObs).pipe( distinctUntilChanged(), filter(([numberFiles, numberFilesInError]) => !isNullOrUndefined(numberFiles) && !isNullOrUndefined(numberFilesInError)), @@ -305,5 +310,4 @@ export class DepositDetailEditRoutable extends SharedAbstractDetailEditRoutable< ).subscribe(); } - } diff --git a/src/app/features/deposit/stores/deposit.state.ts b/src/app/features/deposit/stores/deposit.state.ts index cf1743a8956b1081523e5f603d25bc477938ab26..8fea19f3af483741a40175f42b802976f34a7503 100644 --- a/src/app/features/deposit/stores/deposit.state.ts +++ b/src/app/features/deposit/stores/deposit.state.ts @@ -457,6 +457,9 @@ export class DepositState extends ResourceState<DepositExtended> { @Action(DepositAction.ReserveDOI) reserveDOI(ctx: StateContext<DepositStateModel>, action: DepositAction.ReserveDOI): Observable<DepositExtended> { + ctx.patchState({ + isLoadingCounter: ctx.getState().isLoadingCounter + 1, + }); return this.apiService.patchByIdWithCustomUrl(this._urlResource + urlSeparator + action.deposit.resId + urlSeparator + ApiActionEnum.RESERVE_DOI) .pipe( tap(deposit => ctx.dispatch(new DepositAction.ReserveDOISuccess(deposit))), @@ -469,12 +472,21 @@ export class DepositState extends ResourceState<DepositExtended> { @Action(DepositAction.ReserveDOISuccess) reserveDOISuccess(ctx: StateContext<DepositStateModel>, action: DepositAction.ReserveDOISuccess): void { - ctx.dispatch(new Navigate([RoutesEnum.deposit])); + ctx.patchState({ + current: undefined, + }); + ctx.patchState({ + current: action.deposit, + isLoadingCounter: ctx.getState().isLoadingCounter - 1, + }); this.notificationService.showSuccess(TRANSLATE("deposit.notification.reserveDOI.success"), true); } @Action(DepositAction.ReserveDOIFail) reserveDOIFail(ctx: StateContext<DepositStateModel>, action: DepositAction.ReserveDOIFail): void { + ctx.patchState({ + isLoadingCounter: ctx.getState().isLoadingCounter - 1, + }); this.notificationService.showError(TRANSLATE("deposit.notification.reserveDOI.fail"), true); } } diff --git a/src/app/shared/components/routables/shared-abstract-detail-edit/shared-abstract-detail-edit.routable.ts b/src/app/shared/components/routables/shared-abstract-detail-edit/shared-abstract-detail-edit.routable.ts index fc88c4b915db46fc37b026389d4bed26e951497b..5b40d95d48e4675e48a168a2b1de9f2c2cd01c08 100644 --- a/src/app/shared/components/routables/shared-abstract-detail-edit/shared-abstract-detail-edit.routable.ts +++ b/src/app/shared/components/routables/shared-abstract-detail-edit/shared-abstract-detail-edit.routable.ts @@ -148,7 +148,7 @@ export abstract class SharedAbstractDetailEditRoutable<TResourceModel, UResource const currentUrl = this._store.selectSnapshot((s: LocalStateModel) => s.router.state.url); this._store.dispatch(new Navigate([StoreRouteLocalUtil.getDetailRoute(this.state), this._resId])).subscribe((state: LocalStateModel) => { if (state.router.state.url !== currentUrl) { - this.formPresentational.resetFormToInitialValue(); + // this.formPresentational.resetFormToInitialValue(); // TODO : Fix don't need to get by id model from backend but fix resetFormToInitialValue with component user role org unit // TODO : Problem currently if redirect to detail page via breadcrumb in case of Deposit this.retrieveCurrentModelWithUrl(); diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 2aa7aa67ead264be7cc25d0ce61ba5d08849a644..6d0978fa80198c7bc70c5703a15b165885bd86bf 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -830,7 +830,7 @@ }, "reserveDOI": { "fail": "There was an error when reserving DOI of the deposit", - "success": "DOI reserved" + "success": "DOI reserved with success" } }, "organizationUnit": "Organizational Unit", @@ -863,8 +863,8 @@ "reject": "Reject", "submissionPolicy": "Submission Policy", "submit": "Submit", - "reserveDOI": "Reserve DOI", "doi": "DOI", + "reserveDOI": "Reserve DOI", "tab": { "datafiles": "Files", "details": "Metadata" diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 1d3a737656b98038da7b46b6ec7e86268f76d30f..6d0978fa80198c7bc70c5703a15b165885bd86bf 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -830,7 +830,7 @@ }, "reserveDOI": { "fail": "There was an error when reserving DOI of the deposit", - "success": "DOI reserved" + "success": "DOI reserved with success" } }, "organizationUnit": "Organizational Unit", diff --git a/src/assets/i18n/fr.json b/src/assets/i18n/fr.json index 14fa3b41c7aa7a318e593a6cc9c87b109f71e44c..565a680338cfd854f0668f261d28a4fd7461f8d6 100644 --- a/src/assets/i18n/fr.json +++ b/src/assets/i18n/fr.json @@ -829,8 +829,8 @@ "success": "Dépôt soumis" }, "reserveDOI": { - "fail": "Il y a eu une erreur lors de la réservation du DOI du dépôt", - "success": "DOI réserve" + "fail": "Il y a eu une erreur lors de la réservation du DOI", + "success": "DOI réservé avec succès" } }, "organizationUnit": "Unité organisationnelle", @@ -897,7 +897,6 @@ "publicationDate": "Date à partir de laquelle le dataset (dépôt) doit être disponible en ligne de manière publique", "submissionPolicy": "Montre les options qui ont été choisies lors de la création de votre espace de préservation (ou unité organisationnelle).\n\nVoir la documentation pour plus d'informations", "doi": "Si vous souhaitez attribuer un DOI avant la fin du processus d'archivage,\n\nvous pouvez l'attribuer avec le bouton 'Réserver un DOI" - } }, "error": {