From 6cd250a36da7547a734d7f033739d962c085f876 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Fri, 18 Jan 2019 18:25:02 +0100 Subject: [PATCH] client part of setMultiState --- .../motions/services/motion-multiselect.service.ts | 4 +--- .../motions/services/motion-repository.service.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) 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 *