2020-05-05 18:17:12 +02:00
import { environment } from '../../../environments/environment' ;
2020-06-16 18:40:48 +02:00
import { DateService } from '../services/date.service' ;
2020-05-05 18:17:12 +02:00
2020-10-29 18:43:19 +01:00
export class PollConfiguration {
2020-05-05 18:17:12 +02:00
constructor (
2021-02-05 23:03:49 +01:00
public allowComments : boolean = true ,
public areResultsPublic : boolean = true ,
public dateCreated : Date = new Date ( Date . now ( ) ) ,
public password : string = '' ,
2020-05-05 18:17:12 +02:00
public isAboutDate : boolean = false ,
2021-02-05 23:03:49 +01:00
public isAllowingtoChangeOwnAnswers : boolean = true ,
public isMaybeAnswerAvailable : boolean = false ,
2020-05-05 18:17:12 +02:00
public isProtectedByPassword : boolean = false ,
2020-06-16 18:40:48 +02:00
public isOwnerNotifiedByEmailOnNewVote : boolean = false ,
public isOwnerNotifiedByEmailOnNewComment : boolean = false ,
2021-02-05 23:03:49 +01:00
public isZeroKnoledge : boolean = true ,
public hasSeveralHours : boolean = false ,
public hasMaxCountOfAnswers : boolean = false ,
2021-02-08 18:55:31 +01:00
public whoCanChangeAnswers : string = environment . poll . defaultConfig . whoCanChangeAnswers , // everybody, self, nobody (= just admin)
public visibility : string = environment . poll . defaultConfig . visibility , // visible to anyone with the link:
public voteChoices : string = environment . poll . defaultConfig . voteChoices , // possible answers to a vote choice: only "yes", "yes, maybe, no": number = environment.poll.defaultConfig.maxCountOfAnswers,
2021-02-05 23:03:49 +01:00
public maxCountOfAnswers : number = environment . poll . defaultConfig . maxCountOfAnswers ,
public expiresDaysDelay : number = environment . poll . defaultConfig . expiresDaysDelay ,
2020-11-11 12:14:01 +01:00
public expiracyAfterLastModificationInDays : number = environment . poll . defaultConfig
. expiracyAfterLastModificationInDays ,
2021-02-05 23:03:49 +01:00
// date after creation day when people will not be able to vote anymore
public expiracyDate : Date = DateService . addDaysToDate (
environment . poll . defaultConfig . expiresDaysDelay ,
2020-05-05 18:17:12 +02:00
new Date ( Date . now ( ) )
)
) { }
2020-10-29 18:43:19 +01:00
public static isArchived ( configuration : PollConfiguration ) : boolean {
2021-02-05 23:03:49 +01:00
return configuration . expiracyDate ? DateService . isDateInPast ( configuration . expiracyDate ) : undefined ;
2020-05-05 18:17:12 +02:00
}
}