check DTO for poll creation

This commit is contained in:
Tykayn 2021-11-23 10:21:02 +01:00 committed by tykayn
parent dba514dd46
commit 434f4b82b1
5 changed files with 62 additions and 79 deletions

View File

@ -2,45 +2,44 @@ import { Choice, ChoiceGroup } from './choice.model';
import { DateChoice, TimeSlices } from './dateChoice.model'; import { DateChoice, TimeSlices } from './dateChoice.model';
export class PollDTO { export class PollDTO {
menuVisible = true; adminKey; // key to change config of the poll
expiracyDateDefaultInDays;
deletionDateAfterLastModification;
pollType: string = 'date'; // classic or dates
title;
description;
myName;
myComment = '';
isAdmin; // when we create a poll; we are admin on it
myVoteStack;
myTempVoteStack;
myEmail;
myPolls; // list of retrieved polls from the backend api
allowSeveralHours; allowSeveralHours;
visibility; // visible to one with the link: answers;
voteChoices = 'yes; maybe; no'; // possible answers to a vote timeSlice: only "yes"; "yes; maybe; no" canModifyAnswers; // bool for the frontend selector
created_at; created_at;
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
custom_url; // custom slug in the url; must be unique
customUrlIsUnique; // given by the backend
dateList; // sets of days as strings; config to set identical time for days in a special days poll
deletionDateAfterLastModification;
description;
displayConfirmVoteModalAdmin;
default_expiracy_days_from_now;
expirationDate; // expiracy date expirationDate; // expiracy date
voteStackId; // id of the vote stack to update isAdmin; // when we create a poll; we are admin on it
kind: string;
myComment = '';
myEmail;
myName;
myPolls; // list of retrieved polls from the backend api
myTempVoteStack;
myVoteStack;
owner_modifier_token; // key to change a vote stack
password;
passwordAccess;
pollId; // id of the current poll when created. data given by the backend api pollId; // id of the current poll when created. data given by the backend api
pollSlug; // id of the current poll when created. data given by the backend api pollSlug; // id of the current poll when created. data given by the backend api
currentPoll; // current poll selected with createPoll or getPoll of ConfigService pollType: string = 'date'; // classic or dates
passwordAccess;
password;
customUrl; // custom slug in the url; must be unique
customUrlIsUnique; // given by the backend
urlSlugPublic;
urlPublic;
urlAdmin;
adminKey; // key to change config of the poll
owner_modifier_token; // key to change a vote stack
canModifyAnswers; // bool for the frontend selector
whoModifiesAnswers; // everybody; self; nobody (: just admin)
whoCanChangeAnswers; // everybody; self; nobody (: just admin)
dateList; // sets of days as strings; config to set identical time for days in a special days poll
timeList; // ranges of time expressed as strings timeList; // ranges of time expressed as strings
title;
answers; urlAdmin;
displayConfirmVoteModalAdmin; urlPublic;
urlSlugPublic;
visibility; // visible to one with the link:
voteChoices = 'yes; maybe; no'; // possible answers to a vote timeSlice: only "yes"; "yes; maybe; no"
voteStackId; // id of the vote stack to update
whoCanChangeAnswers; // everybody; self; nobody (: just admin)
whoModifiesAnswers; // everybody; self; nobody (: just admin)
constructor() {} constructor() {}
} }

View File

