Skip to content

Commit

Permalink
Prevent certain speech state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister committed Mar 6, 2024
1 parent cb8f807 commit 70a37e6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 30 deletions.
2 changes: 2 additions & 0 deletions client/src/app/domain/models/speakers/speech-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export enum SpeechState {
INTERPOSED_QUESTION = `interposed_question`,
INTERVENTION = `intervention`
}

export const SPECIAL_SPEECH_STATES = [SpeechState.INTERPOSED_QUESTION, SpeechState.INTERVENTION];
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class SpeakerRepositoryService extends BaseMeetingRelatedRepository<ViewS
id: viewModel.id,
speech_state
};
if (speech_state !== null) {
payload.point_of_order = false;
}
return this.sendActionToBackend(SpeakerAction.UPDATE, payload);
}

Expand Down Expand Up @@ -143,6 +146,9 @@ export class SpeakerRepositoryService extends BaseMeetingRelatedRepository<ViewS
id: speaker.id,
...data
};
if (data.point_of_order) {
payload.speech_state = null;
}
return this.sendActionToBackend(SpeakerAction.UPDATE, payload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@
<mat-menu #manageSpeakerMenu>
<ng-template let-speaker="speaker" matMenuContent>
<ng-container *ngIf="canManage">
<ng-container *ngIf="speaker.speech_state !== SpeechState.INTERPOSED_QUESTION">
<ng-container *ngIf="enableSpeechStateControls(speaker)">
<!-- pro button -->
<button
mat-menu-item
(click)="onProContraButtons(speaker, true)"
*ngIf="enableProContraSpeech && speaker.speech_state !== SpeechState.INTERPOSED_QUESTION"
*ngIf="enableProContraButton(speaker)"
>
<mat-icon *ngIf="speaker.speech_state !== SpeechState.PRO">add_circle_outline</mat-icon>
<mat-icon class="green-text" *ngIf="speaker.speech_state === SpeechState.PRO">add_circle</mat-icon>
Expand All @@ -438,7 +438,7 @@
<button
mat-menu-item
(click)="onProContraButtons(speaker, false)"
*ngIf="enableProContraSpeech && speaker.speech_state !== SpeechState.INTERPOSED_QUESTION"
*ngIf="enableProContraButton(speaker)"
>
<mat-icon *ngIf="speaker.speech_state !== SpeechState.CONTRA">remove_circle_outline</mat-icon>
<mat-icon class="red-warning-text" *ngIf="speaker.speech_state === SpeechState.CONTRA">
Expand All @@ -448,30 +448,23 @@
</button>

<!-- star button -->
<button mat-menu-item (click)="onMarkButton(speaker)">
<button mat-menu-item (click)="onMarkButton(speaker)" *ngIf="enableContributionButton(speaker)">
<mat-icon>
{{ speaker.speech_state === SpeechState.CONTRIBUTION ? 'star' : 'star_border' }}
</mat-icon>
<span>{{ 'Contribution' | translate }}</span>
</button>

<!-- intervention -->
<button *ngIf="interventionEnabled | async" mat-menu-item (click)="onInterventionButton(speaker)">
<button mat-menu-item (click)="onInterventionButton(speaker)" *ngIf="enableInterventionButton(speaker)">
<mat-icon>
{{ speaker.speech_state === SpeechState.INTERVENTION ? 'error' : 'error_outline' }}
</mat-icon>
<span>{{ 'Intervention' | translate }}</span>
</button>

<!-- point of order -->
<button
*ngIf="
pointOfOrderEnabled &&
(speaker.meeting_user?.user.id === operator.user.id || (pointOfOrderForOthersEnabled | async))
"
mat-menu-item
(click)="onPointOfOrderButton(speaker)"
>
<button mat-menu-item (click)="onPointOfOrderButton(speaker)" *ngIf="enablePointOfOrderButton(speaker)">
<mat-icon>warning</mat-icon>
<!-- TODO: don't fill icon if not enabled-->
<span>{{ 'Point of order' | translate }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { firstValueFrom, map, Observable } from 'rxjs';
import { Id } from 'src/app/domain/definitions/key-types';
import { Selectable } from 'src/app/domain/interfaces/selectable';
import { SpeakerState } from 'src/app/domain/models/speakers/speaker-state';
import { SpeechState } from 'src/app/domain/models/speakers/speech-state';
import { SPECIAL_SPEECH_STATES, SpeechState } from 'src/app/domain/models/speakers/speech-state';
import { BaseMeetingComponent } from 'src/app/site/pages/meetings/base/base-meeting.component';
import { ViewListOfSpeakers, ViewSpeaker } from 'src/app/site/pages/meetings/pages/agenda';
import { ListOfSpeakersControllerService } from 'src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/services/list-of-speakers-controller.service';
Expand Down Expand Up @@ -75,14 +75,6 @@ export class ListOfSpeakersContentComponent extends BaseMeetingComponent impleme
return this.meetingSettingService.get(`list_of_speakers_enable_interposed_question`);
}

public get interventionEnabled(): Observable<boolean> {
return this.meetingSettingService.get(`list_of_speakers_intervention_time`).pipe(map(v => v > 0));
}

public get pointOfOrderForOthersEnabled(): Observable<boolean> {
return this.meetingSettingsService.get(`list_of_speakers_can_create_point_of_order_for_others`);
}

public get structureLevelCountdownEnabled(): Observable<boolean> {
return this.meetingSettingService.get(`list_of_speakers_default_structure_level_time`).pipe(map(v => v > 0));
}
Expand Down Expand Up @@ -151,6 +143,10 @@ export class ListOfSpeakersContentComponent extends BaseMeetingComponent impleme

public pointOfOrderEnabled = false;

private pointOfOrderForOthersEnabled = false;

private interventionEnabled = false;

@Output()
private isListOfSpeakersEmptyEvent = new EventEmitter<boolean>();

Expand Down Expand Up @@ -338,6 +334,38 @@ export class ListOfSpeakersContentComponent extends BaseMeetingComponent impleme
return !!this.findOperatorSpeaker(pointOfOrder);
}

