framadate-responsive/src/app/config/PollConfig.ts

74 lines
2.7 KiB
TypeScript
Raw Normal View History

/**
* une option de date dans les sondages spéciaux
*/
import {environment} from "../../environments/environment";
2020-01-24 12:20:28 +01:00
import {defaultAnswers, defaultDates, defaultTimeOfDay} from "./defaultConfigs";
export interface DateOption {
timeList: any;
2019-08-12 14:40:33 +02:00
literal: string;
2020-01-24 11:15:38 +01:00
date_object?: object;
}
const baseConfigValues = {
pollType: "classic",
title: "",
description: "",
myName: "",
myEmail: "",
};
2019-11-15 15:19:42 +01:00
/**
2019-08-10 17:41:01 +02:00
* configuration of the poll, add new fields at will
*/
export class PollConfig {
2019-11-23 15:35:27 +01:00
expiracyDateDefaultInDays = 60;
2020-01-16 11:46:31 +01:00
deletionDateAfterLastModification = 180;
2020-01-20 14:36:26 +01:00
step: number = 0; // step in the progress of creating a poll
stepMax: number = 3; // step max in the progress of creating a poll
2020-01-24 11:10:50 +01:00
pollType: string = 'dates';// classic or dates
2020-01-20 14:36:26 +01:00
title: string = 'titre';
description: string = 'ma description';
myName: string = 'mon pseudo';
myComment: string = 'wouah trop bien framadate!';
2020-01-20 15:50:09 +01:00
isAdmin: boolean = true;
myVoteStack: any;
myTempVoteStack =0;
2020-01-20 14:36:26 +01:00
myEmail: string = "tktest@tktest.com";
2020-01-22 16:49:15 +01:00
myPolls: any = [];// list of retrieved polls from the backend api
2019-11-22 16:46:12 +01: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
allowSeveralHours = 'false';
// access
visibility = 'link_only'; // visible to anyone with the link:
voteChoices = 'only_yes'; // possible answers to a vote choice: only "yes", "yes, maybe, no"
creationDate = new Date();
2019-11-23 15:35:27 +01:00
expirationDate = ''; // expiracy date
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
currentPoll; // current poll selected with createPoll or getPoll of ConfigService
passwordAccess = 0;
password = '';
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;
urlPublic = environment.baseHref + '/#/poll/id/3';
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
2019-11-23 15:35:27 +01:00
canModifyAnswers = 1;// everybody, self, nobody (= just admin)
whoModifiesAnswers = "self";// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
2020-01-24 12:20:28 +01:00
dateList: any = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll
timeList: any = defaultTimeOfDay; // ranges of time expressed as strings
answers: any = defaultAnswers;
2019-08-10 17:41:01 +02:00
2020-01-15 15:55:15 +01:00
constructor() {
}
resetConfig() {
const self = this;
Object.keys(baseConfigValues).forEach((key) => {
self[key] = baseConfigValues[key];
})
}
}