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

View File

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

View File

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

View File

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