diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts index cc04631af2..e3c4ac1d0d 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service.ts @@ -1,10 +1,13 @@ import { Injectable } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; import { ListOfSpeakers } from 'src/app/domain/models/list-of-speakers/list-of-speakers'; import { ListOfSpeakersRepositoryService } from 'src/app/gateways/repositories/list-of-speakers/list-of-speakers-repository.service'; import { BaseController } from 'src/app/site/base/base-controller'; import { BaseViewModel } from 'src/app/site/base/base-view-model'; +import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service'; import { ControllerServiceCollectorService } from 'src/app/site/services/controller-service-collector.service'; +import { ViewStructureLevel } from '../../../../participants/pages/structure-levels/view-models'; import { ViewListOfSpeakers, ViewSpeaker } from '../view-models'; /** @@ -15,6 +18,7 @@ import { ViewListOfSpeakers, ViewSpeaker } from '../view-models'; export interface SpeakingTimeStructureLevelObject { finishedSpeakers: ViewSpeaker[]; speakingTime: number; + name: string; } @Injectable({ @@ -23,7 +27,8 @@ export interface SpeakingTimeStructureLevelObject { export class ListOfSpeakersControllerService extends BaseController { public constructor( controllerServiceCollector: ControllerServiceCollectorService, - protected override repo: ListOfSpeakersRepositoryService + protected override repo: ListOfSpeakersRepositoryService, + private meetingSettings: MeetingSettingsService ) { super(controllerServiceCollector, ListOfSpeakers, repo); } @@ -58,48 +63,46 @@ export class ListOfSpeakersControllerService extends BaseController(); + const parliamentMode = this.meetingSettings.instant(`list_of_speakers_default_structure_level_time`); for (const los of this.getViewModelList()) { for (const speaker of los.finishedSpeakers) { - const nextEntry = this.getSpeakingTimeStructureLevelObject(speaker); - listSpeakingTimeStructureLevel = this.getSpeakingTimeStructureLevelList( - nextEntry, - listSpeakingTimeStructureLevel - ); + if (!!parliamentMode) { + const structureLevelOrNull = speaker.structure_level_list_of_speakers?.structure_level; + this.putIntoMapForAggregation(structureLevelOrNull, speaker, mapForAggregation); + } else { + for (const structureLevel of speaker.user?.structure_levels() ?? []) { + this.putIntoMapForAggregation(structureLevel, speaker, mapForAggregation); + } + if (!(speaker.user?.structure_levels() ?? []).length) { + this.putIntoMapForAggregation(null, speaker, mapForAggregation); + } + } } } - return listSpeakingTimeStructureLevel; + return Array.from(mapForAggregation.values()); } - /** - * Helper-function to create a `SpeakingTimeStructureLevelObject` by a given speaker. - * - * @param speaker, with whom structure-level and speaking-time is calculated. - * - * @returns The created `SpeakingTimeStructureLevelObject`. - */ - private getSpeakingTimeStructureLevelObject(speaker: ViewSpeaker): SpeakingTimeStructureLevelObject { - return { - finishedSpeakers: [speaker], - speakingTime: this.getSpeakingTimeAsNumber(speaker) - }; - } - - /** - * Helper-function to update entries in a given list, if already existing, or create entries otherwise. - * - * @param object A `SpeakingTimeStructureLevelObject`, that contains information about speaking-time - * and structure-level. - * @param list A list, at which speaking-time, structure-level and finished_speakers are set. - * - * @returns The updated map. - */ - private getSpeakingTimeStructureLevelList( - object: SpeakingTimeStructureLevelObject, - list: SpeakingTimeStructureLevelObject[] - ): SpeakingTimeStructureLevelObject[] { - list.push(object); - return list; + private putIntoMapForAggregation( + structureLevel: ViewStructureLevel | null, + speaker: ViewSpeaker, + mapForAggregation: Map + ): void { + let structureLevelId = -1; + if (!!structureLevel) { + structureLevelId = structureLevel.id; + } + if (mapForAggregation.has(structureLevelId)) { + const entry = mapForAggregation.get(structureLevelId); + entry.finishedSpeakers.push(speaker); + entry.speakingTime += this.getSpeakingTimeAsNumber(speaker); + } else { + mapForAggregation.set(structureLevelId, { + finishedSpeakers: [speaker], + speakingTime: this.getSpeakingTimeAsNumber(speaker), + name: structureLevelId === -1 ? `Without Structure Level` : structureLevel.name + }); + } } /** diff --git a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts index 008f029a5f..92dcde0fa8 100644 --- a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts +++ b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/meeting-info/meeting-info.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { filter, firstValueFrom, map } from 'rxjs'; +import { FULL_FIELDSET } from 'src/app/domain/fieldsets/misc'; import { OrganizationRepositoryService } from 'src/app/gateways/repositories/organization-repository.service'; import { BaseMeetingComponent } from 'src/app/site/pages/meetings/base/base-meeting.component'; import { ViewMeeting } from 'src/app/site/pages/meetings/view-models/view-meeting'; @@ -49,6 +50,16 @@ export class MeetingInfoComponent extends BaseMeetingComponent implements OnInit } ] }, + { + idField: `speaker_ids`, + fieldset: [`id`, `begin_time`, `end_time`], + follow: [ + { + idField: `structure_level_list_of_speakers_id`, + fieldset: FULL_FIELDSET + } + ] + }, { idField: `list_of_speakers_ids`, fieldset: [], @@ -56,7 +67,28 @@ export class MeetingInfoComponent extends BaseMeetingComponent implements OnInit { idField: `speaker_ids`, fieldset: [`begin_time`, `end_time`, `point_of_order`], - follow: [`meeting_user_id`] + follow: [ + { + idField: `meeting_user_id`, + fieldset: [`user_id`], + follow: [ + { + idField: `structure_level_ids`, + fieldset: [`name`] + } + ] + }, + { + idField: `structure_level_list_of_speakers_id`, + fieldset: FULL_FIELDSET, + follow: [ + { + idField: `structure_level_id`, + fieldset: [`name`] + } + ] + } + ] } ] } diff --git a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html index 3a0d8d884e..cb08140136 100644 --- a/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html +++ b/client/src/app/site/pages/meetings/pages/home/pages/meeting-info/components/user-statistics/user-statistics.component.html @@ -37,7 +37,7 @@
{{ 'Structure level' | translate }}
- {{ object.structureLevel | translate }} + {{ object.name }}
{{ 'Duration of requests to speak' | translate }}