funky-framadate-front/src/app/config/PollConfig.ts

83 lines
2.8 KiB
TypeScript

/**
* une option de date dans les sondages spéciaux
*/
import {environment} from "../../environments/environment";
export interface DateOption {
timeList: any;
literal: string;
}
export const timeOfDay = [{
timeList: [],
literal: 'matin'
},
{timeList: [], literal: 'midi'},
{timeList: [], literal: 'après-midi'},
{timeList: [], literal: 'soirée'}];
export const defaultDates = [
{
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}`,
timeList: [{literal: 'matin'}, {literal: 'midi'}, {literal: 'soir'}]
},
{
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 1}`,
timeList: [{literal: 'matin'}, {literal: 'midi'}, {literal: 'soir'}]
},
{
literal: `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate() + 2}`,
timeList: [{literal: 'matin'}, {literal: 'midi'}, {literal: 'soir'}]
}
];
export const defaultAnswers = [{
id: 0,
text: 'réponse de démo 1'
},
{
id: 1,
text: 'réponse 2'
},
{
id: 2,
text: 'la réponse D'
}];
/**
* configuration of the poll, add new fields at will
*/
export class PollConfig {
expiracyDateDefaultInDays = 60;
step = 0;
stepMax = 3;
pollType = 'classic';// classic or date
title = 'titre';
description = 'ma description';
myName = 'mon pseudo';
// 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
pollId = null; // id of the current poll when created. data given by the backend api
selectedPoll = null; // 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
urlPublic = environment.baseApiHref + '/default-url';
urlAdmin = environment.baseApiHref + '/default-url/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
canModifyAnswers = 1;// everybody, self, nobody (= just admin)
whoModifiesAnswers = "self";// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
dateList: DateOption[] = defaultDates; // sets of days as strings, config to set identical time for days in a special days poll
timeList: DateOption[] = timeOfDay; // ranges of time expressed as strings
answers: any = defaultAnswers;
constructor() {
}
}