Skip to content

Commit

Permalink
Add default poll method to motion settings (#4173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elblinator authored Sep 27, 2024
1 parent 3056053 commit 109974a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const meetingSettingsDefaults: { [key: string]: any } = {
motions_supporters_min_amount: 0,
motions_block_slide_columns: 3,
motion_poll_default_type: `pseudoanonymous`,
motion_poll_default_method: `YNA`,
motion_poll_default_onehundred_percent_base: `YNA`,
motion_poll_ballot_paper_selection: `CUSTOM_NUMBER`,
motion_poll_ballot_paper_number: 8,
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/domain/models/meetings/meeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class Settings {
public motion_poll_default_onehundred_percent_base!: PollPercentBase;
public motion_poll_default_group_ids!: Id[]; // (group/used_as_motion_poll_default_id)[];
public motion_poll_default_backend!: PollBackendDurationType;
public motion_poll_default_method!: PollMethod;

// Users
public users_enable_presence_view!: boolean;
Expand Down Expand Up @@ -394,6 +395,7 @@ export class Meeting extends BaseModel<Meeting> {
`motion_poll_ballot_paper_selection`,
`motion_poll_ballot_paper_number`,
`motion_poll_default_type`,
`motion_poll_default_method`,
`motion_poll_default_onehundred_percent_base`,
`motion_poll_default_group_ids`,
`motion_poll_default_backend`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { marker as _ } from '@colsen1991/ngx-translate-extract-marker';

export const MotionPollMethodVerbose = {
YN: _(`Yes/No`),
YNA: _(`Yes/No/Abstain`)
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface TableDataEntryCreationInput {
})
export class MotionPollService extends PollService {
public defaultPercentBase!: PollPercentBase;
public defaultPollMethod: PollMethod | undefined;
public defaultPollType!: PollType;
public defaultGroupIds!: number[];

Expand All @@ -52,14 +53,17 @@ export class MotionPollService extends PollService {
.subscribe(base => (this.defaultPercentBase = base));
this.meetingSettingsService.get(`motion_poll_default_type`).subscribe(type => (this.defaultPollType = type));
this.meetingSettingsService.get(`motion_poll_default_group_ids`).subscribe(ids => (this.defaultGroupIds = ids));
this.meetingSettingsService
.get(`motion_poll_default_method`)
.subscribe(method => (this.defaultPollMethod = method));
}

public getDefaultPollData(contentObject?: Motion): Partial<Poll> {
const poll: Partial<Poll> = {
onehundred_percent_base: this.defaultPercentBase,
entitled_group_ids: Object.values(this.defaultGroupIds ?? []),
type: this.isElectronicVotingEnabled ? this.defaultPollType : PollType.Analog,
pollmethod: PollMethod.YNA
pollmethod: this.defaultPollMethod
};

let titlePrefix = this.translate.instant(`Motion`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { createEmailValidator } from 'src/app/infrastructure/utils/validators/em

import { OrganizationSettingsService } from '../../../organization/services/organization-settings.service';
import { AssignmentPollMethodVerbose } from '../../pages/assignments/modules/assignment-poll/definitions';
import { MotionPollMethodVerbose } from '../../pages/motions/modules/motion-poll/definitions';
import { ViewMeeting } from '../../view-models/view-meeting';

export type SettingsValueMap = { [key in keyof Settings]?: any };
Expand Down Expand Up @@ -766,6 +767,12 @@ export const meetingSettings: SettingsGroup[] = fillInSettingsDefaults([
label: _(`Default groups with voting rights`),
type: `groups`
},
{
key: `motion_poll_default_method`,
label: _(`Default vote method`),
type: `choice`,
choices: MotionPollMethodVerbose
},
{
key: `motion_poll_default_onehundred_percent_base`,
label: _(`Default 100 % base`),
Expand Down

0 comments on commit 109974a

Please sign in to comment.