Fixes submitters
This commit is contained in:
parent
c5912f8515
commit
d932d6e907
@ -39,7 +39,7 @@ export class AssignmentRepositoryService extends BaseRepository<ViewAssignment,
|
||||
}
|
||||
|
||||
public createViewModel(assignment: Assignment): ViewAssignment {
|
||||
const relatedUser = this.viewModelStoreService.getMany(ViewUser, assignment.candidateIds);
|
||||
const relatedUser = this.viewModelStoreService.getMany(ViewUser, assignment.candidates_id);
|
||||
const agendaItem = this.viewModelStoreService.get(ViewItem, assignment.agenda_item_id);
|
||||
const tags = this.viewModelStoreService.getMany(ViewTag, assignment.tags_id);
|
||||
|
||||
|
@ -70,6 +70,7 @@ export abstract class BaseRepository<V extends BaseViewModel, M extends BaseMode
|
||||
this.DS.getAll(this.baseModelCtor).forEach((model: M) => {
|
||||
this.viewModelStore[model.id] = this.createViewModel(model);
|
||||
});
|
||||
|
||||
// Update the list and then all models on their own
|
||||
this.updateViewModelListObservable();
|
||||
this.DS.getAll(this.baseModelCtor).forEach((model: M) => {
|
||||
|
@ -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.submitterIds);
|
||||
const submitters = this.viewModelStoreService.getMany(ViewUser, motion.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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Speaker, SpeakerState } from './speaker';
|
||||
import { Speaker } from './speaker';
|
||||
import { BaseModel } from '../base/base-model';
|
||||
|
||||
/**
|
||||
@ -55,35 +55,4 @@ export class Item extends BaseModel<Item> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of waiting speakers
|
||||
*/
|
||||
public get waitingSpeakerAmount(): number {
|
||||
return this.speakers.filter(speaker => speaker.state === SpeakerState.WAITING).length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string representation of the item type
|
||||
* @returns The visibility for this item, as defined in {@link itemVisibilityChoices}
|
||||
*/
|
||||
public get verboseType(): string {
|
||||
if (!this.type) {
|
||||
return '';
|
||||
}
|
||||
const type = itemVisibilityChoices.find(choice => choice.key === this.type);
|
||||
return type ? type.name : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a shortened string for CSV export
|
||||
* @returns empty string if it is a public item, 'internal' or 'hidden' otherwise
|
||||
*/
|
||||
public get verboseCsvType(): string {
|
||||
if (!this.type) {
|
||||
return '';
|
||||
}
|
||||
const type = itemVisibilityChoices.find(choice => choice.key === this.type);
|
||||
return type ? type.csvName : '';
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export class Assignment extends BaseModel<Assignment> {
|
||||
super(Assignment.COLLECTIONSTRING, input);
|
||||
}
|
||||
|
||||
public get candidateIds(): number[] {
|
||||
public get candidates_id(): number[] {
|
||||
return this.assignment_related_users
|
||||
.sort((a: AssignmentUser, b: AssignmentUser) => {
|
||||
return a.weight - b.weight;
|
||||
@ -42,16 +42,14 @@ export class Assignment extends BaseModel<Assignment> {
|
||||
|
||||
this.assignment_related_users = [];
|
||||
if (input.assignment_related_users instanceof Array) {
|
||||
input.assignment_related_users.forEach(assignmentUserData => {
|
||||
this.assignment_related_users.push(new AssignmentUser(assignmentUserData));
|
||||
});
|
||||
this.assignment_related_users = input.assignment_related_users.map(
|
||||
assignmentUserData => new AssignmentUser(assignmentUserData)
|
||||
);
|
||||
}
|
||||
|
||||
this.polls = [];
|
||||
if (input.polls instanceof Array) {
|
||||
input.polls.forEach(pollData => {
|
||||
this.polls.push(new Poll(pollData));
|
||||
});
|
||||
this.polls = input.polls.map(pollData => new Poll(pollData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,7 @@ export class Poll extends Deserializer {
|
||||
|
||||
this.options = [];
|
||||
if (input.options instanceof Array) {
|
||||
input.options.forEach(pollOptionData => {
|
||||
this.options.push(new PollOption(pollOptionData));
|
||||
});
|
||||
this.options = input.options.map(pollOptionData => new PollOption(pollOptionData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ export class Motion extends BaseModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the motion submitters userIDs
|
||||
* returns the motion submitters user ids
|
||||
*/
|
||||
public get submitterIds(): number[] {
|
||||
public get submitters_id(): number[] {
|
||||
return this.submitters
|
||||
.sort((a: MotionSubmitter, b: MotionSubmitter) => {
|
||||
return a.weight - b.weight;
|
||||
|
@ -29,20 +29,14 @@ export class Workflow extends BaseModel<Workflow> {
|
||||
id = obj;
|
||||
}
|
||||
|
||||
return this.states.some(state => {
|
||||
if (state.id === id) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return this.states.some(state => state.id === id);
|
||||
}
|
||||
|
||||
public deserialize(input: any): void {
|
||||
Object.assign(this, input);
|
||||
|
||||
if (input.states instanceof Array) {
|
||||
this.states = [];
|
||||
input.states.forEach(workflowStateData => {
|
||||
this.states.push(new WorkflowState(workflowStateData));
|
||||
});
|
||||
this.states = input.states.map(workflowStateData => new WorkflowState(workflowStateData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,4 @@ export class User extends BaseModel<User> {
|
||||
public constructor(input?: any) {
|
||||
super(User.COLLECTIONSTRING, input);
|
||||
}
|
||||
|
||||
public containsGroupId(id: number): boolean {
|
||||
return this.groups_id.some(groupId => groupId === id);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
<mat-form-field *ngIf="projectors && projectors.length > 0">
|
||||
<mat-select [value]="projectors[0]" (selectionChange)="onSelectProjector($event)">
|
||||
<mat-option *ngFor="let projector of projectors" [value]="projector">
|
||||
{{ projector.name }}
|
||||
{{ projector.name | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
@ -2,6 +2,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormControl } from '@angular/forms';
|
||||
import { MatSnackBar, MatSelectChange } from '@angular/material';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
||||
@ -13,7 +14,6 @@ import { OperatorService } from 'app/core/core-services/operator.service';
|
||||
import { ProjectorRepositoryService } from 'app/core/repositories/projector/projector-repository.service';
|
||||
import { PromptService } from 'app/core/ui-services/prompt.service';
|
||||
import { SpeakerState } from 'app/shared/models/agenda/speaker';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { ViewItem } from '../../models/view-item';
|
||||
import { ViewSpeaker } from '../../models/view-speaker';
|
||||
import { ViewProjector } from 'app/site/projector/models/view-projector';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { BaseViewModel } from '../../base/base-view-model';
|
||||
import { Item } from 'app/shared/models/agenda/item';
|
||||
import { Speaker } from 'app/shared/models/agenda/speaker';
|
||||
import { Item, itemVisibilityChoices } from 'app/shared/models/agenda/item';
|
||||
import { Speaker, SpeakerState } from 'app/shared/models/agenda/speaker';
|
||||
import { BaseAgendaViewModel, isAgendaBaseModel } from 'app/site/base/base-agenda-view-model';
|
||||
|
||||
export class ViewItem extends BaseViewModel {
|
||||
@ -42,8 +42,11 @@ export class ViewItem extends BaseViewModel {
|
||||
return this.item.duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of waiting speakers
|
||||
*/
|
||||
public get waitingSpeakerAmount(): number {
|
||||
return this.item.waitingSpeakerAmount;
|
||||
return this.item.speakers.filter(speaker => speaker.state === SpeakerState.WAITING).length;
|
||||
}
|
||||
|
||||
public get type(): number {
|
||||
@ -58,12 +61,28 @@ export class ViewItem extends BaseViewModel {
|
||||
return this.item.comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string representation of the item type
|
||||
* @returns The visibility for this item, as defined in {@link itemVisibilityChoices}
|
||||
*/
|
||||
public get verboseType(): string {
|
||||
return this.item.verboseType;
|
||||
if (!this.type) {
|
||||
return '';
|
||||
}
|
||||
const type = itemVisibilityChoices.find(choice => choice.key === this.type);
|
||||
return type ? type.name : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a shortened string for CSV export
|
||||
* @returns empty string if it is a public item, 'internal' or 'hidden' otherwise
|
||||
*/
|
||||
public get verboseCsvType(): string {
|
||||
return this.item.verboseCsvType;
|
||||
if (!this.type) {
|
||||
return '';
|
||||
}
|
||||
const type = itemVisibilityChoices.find(choice => choice.key === this.type);
|
||||
return type ? type.csvName : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -948,8 +948,8 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
|
||||
public updateWorkflowIdForCreateForm(): void {
|
||||
const isStatuteAmendment = !!this.contentForm.get('statute_amendment').value;
|
||||
const configKey = isStatuteAmendment ? 'motions_statute_amendments_workflow' : 'motions_workflow';
|
||||
const workflowID = this.configService.instant<string>(configKey);
|
||||
this.contentForm.patchValue({ workflow_id: +workflowID });
|
||||
const workflowId = this.configService.instant<string>(configKey);
|
||||
this.contentForm.patchValue({ workflow_id: +workflowId });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +129,7 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
||||
}
|
||||
|
||||
public get submitters_id(): number[] {
|
||||
return this.motion.submitterIds;
|
||||
return this.motion.submitters_id;
|
||||
}
|
||||
|
||||
public get supporters(): ViewUser[] {
|
||||
@ -482,7 +482,7 @@ export class ViewMotion extends BaseAgendaViewModel implements Searchable {
|
||||
*/
|
||||
public updateUser(update: ViewUser): void {
|
||||
if (this.motion.submitters && this.motion.submitters.find(user => user.user_id === update.id)) {
|
||||
const userIndex = this.submitters.findIndex(user => user.id === update.id);
|
||||
const userIndex = this.motion.submitters.findIndex(submitter => submitter.user_id === update.id);
|
||||
this.submitters[userIndex] = update;
|
||||
}
|
||||
if (this.motion.supporters_id && this.motion.supporters_id.includes(update.id)) {
|
||||
|
@ -533,7 +533,7 @@ export class MotionPdfService {
|
||||
const callListRows: object[] = [];
|
||||
let currentTitle = '';
|
||||
|
||||
motions.map(motion => {
|
||||
motions.forEach(motion => {
|
||||
if (!motion.sort_parent_id) {
|
||||
const heading = motion.tags ? motion.tags.map(tag => tag.name).join(', ') : '';
|
||||
if (heading !== currentTitle) {
|
||||
|
Loading…
Reference in New Issue
Block a user