diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 7864911f..0a745321 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -669,7 +669,9 @@ export class PollService implements Resolve { for (let someDate of this.calendar) { converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); } - this.dateChoiceList = converted; + this.dateChoiceList = converted.sort((first: any, second: any) => { + return second.date_object < first.date_object; + }); return converted; } diff --git a/src/app/features/administration/form/date/list/day/day-list.component.ts b/src/app/features/administration/form/date/list/day/day-list.component.ts index b0a4a8f1..3630e8f8 100644 --- a/src/app/features/administration/form/date/list/day/day-list.component.ts +++ b/src/app/features/administration/form/date/list/day/day-list.component.ts @@ -129,8 +129,24 @@ export class DayListComponent { } addChoice(optionalLabel = ''): void { - this.pollService.dateChoiceList.push(this.dateUtilitiesService.convertDateToDateChoiceObject(new Date())); + let lastDateChoice = this.pollService.dateChoiceList[this.pollService.dateChoiceList.length]; + console.log('lastDateChoice', lastDateChoice); + let lastDateChoiceObject = this.dateUtilitiesService.addDaysToDate( + this.pollService.dateChoiceList.length, + new Date() + ); + if (lastDateChoice && lastDateChoice.date_object) { + lastDateChoiceObject = lastDateChoice.date_object; + } + this.pollService.dateChoiceList.push( + this.dateUtilitiesService.convertDateToDateChoiceObject( + this.dateUtilitiesService.addDaysToDate(1, lastDateChoiceObject) + ) + ); + this.pollService.dateChoiceList = this.pollService.dateChoiceList.sort((a: any, b: any) => { + return b.date_object < a.date_object; + }); this.focusOnChoice(this.storageService.dateChoices.length - 1); } diff --git a/src/app/features/administration/form/steps/step-two/step-two.component.ts b/src/app/features/administration/form/steps/step-two/step-two.component.ts index 728c04aa..8fb0f416 100644 --- a/src/app/features/administration/form/steps/step-two/step-two.component.ts +++ b/src/app/features/administration/form/steps/step-two/step-two.component.ts @@ -42,8 +42,6 @@ export class StepTwoComponent implements OnInit { this.pollService.step_current = 2; } - addIntervalOfDates() {} - get choices(): FormArray { return this.form.get('choices') as FormArray; }