From f0e6afb5333813f07bc513f7e09891a0f5a20e15 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 14 Feb 2019 13:45:52 +0100 Subject: [PATCH] Fixed submitter ids name clash --- .../core/repositories/motions/motion-repository.service.ts | 2 +- client/src/app/shared/models/motions/motion.ts | 2 +- client/src/app/site/motions/models/view-create-motion.ts | 2 +- client/src/app/site/motions/models/view-motion.ts | 4 ++-- .../app/site/motions/services/motion-multiselect.service.ts | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/src/app/core/repositories/motions/motion-repository.service.ts b/client/src/app/core/repositories/motions/motion-repository.service.ts index 233409a94..cb6458950 100644 --- a/client/src/app/core/repositories/motions/motion-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-repository.service.ts @@ -102,7 +102,7 @@ export class MotionRepositoryService extends BaseRepository */ 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); diff --git a/client/src/app/shared/models/motions/motion.ts b/client/src/app/shared/models/motions/motion.ts index 01645192a..9ea666dfb 100644 --- a/client/src/app/shared/models/motions/motion.ts +++ b/client/src/app/shared/models/motions/motion.ts @@ -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; diff --git a/client/src/app/site/motions/models/view-create-motion.ts b/client/src/app/site/motions/models/view-create-motion.ts index 293bb40dc..ef17d1eb2 100644 --- a/client/src/app/site/motions/models/view-create-motion.ts +++ b/client/src/app/site/motions/models/view-create-motion.ts @@ -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[]) { diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index 76ec1f50d..4c9c8480a 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -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[] { 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 e9e335e3e..58e603ea7 100644 --- a/client/src/app/site/motions/services/motion-multiselect.service.ts +++ b/client/src/app/site/motions/services/motion-multiselect.service.ts @@ -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