@ -5,62 +5,41 @@ import { DateChoice, TimeSlices } from './dateChoice.model';
import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs'; import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs';
export class Poll { export class Poll {
public id = 0;
public default_expiracy_days_from_now = 60;
public admin_key: string; public admin_key: string;
public kind = 'date';
public description?: string;
public password?: string;
public expiracy_date?: string;
public creation_date?: string = new Date().toISOString();
public creatorPseudo?: string;
public creatorEmail?: string;
public is_archived?: boolean;
public is_zero_knowledge?: boolean = false;
public allow_comments?: boolean = true; public allow_comments?: boolean = true;
public allowComments?: boolean = true; public allowComments?: boolean = true;
public allowed_answers = ['yes', 'maybe', 'no'];
public allowSeveralHours?: boolean;
public archiveNumberOfDays?: number;
public areResultsPublic?: boolean = true;
public choices: Choice[] = [];
public choices_grouped: ChoiceGroup[] = [];
public comments: Comment[] = [];
public creation_date?: string = new Date().toISOString();
public creatorEmail?: string;
public creatorPseudo?: string;
public dateChoices: DateChoice[] = [];
public default_expiracy_days_from_now = 60;
public description?: string;
public expiracy_date?: string;
public has_several_hours?: boolean = false; public has_several_hours?: boolean = false;
public hasSeveralHours?: boolean = false; public hasSeveralHours?: boolean = false;
public isOwnerNotifiedByEmailOnNewVote?: boolean = true; public id = 0;
public isOwnerNotifiedByEmailOnNewComment?: boolean = true; public is_archived?: boolean;
public isMaybeAnswerAvailable?: boolean = true; public isMaybeAnswerAvailable?: boolean = true;
public areResultsPublic?: boolean = true; public isOwnerNotifiedByEmailOnNewComment?: boolean = true;
public isOwnerNotifiedByEmailOnNewVote?: boolean = true;
public allowSeveralHours?: boolean; public is_zero_knowledge?: boolean = false;
public kind = 'date';
public archiveNumberOfDays?: number; public hideResults = false;
public max_score?: number;
public max_count_of_answers?: number = 150; public max_count_of_answers?: number = 150;
public maxCountOfAnswers?: number = 150; public maxCountOfAnswers?: number = 150;
public max_score?: number;
public comments: Comment[] = [];
public choices: Choice[] = [];
public choices_grouped: ChoiceGroup[] = [];
public votes = [];
public stacks = [];
public allowed_answers = ['yes'];
public modification_policy = 'everybody'; public modification_policy = 'everybody';
public password?: string;
public dateChoices: DateChoice[] = []; public stacks = [];
// sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
public timeSlices: TimeSlices[] = Object.create(defaultTimeOfDay); // ranges of time expressed as strings public timeSlices: TimeSlices[] = Object.create(defaultTimeOfDay); // ranges of time expressed as strings
public votes = [];
constructor(public owner: Owner = new Owner(), public title = 'mon titre', public custom_url: string = '') {} constructor(public owner: Owner = new Owner(), public title = 'mon titre', public custom_url: string = '') {}
} }

View File

@ -141,6 +141,7 @@ export class PollService implements Resolve<Poll> {
useVoterUniqueLink: [false, [Validators.required]], useVoterUniqueLink: [false, [Validators.required]],
voterEmailList: ['', []], voterEmailList: ['', []],
hasSeveralHours: [false, []], hasSeveralHours: [false, []],
hideResults: [false, []],
allowNewDateTime: [true, [Validators.required]], allowNewDateTime: [true, [Validators.required]],
}); });
this.form = form; this.form = form;

View File

@ -112,6 +112,9 @@
<mat-checkbox class="is-not-flex" formControlName="allowComments"> <mat-checkbox class="is-not-flex" formControlName="allowComments">
Autoriser les commentaires Autoriser les commentaires
</mat-checkbox> </mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="hideResults">
Cacher les résultats au public
</mat-checkbox>
<br /> <br />
<mat-checkbox class="is-not-flex" formControlName="hasMaxCountOfAnswers"> <mat-checkbox class="is-not-flex" formControlName="hasMaxCountOfAnswers">
Nombre de réponses limitées à ce nombre. Utile pour réserver des places à un évènement. Nombre de réponses limitées à ce nombre. Utile pour réserver des places à un évènement.

View File

@ -22,6 +22,7 @@ export const environment = {
autofill_creation: true, autofill_creation: true,
autofill_participation: false, autofill_participation: false,
advanced_options_display: false, advanced_options_display: false,
autofill_default_timeslices: false,
autoSendNewPoll: false, autoSendNewPoll: false,
interval_days_default: 7, interval_days_default: 7,
showStepperShortcuts: true, showStepperShortcuts: true,