public enableSpeechStateControls(speaker: ViewSpeaker): boolean {
return (
speaker.speech_state !== SpeechState.INTERPOSED_QUESTION &&
(!speaker.isSpeaking || speaker.speech_state !== SpeechState.INTERVENTION)
);
}

public enableProContraButton(speaker: ViewSpeaker): boolean {
return (
this.enableProContraSpeech &&
(!speaker.isSpeaking || (!SPECIAL_SPEECH_STATES.includes(speaker.speech_state) && !speaker.point_of_order))
);
}

public enableContributionButton(speaker: ViewSpeaker): boolean {
return (
!speaker.isSpeaking || (!SPECIAL_SPEECH_STATES.includes(speaker.speech_state) && !speaker.point_of_order)
);
}

public enableInterventionButton(speaker: ViewSpeaker): boolean {
return this.interventionEnabled && !speaker.isSpeaking;
}

public enablePointOfOrderButton(speaker: ViewSpeaker): boolean {
return (
this.pointOfOrderEnabled &&
(speaker.meeting_user?.user.id === this.operator.user.id || this.pointOfOrderForOthersEnabled) &&
(!speaker.isSpeaking || !speaker.structure_level_list_of_speakers_id)
);
}

/**
* Click on the mic button to mark a speaker as speaking
*
Expand Down Expand Up @@ -672,22 +700,30 @@ export class ListOfSpeakersContentComponent extends BaseMeetingComponent impleme
private subscribeToSettings(): void {
this.subscriptions.push(
// observe changes the agenda_present_speakers_only setting
this.meetingSettingService.get(`list_of_speakers_present_users_only`).subscribe(() => {
this.meetingSettingsService.get(`list_of_speakers_present_users_only`).subscribe(() => {
this.filterNonAvailableUsers();
}),
// observe changes to the agenda_show_first_contribution setting
// observe point of order settings
this.meetingSettingService.get(`list_of_speakers_enable_point_of_order_speakers`).subscribe(show => {
this.meetingSettingsService.get(`list_of_speakers_enable_point_of_order_speakers`).subscribe(show => {
this.pointOfOrderEnabled = show;
}),
this.meetingSettingService.get(`list_of_speakers_enable_pro_contra_speech`).subscribe(enabled => {
this.meetingSettingsService
.get(`list_of_speakers_can_create_point_of_order_for_others`)
.subscribe(canCreate => {
this.pointOfOrderForOthersEnabled = canCreate;
}),
this.meetingSettingsService.get(`list_of_speakers_enable_pro_contra_speech`).subscribe(enabled => {
this.enableProContraSpeech = enabled;
}),
this.meetingSettingService.get(`list_of_speakers_can_set_contribution_self`).subscribe(canSet => {
this.meetingSettingsService.get(`list_of_speakers_can_set_contribution_self`).subscribe(canSet => {
this.canMarkSelf = canSet;
}),
this.meetingSettingService.get(`list_of_speakers_allow_multiple_speakers`).subscribe(multiple => {
this.meetingSettingsService.get(`list_of_speakers_allow_multiple_speakers`).subscribe(multiple => {
this.enableMultipleParticipants = multiple;
}),
this.meetingSettingsService.get(`list_of_speakers_intervention_time`).subscribe(time => {
this.interventionEnabled = time > 0;
})
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { SpeechState } from 'src/app/domain/models/speakers/speech-state';
import { SPECIAL_SPEECH_STATES } from 'src/app/domain/models/speakers/speech-state';
import { StructureLevelListOfSpeakers } from 'src/app/domain/models/structure-levels/structure-level-list-of-speakers';
import { BaseViewModel } from 'src/app/site/base/base-view-model';
import { ViewListOfSpeakers, ViewSpeaker } from 'src/app/site/pages/meetings/pages/agenda';
import { ViewStructureLevel } from 'src/app/site/pages/meetings/pages/participants/pages/structure-levels/view-models';
import { HasMeeting } from 'src/app/site/pages/meetings/view-models/has-meeting';

const SPECIAL_SPEECH_STATES = [SpeechState.INTERPOSED_QUESTION, SpeechState.INTERVENTION];

export class ViewStructureLevelListOfSpeakers extends BaseViewModel<StructureLevelListOfSpeakers> {
public static COLLECTION = StructureLevelListOfSpeakers.COLLECTION;

Expand Down

0 comments on commit 70a37e6

Please sign in to comment.