Commit 07c1d58f authored by Florent Poittevin's avatar Florent Poittevin
Browse files

refactor: use delete list action feature for deposit authors

parent 05f2f498
import {adminLicenseActionNameSpace} from "@app/features/admin/stores/license/admin-license.action";
import {Licenses} from "@app/generated-api";
import {ApiResourceNameEnum} from "@app/shared/enums/api-resource-name.enum";
import {AdminResourceApiEnum} from "@app/shared/enums/api.enum";
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {RoutesEnum} from "@app/shared/enums/routes.enum";
import {Actions, State, Store} from "@ngxs/store";
import {
ApiService,
defaultResourceStateInitValue, NotificationService, ResourceApiEnum, ResourceNameSpace,
defaultResourceStateInitValue,
NotificationService,
ResourceApiEnum,
ResourceNameSpace,
ResourceState,
ResourceStateModel
ResourceStateModel,
} from "solidify-frontend";
import {environment} from "../../../../../environments/environment";
......@@ -38,10 +40,6 @@ export class AdminLicenseState extends ResourceState<Licenses> {
return adminLicenseActionNameSpace;
}
defineSubResource(): ApiResourceNameEnum[] {
return [];
}
defineUrlResource(): ResourceApiEnum {
return AdminResourceApiEnum.licenses;
}
......
......@@ -68,27 +68,27 @@ export namespace AdminOrgUnitPreservationPolicyAction {
}
@TypeDefaultAction(state)
export class Delete extends Relation2TiersAction.Delete {
export class DeleteList extends Relation2TiersAction.DeleteList {
}
@TypeDefaultAction(state)
export class DeleteSuccess extends Relation2TiersAction.DeleteSuccess {
export class DeleteListSuccess extends Relation2TiersAction.DeleteListSuccess {
}
@TypeDefaultAction(state)
export class DeleteFail extends Relation2TiersAction.DeleteFail {
export class DeleteListFail extends Relation2TiersAction.DeleteListFail {
}
@TypeDefaultAction(state)
export class DeleteById extends Relation2TiersAction.DeleteById {
export class Delete extends Relation2TiersAction.Delete {
}
@TypeDefaultAction(state)
export class DeleteByIdSuccess extends Relation2TiersAction.DeleteByIdSuccess {
export class DeleteSuccess extends Relation2TiersAction.DeleteSuccess {
}
@TypeDefaultAction(state)
export class DeleteByIdFail extends Relation2TiersAction.DeleteByIdFail {
export class DeleteFail extends Relation2TiersAction.DeleteFail {
}
}
......
......@@ -68,27 +68,27 @@ export namespace AdminOrgUnitSubmissionPolicyAction {
}
@TypeDefaultAction(state)
export class Delete extends Relation2TiersAction.Delete {
export class DeleteList extends Relation2TiersAction.DeleteList {
}
@TypeDefaultAction(state)
export class DeleteSuccess extends Relation2TiersAction.DeleteSuccess {
export class DeleteListSuccess extends Relation2TiersAction.DeleteListSuccess {
}
@TypeDefaultAction(state)
export class DeleteFail extends Relation2TiersAction.DeleteFail {
export class DeleteListFail extends Relation2TiersAction.DeleteListFail {
}
@TypeDefaultAction(state)
export class DeleteById extends Relation2TiersAction.DeleteById {
export class Delete extends Relation2TiersAction.Delete {
}
@TypeDefaultAction(state)
export class DeleteByIdSuccess extends Relation2TiersAction.DeleteByIdSuccess {
export class DeleteSuccess extends Relation2TiersAction.DeleteSuccess {
}
@TypeDefaultAction(state)
export class DeleteByIdFail extends Relation2TiersAction.DeleteByIdFail {
export class DeleteFail extends Relation2TiersAction.DeleteFail {
}
}
......
......@@ -135,7 +135,7 @@ export class DepositState extends ResourceState<DepositsExtended> {
tap(model => {
const oldAuthors = [];
const newAuthors = action.modelFormControlEvent.model[LocalModelAttributeEnum.authors];
const updateSubResourceAction = AssociationRemoteActionHelper.updateSubResource(depositPersonActionNameSpace, model.resId, oldAuthors, newAuthors);
const updateSubResourceAction = AssociationRemoteActionHelper.update(depositPersonActionNameSpace, model.resId, oldAuthors, newAuthors);
StoreUtil.updateSubResource(ChangeModeEnum.create, this.actions$, ctx, updateSubResourceAction, depositActionNameSpace, depositPersonActionNameSpace);
}),
);
......@@ -149,7 +149,7 @@ export class DepositState extends ResourceState<DepositsExtended> {
tap(model => {
const oldAuthors = _.map(ctx.getState()[LocalStateEnum.deposit_person].selected, LocalModelAttributeEnum.resId);
const newAuthors = action.modelFormControlEvent.model[LocalModelAttributeEnum.authors];
const updateSubResourceAction = AssociationRemoteActionHelper.updateSubResource(depositPersonActionNameSpace, action.modelFormControlEvent.model.resId, oldAuthors, newAuthors);
const updateSubResourceAction = AssociationRemoteActionHelper.update(depositPersonActionNameSpace, action.modelFormControlEvent.model.resId, oldAuthors, newAuthors);
StoreUtil.updateSubResource(ChangeModeEnum.update, this.actions$, ctx, updateSubResourceAction, depositActionNameSpace, depositPersonActionNameSpace);
}),
);
......@@ -240,7 +240,7 @@ export class DepositState extends ResourceState<DepositsExtended> {
@Action(DepositAction.SendDataFileSuccess)
sendDataFileSuccess(ctx: StateContext<DepositStateModel>, action: DepositAction.SendDataFileSuccess): void {
this.notificationService.showSuccess(TRANSLATE("deposit.file.upload.notification.success"), true);
ctx.dispatch(CompositionActionHelper.getAllSubResource(depositDataFileActionNameSpace, action.parentId));
ctx.dispatch(CompositionActionHelper.getAll(depositDataFileActionNameSpace, action.parentId));
const uploadFileStatusCopied = ObjectUtil.clone(action.uploadFileStatus);
DataFileUploadHelper.updateCompletedUploadFileStatus(ctx, uploadFileStatusCopied, action.depositDataFile);
}
......
......@@ -65,6 +65,18 @@ export namespace DepositPersonAction {
@TypeDefaultAction(state)
export class DeleteFail extends AssociationRemoteAction.DeleteFail {
}
@TypeDefaultAction(state)
export class DeleteList extends AssociationRemoteAction.DeleteList {
}
@TypeDefaultAction(state)
export class DeleteListSuccess extends AssociationRemoteAction.DeleteListSuccess {
}
@TypeDefaultAction(state)
export class DeleteListFail extends AssociationRemoteAction.DeleteListFail {
}
}
export const depositPersonActionNameSpace: AssociationRemoteNameSpace = DepositPersonAction;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment