2019-08-10 17:21:40 +02:00
|
|
|
/**
|
|
|
|
* une option de date dans les sondages spéciaux
|
|
|
|
*/
|
2020-04-11 16:16:25 +02:00
|
|
|
import {environment} from '../../environments/environment';
|
|
|
|
import {DateChoice, defaultAnswers, otherDefaultDates, PollAnswer} from './defaultConfigs';
|
2020-01-16 10:45:56 +01:00
|
|
|
|
2019-08-10 17:21:40 +02:00
|
|
|
export interface DateOption {
|
2019-11-19 10:36:53 +01:00
|
|
|
timeList: any;
|
2019-08-12 14:40:33 +02:00
|
|
|
literal: string;
|
2020-01-24 11:15:38 +01:00
|
|
|
date_object?: object;
|
2019-08-10 17:21:40 +02:00
|
|
|
}
|
|
|
|
|
2020-01-21 12:30:53 +01:00
|
|
|
const baseConfigValues = {
|
2020-04-11 16:16:25 +02:00
|
|
|
pollType: 'dates',
|
|
|
|
title: '',
|
|
|
|
description: '',
|
|
|
|
myName: '',
|
|
|
|
myEmail: '',
|
2020-01-21 12:30:53 +01:00
|
|
|
};
|
2019-11-15 15:19:42 +01:00
|
|
|
|
2020-02-19 12:26:44 +01:00
|
|
|
|
2020-04-11 16:59:46 +02:00
|
|
|
|
|
|
|
|
2019-08-10 17:21:40 +02:00
|
|
|
/**
|
2019-08-10 17:41:01 +02:00
|
|
|
* configuration of the poll, add new fields at will
|
2019-08-10 17:21:40 +02:00
|
|
|
*/
|
|
|
|
export class PollConfig {
|
2020-04-11 16:06:56 +02:00
|
|
|
|
2020-04-11 16:59:46 +02:00
|
|
|
|
2020-04-11 16:06:56 +02:00
|
|
|
menuVisible = true;
|
|
|
|
|
2019-11-23 15:35:27 +01:00
|
|
|
expiracyDateDefaultInDays = 60;
|
2020-01-16 11:46:31 +01:00
|
|
|
deletionDateAfterLastModification = 180;
|
2020-04-11 16:16:25 +02:00
|
|
|
step = 0; // step in the progress of creating a poll
|
|
|
|
stepMax = 3; // step max in the progress of creating a poll
|
|
|
|
pollType = 'dates';// classic or dates
|
2020-04-02 17:49:10 +02:00
|
|
|
|
2020-04-11 16:16:25 +02:00
|
|
|
title: string = environment.production ? '' : 'titre';
|
|
|
|
description: string = environment.production ? '' : 'ma description';
|
|
|
|
myName: string = environment.production ? '' : 'mon pseudo';
|
|
|
|
myComment: string = environment.production ? '' : 'wouah trop bien framadate!';
|
|
|
|
isAdmin: boolean = !environment.production;
|
2020-01-23 15:08:52 +01:00
|
|
|
myVoteStack: any;
|
2020-01-30 10:07:03 +01:00
|
|
|
myTempVoteStack = 0;
|
2020-04-11 16:16:25 +02:00
|
|
|
myEmail: string = environment.production ? '' : 'tktest@tktest.com';
|
2020-01-22 16:49:15 +01:00
|
|
|
myPolls: any = [];// list of retrieved polls from the backend api
|
2020-04-11 16:16:25 +02:00
|
|
|
/*
|
|
|
|
date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates
|
|
|
|
*/
|
2020-02-10 13:06:47 +01:00
|
|
|
allowSeveralHours = 'true';
|
2019-11-19 11:19:21 +01:00
|
|
|
// access
|
|
|
|
visibility = 'link_only'; // visible to anyone with the link:
|
2019-11-23 14:30:19 +01:00
|
|
|
voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no"
|
2020-01-16 11:33:13 +01:00
|
|
|
creationDate = new Date();
|
2019-11-23 15:35:27 +01:00
|
|
|
expirationDate = ''; // expiracy date
|
2020-01-30 10:07:03 +01:00
|
|
|
voteStackId = null; // id of the vote stack to update
|
2019-12-04 12:45:50 +01:00
|
|
|
pollId = null; // id of the current poll when created. data given by the backend api
|
2020-01-23 14:23:07 +01:00
|
|
|
pollSlug = null; // id of the current poll when created. data given by the backend api
|
2020-01-22 11:18:55 +01:00
|
|
|
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
|
2019-11-23 14:58:44 +01:00
|
|
|
passwordAccess = 0;
|
2019-11-19 11:19:21 +01:00
|
|
|
password = '';
|
2020-01-16 11:33:13 +01:00
|
|
|
customUrl = ''; // custom slug in the url, must be unique
|
|
|
|
customUrlIsUnique = null; // given by the backend
|
2020-01-23 16:47:53 +01:00
|
|
|
urlSlugPublic = null;
|
2020-04-11 16:16:25 +02:00
|
|
|
urlPublic = environment.production ? '' : environment.baseHref + '/#/poll/id/4';
|
2020-01-22 14:42:46 +01:00
|
|
|
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
|
2020-02-04 12:51:18 +01:00
|
|
|
adminKey = ''; // key to change config of the poll
|
|
|
|
owner_modifier_token = ''; // key to change a vote stack
|
2020-04-11 16:16:25 +02:00
|
|
|
canModifyAnswers = true;// bool for the frontend selector
|
|
|
|
whoModifiesAnswers = 'everybody';// everybody, self, nobody (= just admin)
|
2019-11-19 11:19:21 +01:00
|
|
|
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
|
2020-02-13 17:41:36 +01:00
|
|
|
dateList: any = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll
|
2020-02-19 12:26:44 +01:00
|
|
|
timeList: DateChoice[] = otherDefaultDates; // ranges of time expressed as strings
|
2019-11-23 14:30:19 +01:00
|
|
|
|
2020-02-19 12:26:44 +01:00
|
|
|
answers: PollAnswer[] = defaultAnswers;
|
2020-04-02 17:49:10 +02:00
|
|
|
// front end choices
|
|
|
|
themeChoices: string[] = ['light-watermelon', 'dark-crystal', 'hot-covid'];
|
2020-04-11 16:16:25 +02:00
|
|
|
themeSelected = 0;
|
|
|
|
themeClass = 'theme-light-watermelon';
|
2020-04-02 17:49:10 +02:00
|
|
|
// modals
|
2020-04-11 16:16:25 +02:00
|
|
|
displayConfirmVoteModalAdmin = false;
|
2019-08-10 17:41:01 +02:00
|
|
|
|
2020-01-21 12:30:53 +01:00
|
|
|
resetConfig() {
|
|
|
|
const self = this;
|
|
|
|
Object.keys(baseConfigValues).forEach((key) => {
|
|
|
|
self[key] = baseConfigValues[key];
|
2020-04-11 16:16:25 +02:00
|
|
|
});
|
2020-01-21 12:30:53 +01:00
|
|
|
}
|
2019-08-10 17:21:40 +02:00
|
|
|
}
|