Merge pull request #4136 from MaximilianKrambach/bulkState

client part of setMultiState
This commit is contained in:
Emanuel Schütze 2019-01-19 11:21:51 +01:00 committed by GitHub
commit b03538e564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -168,6 +168,20 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
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<void> {
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
*