Merge pull request #4343 from FinnStutzenstein/fixSubmitterIds

Fixed submitter ids name clash
This commit is contained in:
Emanuel Schütze 2019-02-14 15:27:23 +01:00 committed by GitHub
commit 2df284c82e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View File

@ -102,7 +102,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
*/
protected createViewModel(motion: Motion): ViewMotion {
const category = this.viewModelStoreService.get(ViewCategory, motion.category_id);
const submitters = this.viewModelStoreService.getMany(ViewUser, motion.submitters_id);
const submitters = this.viewModelStoreService.getMany(ViewUser, motion.sorted_submitters_id);
const supporters = this.viewModelStoreService.getMany(ViewUser, motion.supporters_id);
const workflow = this.viewModelStoreService.get(ViewWorkflow, motion.workflow_id);
const item = this.viewModelStoreService.get(ViewItem, motion.agenda_item_id);

View File

@ -50,7 +50,7 @@ export class Motion extends BaseModel {
/**
* returns the motion submitters user ids
*/
public get submitters_id(): number[] {
public get sorted_submitters_id(): number[] {
return this.submitters
.sort((a: MotionSubmitter, b: MotionSubmitter) => {
return a.weight - b.weight;

View File

@ -25,7 +25,7 @@ export class ViewCreateMotion extends ViewMotion {
}
public get submitters_id(): number[] {
return this.motion ? this.motion.submitters_id : null;
return this.motion ? this.motion.sorted_submitters_id : null;
}
public set submitters(users: ViewUser[]) {

View File

@ -128,8 +128,8 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
return this._submitters;
}
public get submitters_id(): number[] {
return this.motion.submitters_id;
public get sorted_submitters_id(): number[] {
return this.motion.sorted_submitters_id;
}
public get supporters(): ViewUser[] {

View File

@ -167,7 +167,7 @@ export class MotionMultiselectService {
const selectedChoice = await this.choiceService.open(title, this.userRepo.getViewModelList(), true, choices);
if (selectedChoice && selectedChoice.action === choices[0]) {
const requestData = motions.map(motion => {
let submitterIds = [...motion.submitters_id, ...(selectedChoice.items as number[])];
let submitterIds = [...motion.sorted_submitters_id, ...(selectedChoice.items as number[])];
submitterIds = submitterIds.filter((id, index, self) => self.indexOf(id) === index); // remove duplicates
return {
id: motion.id,
@ -178,7 +178,7 @@ export class MotionMultiselectService {
} else if (selectedChoice && selectedChoice.action === choices[1]) {
const requestData = motions.map(motion => {
const submitterIdsToRemove = selectedChoice.items as number[];
const submitterIds = motion.submitters_id.filter(id => !submitterIdsToRemove.includes(id));
const submitterIds = motion.sorted_submitters_id.filter(id => !submitterIdsToRemove.includes(id));
return {
id: motion.id,
submitters: submitterIds