client part of setMultiState

This commit is contained in:
Maximilian Krambach 2019-01-18 18:25:02 +01:00
parent cb3e6c4e47
commit 6cd250a36d
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
*