diff --git a/client/src/app/site/motions/services/motion-multiselect.service.ts b/client/src/app/site/motions/services/motion-multiselect.service.ts index e2a4d19d4..78a9eeec8 100644 --- a/client/src/app/site/motions/services/motion-multiselect.service.ts +++ b/client/src/app/site/motions/services/motion-multiselect.service.ts @@ -95,9 +95,7 @@ export class MotionMultiselectService { })); const selectedChoice = await this.choiceService.open(title, choices); if (selectedChoice) { - for (const motion of motions) { - await this.repo.setState(motion, selectedChoice.items as number); - } + await this.repo.setMultiState(motions, selectedChoice.items as number); } } diff --git a/client/src/app/site/motions/services/motion-repository.service.ts b/client/src/app/site/motions/services/motion-repository.service.ts index 21d104a89..bff4f7d46 100644 --- a/client/src/app/site/motions/services/motion-repository.service.ts +++ b/client/src/app/site/motions/services/motion-repository.service.ts @@ -168,6 +168,20 @@ export class MotionRepositoryService extends BaseRepository await this.httpService.put(restPath, { state: stateId }); } + /** + * Set the state of motions in bulk + * + * @param viewMotion target motion + * @param stateId the number that indicates the state + */ + public async setMultiState(viewMotions: ViewMotion[], stateId: number): Promise { + const restPath = `/rest/motions/motion/manage_multiple_state/`; + const motionsIdMap: { id: number; state: number }[] = viewMotions.map(motion => { + return { id: motion.id, state: stateId }; + }); + await this.httpService.post(restPath, { motions: motionsIdMap }); + } + /** * Set the recommenders state of a motion *