Merge pull request #4343 from FinnStutzenstein/fixSubmitterIds
Fixed submitter ids name clash
This commit is contained in:
commit
2df284c82e
@ -102,7 +102,7 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
*/
|
*/
|
||||||
protected createViewModel(motion: Motion): ViewMotion {
|
protected createViewModel(motion: Motion): ViewMotion {
|
||||||
const category = this.viewModelStoreService.get(ViewCategory, motion.category_id);
|
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 supporters = this.viewModelStoreService.getMany(ViewUser, motion.supporters_id);
|
||||||
const workflow = this.viewModelStoreService.get(ViewWorkflow, motion.workflow_id);
|
const workflow = this.viewModelStoreService.get(ViewWorkflow, motion.workflow_id);
|
||||||
const item = this.viewModelStoreService.get(ViewItem, motion.agenda_item_id);
|
const item = this.viewModelStoreService.get(ViewItem, motion.agenda_item_id);
|
||||||
|
@ -50,7 +50,7 @@ export class Motion extends BaseModel {
|
|||||||
/**
|
/**
|
||||||
* returns the motion submitters user ids
|
* returns the motion submitters user ids
|
||||||
*/
|
*/
|
||||||
public get submitters_id(): number[] {
|
public get sorted_submitters_id(): number[] {
|
||||||
return this.submitters
|
return this.submitters
|
||||||
.sort((a: MotionSubmitter, b: MotionSubmitter) => {
|
.sort((a: MotionSubmitter, b: MotionSubmitter) => {
|
||||||
return a.weight - b.weight;
|
return a.weight - b.weight;
|
||||||
|
@ -25,7 +25,7 @@ export class ViewCreateMotion extends ViewMotion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get submitters_id(): number[] {
|
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[]) {
|
public set submitters(users: ViewUser[]) {
|
||||||
|
@ -128,8 +128,8 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
|||||||
return this._submitters;
|
return this._submitters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get submitters_id(): number[] {
|
public get sorted_submitters_id(): number[] {
|
||||||
return this.motion.submitters_id;
|
return this.motion.sorted_submitters_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get supporters(): ViewUser[] {
|
public get supporters(): ViewUser[] {
|
||||||
|
@ -167,7 +167,7 @@ export class MotionMultiselectService {
|
|||||||
const selectedChoice = await this.choiceService.open(title, this.userRepo.getViewModelList(), true, choices);
|
const selectedChoice = await this.choiceService.open(title, this.userRepo.getViewModelList(), true, choices);
|
||||||
if (selectedChoice && selectedChoice.action === choices[0]) {
|
if (selectedChoice && selectedChoice.action === choices[0]) {
|
||||||
const requestData = motions.map(motion => {
|
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
|
submitterIds = submitterIds.filter((id, index, self) => self.indexOf(id) === index); // remove duplicates
|
||||||
return {
|
return {
|
||||||
id: motion.id,
|
id: motion.id,
|
||||||
@ -178,7 +178,7 @@ export class MotionMultiselectService {
|
|||||||
} else if (selectedChoice && selectedChoice.action === choices[1]) {
|
} else if (selectedChoice && selectedChoice.action === choices[1]) {
|
||||||
const requestData = motions.map(motion => {
|
const requestData = motions.map(motion => {
|
||||||
const submitterIdsToRemove = selectedChoice.items as number[];
|
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 {
|
return {
|
||||||
id: motion.id,
|
id: motion.id,
|
||||||
submitters: submitterIds
|
submitters: submitterIds
|
||||||
|
Loading…
Reference in New Issue
Block a user