forked from tykayn/funky-framadate-front
focus on day list input on delete and add choice
This commit is contained in:
parent
8a22dd85eb
commit
0b1c909182
@ -29,7 +29,7 @@
|
||||
<div class="delete-date">
|
||||
<button
|
||||
class="has-no-outline has-no-background has-text-primary has-text-left"
|
||||
(click)="dateChoices.splice(id, 1)"
|
||||
(click)="deleteChoiceField(id)"
|
||||
>
|
||||
<img class="icon" aria-hidden="true" src="assets/icons/trash.svg" />
|
||||
{{ 'dates.remove' | translate }} {{ id + 1 }}
|
||||
|
@ -131,7 +131,7 @@ export class DayListComponent {
|
||||
}
|
||||
|
||||
addChoice(optionalLabel = ''): void {
|
||||
let lastDateChoice = this.pollService.dateChoiceList[this.pollService.dateChoiceList.length];
|
||||
let lastDateChoice = this.pollService.dateChoiceList[this.pollService.dateChoiceList.length - 1];
|
||||
console.log('lastDateChoice', lastDateChoice);
|
||||
let lastDateChoiceObject = this.dateUtilitiesService.addDaysToDate(
|
||||
this.pollService.dateChoiceList.length,
|
||||
@ -149,29 +149,29 @@ export class DayListComponent {
|
||||
this.pollService.dateChoiceList.sort((a: any, b: any) => {
|
||||
return a.date_object - b.date_object;
|
||||
});
|
||||
this.focusOnChoice(this.storageService.dateChoices.length - 1);
|
||||
this.cd.detectChanges();
|
||||
this.focusOnChoice(this.pollService.dateChoiceList.length - 1);
|
||||
}
|
||||
|
||||
focusOnChoice(index): void {
|
||||
const selector = '#choice_label_' + index;
|
||||
const selector = '#dateChoices_' + index;
|
||||
const elem = this.document.querySelector(selector);
|
||||
console.log('focusOnChoice elem', selector, elem);
|
||||
if (elem) {
|
||||
elem.focus();
|
||||
}
|
||||
}
|
||||
|
||||
deleteChoiceField(index: number): void {
|
||||
if (this.dateChoices.length !== 1) {
|
||||
this.dateChoices.splice(index, 1);
|
||||
}
|
||||
this.dateChoices.splice(index, 1);
|
||||
this.cd.detectChanges();
|
||||
this.focusOnChoice(index - 1 < 0 ? 0 : index - 1);
|
||||
}
|
||||
|
||||
isWeekendDay(date_input: string) {
|
||||
let date_object = new Date(Date.parse(date_input));
|
||||
console.log('date_object', date_object);
|
||||
if (date_object) {
|
||||
const day = date_object.getDay();
|
||||
console.log('day', day);
|
||||
return day === 6 || day === 0;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user