funky-framadate-front/src/app/core/models/configuration.model.ts

37 lines
1.9 KiB
TypeScript
Raw Normal View History

2020-05-05 18:17:12 +02:00
import { environment } from '../../../environments/environment';
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 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,
public isAllowingtoChangeOwnAnswers: boolean = true,
public isMaybeAnswerAvailable: boolean = false,
2020-05-05 18:17:12 +02:00
public isProtectedByPassword: boolean = false,
public isOwnerNotifiedByEmailOnNewVote: boolean = false,
public isOwnerNotifiedByEmailOnNewComment: boolean = false,
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,
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,
// 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 {
return configuration.expiracyDate ? DateService.isDateInPast(configuration.expiracyDate) : undefined;
2020-05-05 18:17:12 +02:00
}
}