add and sort dates in text mode

This commit is contained in:
Tykayn 2021-11-17 17:03:24 +01:00 committed by tykayn
parent 0f4aac7e81
commit b1b6ec650a
3 changed files with 20 additions and 4 deletions

View File

@ -669,7 +669,9 @@ export class PollService implements Resolve<Poll> {
for (let someDate of this.calendar) { for (let someDate of this.calendar) {
converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); 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; return converted;
} }

View File

@ -129,8 +129,24 @@ export class DayListComponent {
} }
addChoice(optionalLabel = ''): void { 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); this.focusOnChoice(this.storageService.dateChoices.length - 1);
} }

View File

@ -42,8 +42,6 @@ export class StepTwoComponent implements OnInit {
this.pollService.step_current = 2; this.pollService.step_current = 2;
} }
addIntervalOfDates() {}
get choices(): FormArray { get choices(): FormArray {
return this.form.get('choices') as FormArray; return this.form.get('choices') as FormArray;
} }