|
|
|
@ -12,6 +12,13 @@ import { UserService } from './user.service';
|
|
|
|
|
import { UuidService } from './uuid.service';
|
|
|
|
|
import { Form } from '@angular/forms';
|
|
|
|
|
import { PollConfig } from '../../features/old-stuff/config/PollConfig';
|
|
|
|
|
import { environment } from '../../../environments/environment';
|
|
|
|
|
import {
|
|
|
|
|
DateChoice,
|
|
|
|
|
defaultAnswers,
|
|
|
|
|
otherDefaultDates,
|
|
|
|
|
PollAnswer,
|
|
|
|
|
} from '../../features/old-stuff/config/defaultConfigs';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root',
|
|
|
|
@ -168,6 +175,55 @@ export class PollService implements Resolve<Poll> {
|
|
|
|
|
this.uuidService.getUUID(),
|
|
|
|
|
form.controls.title.value
|
|
|
|
|
);
|
|
|
|
|
return newpoll;
|
|
|
|
|
/**
|
|
|
|
|
* convert to API version 1 config poll
|
|
|
|
|
*/
|
|
|
|
|
const apiV1Poll = {
|
|
|
|
|
menuVisible: true,
|
|
|
|
|
expiracyDateDefaultInDays: newpoll.configuration.expiresDaysDelay,
|
|
|
|
|
deletionDateAfterLastModification: newpoll.configuration.expiracyAfterLastModificationInDays,
|
|
|
|
|
pollType: newpoll.configuration.isAboutDate ? 'dates' : 'classic', // classic or dates
|
|
|
|
|
title: newpoll.title,
|
|
|
|
|
description: newpoll.description,
|
|
|
|
|
myName: newpoll.owner.pseudo,
|
|
|
|
|
myComment: '',
|
|
|
|
|
isAdmin: true, // when we create a poll, we are admin on it
|
|
|
|
|
myVoteStack: {},
|
|
|
|
|
myTempVoteStack: 0,
|
|
|
|
|
myEmail: newpoll.owner.email,
|
|
|
|
|
myPolls: [], // 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: 'true',
|
|
|
|
|
// access
|
|
|
|
|
visibility: newpoll.configuration.areResultsPublic, // visible to one with the link:
|
|
|
|
|
voteChoices: newpoll.configuration.isMaybeAnswerAvailable ? 'yes, maybe, no' : '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: null, // current poll selected with createPoll or getPoll of ConfigService
|
|
|
|
|
passwordAccess: newpoll.configuration.isProtectedByPassword,
|
|
|
|
|
password: newpoll.configuration.password,
|
|
|
|
|
customUrl: newpoll.slug, // custom slug in the url, must be unique
|
|
|
|
|
customUrlIsUnique: null, // given by the backend
|
|
|
|
|
urlSlugPublic: null,
|
|
|
|
|
urlPublic: null,
|
|
|
|
|
urlAdmin: null,
|
|
|
|
|
adminKey: '', // key to change config of the poll
|
|
|
|
|
owner_modifier_token: '', // key to change a vote stack
|
|
|
|
|
canModifyAnswers: newpoll.configuration.isAllowingtoChangeOwnAnswers, // bool for the frontend selector
|
|
|
|
|
whoModifiesAnswers: newpoll.configuration.whoCanChangeAnswers, // everybody, self, nobody (: just admin)
|
|
|
|
|
whoCanChangeAnswers: newpoll.configuration.whoCanChangeAnswers, // everybody, self, nobody (: just admin)
|
|
|
|
|
dateList: newpoll.dateChoices, // sets of days as strings, config to set identical time for days in a special days poll
|
|
|
|
|
timeList: newpoll.timeChoices, // ranges of time expressed as strings
|
|
|
|
|
|
|
|
|
|
answers: newpoll.choices,
|
|
|
|
|
// modals
|
|
|
|
|
displayConfirmVoteModalAdmin: false,
|
|
|
|
|
};
|
|
|
|
|
return apiV1Poll;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|