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

74 lines
2.9 KiB
TypeScript

/**
* une option de date dans les sondages spéciaux
*/
import {environment} from "../../environments/environment";
import {defaultAnswers, defaultDates, defaultTimeOfDay} from "./defaultConfigs";
export interface DateOption {
timeList: any;
literal: string;
date_object?: object;
}
const baseConfigValues = {
pollType: "classic",
title: "",
description: "",
myName: "",
myEmail: "",
};
/**
* configuration of the poll, add new fields at will
*/
export class PollConfig {
expiracyDateDefaultInDays = 60;
deletionDateAfterLastModification = 180;
step: number = 0; // step in the progress of creating a poll
stepMax: number = 3; // step max in the progress of creating a poll
pollType: string = 'dates';// classic or dates
title: string = 'titre';
description: string = 'ma description';
myName: string = 'mon pseudo';
myComment: string = 'wouah trop bien framadate!';
isAdmin: boolean = true;
myVoteStack: any;
myTempVoteStack = 0;
myEmail: string = "tktest@tktest.com";
myPolls: any = [];// list of retrieved polls from the backend api
// 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();
expirationDate = ''; // expiracy date
voteStackId = null; // id of the vote stack to update
pollId = null; // id of the current poll when created. data given by the backend api
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
urlSlugPublic = null;
urlPublic = environment.baseHref + '/#/poll/id/4';
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
adminKey = ''; // key to change config of the poll
owner_modifier_token = ''; // key to change a vote stack
canModifyAnswers = true;// bool for the frontend selector
whoModifiesAnswers = "everybody";// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
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;
resetConfig() {
const self = this;
Object.keys(baseConfigValues).forEach((key) => {
self[key] = baseConfigValues[key];
})
}
}