fix default days to expire a poll

This commit is contained in:
Tykayn 2021-11-14 17:43:18 +01:00 committed by tykayn
parent 989208faa5
commit 2f26e27e31
4 changed files with 24 additions and 14 deletions

View File

@ -96,7 +96,7 @@ export class PollService implements Resolve<Poll> {
isProtectedByPassword: false,
richTextMode: false,
areResultsPublic: true,
expiracyNumberOfDays: 60,
expiresDaysDelay: environment.expiresDaysDelay,
});
this.automaticSlug();
}
@ -122,7 +122,7 @@ export class PollService implements Resolve<Poll> {
whoModifiesAnswers: ['', [Validators.required]],
whoCanChangeAnswers: ['', [Validators.required]],
isAboutDate: [true, [Validators.required]],
expiresDaysDelay: [60, []],
expiresDaysDelay: [environment.expiresDaysDelay, []],
maxCountOfAnswers: [300, []],
isZeroKnoledge: [false, [Validators.required]],
isProtectedByPassword: [false, [Validators.required]],
@ -137,7 +137,7 @@ export class PollService implements Resolve<Poll> {
hasMaxCountOfAnswers: [300, [Validators.required]],
useVoterUniqueLink: [false, [Validators.required]],
voterEmailList: ['', []],
allowNewDateTime: [60, [Validators.required, Validators.min(0)]],
allowNewDateTime: [true, [Validators.required]],
});
this.form = form;
return form;
@ -159,7 +159,7 @@ export class PollService implements Resolve<Poll> {
isProtectedByPassword: false,
richTextMode: false,
areResultsPublic: true,
expiresDayDelay: 60,
expiresDaysDelay: environment.expiresDaysDelay,
maxCountOfAnswers: 300,
voterEmailList: '',
password: '',
@ -395,8 +395,6 @@ export class PollService implements Resolve<Poll> {
return this.apiService.createPoll(newpoll).then(
(resp: any) => {
console.log('poll created resp', resp);
console.log('TODO fill admin_key');
console.log('resp', resp);
this.admin_key = resp.data.poll.admin_key;
this.storageService.userPolls.push(resp.data.poll);
},

View File

@ -21,8 +21,13 @@ export class StepFourComponent implements OnInit {
ngOnInit(): void {}
createPoll() {
this.pollService.createPoll().then((resp) => {
this.router.navigate(['administration/success']);
});
this.pollService.createPoll().then(
(resp) => {
this.router.navigate(['administration/success']);
},
(err) => {
console.error('oops err', err);
}
);
}
}

View File

@ -42,12 +42,18 @@
Voir le sondage coté administrateur·ice
</a>
<br />
<p class="note">
Note : Le sondage sera supprimé
{{ pollService.form.value.default_expiracy_days_from_now }} jours après la date de sa
<p class="note has-background-info padded">
<i class="fa fa-info-circle"></i> Note : Le sondage sera supprimé
<strong> {{ pollService.form.value.expiresDaysDelay }} </strong> jours après la date de sa
dernière modification.
<span class="expiracy-detail" *ngIf="pollService.form.value.expiracy_date">
Le {{ pollService.form.value.expiracy_date | date: 'short' }}
<span class="expiracy-detail" *ngIf="pollService.form.value.expiresDaysDelay">
Le
{{
pollService.DateUtilitiesService.addDaysToDate(
pollService.form.value.expiresDaysDelay,
today
) | date: 'short'
}}
</span>
</p>
</div>

View File

@ -15,6 +15,7 @@ export class SuccessComponent {
mailToRecieve: string;
window: any = window;
environment = environment;
today: Date = new Date();
constructor(public pollService: PollService, private dateUtils: DateUtilitiesService, private titleService: Title) {
this.titleService.setTitle(
environment.appTitle + ' - 🎉 succès de création de sondage - ' + this.pollService.form.value.title