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(
|
|
|
|
public isAboutDate: boolean = false,
|
|
|
|
public isProtectedByPassword: boolean = false,
|
2020-11-11 12:14:01 +01:00
|
|
|
public password: string = '',
|
2020-06-16 18:40:48 +02:00
|
|
|
public isOwnerNotifiedByEmailOnNewVote: boolean = false,
|
|
|
|
public isOwnerNotifiedByEmailOnNewComment: boolean = false,
|
2020-05-05 18:17:12 +02:00
|
|
|
public isMaybeAnswerAvailable: boolean = false,
|
2020-06-16 18:40:48 +02:00
|
|
|
public areResultsPublic: boolean = true,
|
2020-11-11 12:14:01 +01:00
|
|
|
public isAllowingtoChangeOwnAnswers: boolean = true,
|
|
|
|
public whoCanChangeAnswers: string = 'everybody',
|
2020-05-12 19:16:23 +02:00
|
|
|
public dateCreated: Date = new Date(Date.now()),
|
2020-11-11 12:14:01 +01:00
|
|
|
public expiresDaysDelay: number = environment.poll.defaultConfig.expiracyInDays,
|
|
|
|
public expiracyAfterLastModificationInDays: number = environment.poll.defaultConfig
|
|
|
|
.expiracyAfterLastModificationInDays,
|
2020-06-16 18:40:48 +02:00
|
|
|
public expires: Date = DateService.addDaysToDate(
|
2020-05-05 18:17:12 +02:00
|
|
|
environment.poll.defaultConfig.expiracyInDays,
|
|
|
|
new Date(Date.now())
|
|
|
|
)
|
|
|
|
) {}
|
|
|
|
|
2020-10-29 18:43:19 +01:00
|
|
|
public static isArchived(configuration: PollConfiguration): boolean {
|
2020-06-18 16:15:26 +02:00
|
|
|
return configuration.expires ? DateService.isDateInPast(configuration.expires) : undefined;
|
2020-05-05 18:17:12 +02:00
|
|
|
}
|
|
|
|
}
|