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';
export class PollDTO {
menuVisible = true;
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
adminKey; // key to change config of the poll
allowSeveralHours;
visibility; // visible to one with the link:
voteChoices = 'yes; maybe; no'; // possible answers to a vote timeSlice: only "yes"; "yes; maybe; no"
answers;
canModifyAnswers; // bool for the frontend selector
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
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
pollSlug; // id of the current poll when created. data given by the backend api
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
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
pollType: string = 'date'; // classic or dates
timeList; // ranges of time expressed as strings
answers;
displayConfirmVoteModalAdmin;
title;
urlAdmin;
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() {}
}

View File

@ -5,62 +5,41 @@ import { DateChoice, TimeSlices } from './dateChoice.model';
import { defaultTimeOfDay } from '../../../../mocks/old-stuff/config/defaultConfigs';
export class Poll {
public id = 0;
public default_expiracy_days_from_now = 60;
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 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 hasSeveralHours?: boolean = false;
public isOwnerNotifiedByEmailOnNewVote?: boolean = true;
public isOwnerNotifiedByEmailOnNewComment?: boolean = true;
public id = 0;
public is_archived?: boolean;
public isMaybeAnswerAvailable?: boolean = true;
public areResultsPublic?: boolean = true;
public allowSeveralHours?: boolean;
public archiveNumberOfDays?: number;
public max_score?: number;
public isOwnerNotifiedByEmailOnNewComment?: boolean = true;
public isOwnerNotifiedByEmailOnNewVote?: boolean = true;
public is_zero_knowledge?: boolean = false;
public kind = 'date';
public hideResults = false;
public max_count_of_answers?: number = 150;
public maxCountOfAnswers?: number = 150;
public comments: Comment[] = [];
public choices: Choice[] = [];
public choices_grouped: ChoiceGroup[] = [];
public votes = [];
public stacks = [];
public allowed_answers = ['yes'];
public max_score?: number;
public modification_policy = 'everybody';
public dateChoices: DateChoice[] = [];
// sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
public password?: string;
public stacks = [];
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 = '') {}
}

View File

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

View File

@ -112,6 +112,9 @@
<mat-checkbox class="is-not-flex" formControlName="allowComments">
Autoriser les commentaires
</mat-checkbox>
<mat-checkbox class="is-not-flex" formControlName="hideResults">
Cacher les résultats au public
</mat-checkbox>
<br />
<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.

View File

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