update manual text dates input on change and prefill

This commit is contained in:
Tykayn 2022-02-04 13:40:19 +01:00 committed by tykayn
parent 19e5e07d26
commit 217d9a97c7
3 changed files with 15 additions and 5 deletions

View File

@ -47,7 +47,7 @@ export class PollService implements Resolve<Poll> {
public showDateInterval = false;
public allowSeveralHours = false;
public richTextMode = false;
public mode_calendar = true;
public mode_calendar = false;
public calendar: Date[] = [new Date()];
public disabled_dates: Date[] = [];

View File

@ -7,9 +7,6 @@
(cdkDropListDropped)="dropDayItem($event)"
>
<div class="date-choice-container" *ngFor="let choice of dateChoices; index as id">
<p>
{{ choice.date_object | date: 'short' }}
</p>
<div class="date-choice" cdkDrag [ngClass]="{ 'day-weekend': isWeekendDay(choice.date_input) }">
<!-- <span class="button is-default">-->
<!-- <i class="icon fa fa-arrows-v"></i>-->
@ -26,7 +23,8 @@
<span class="format-helper pull-right">{{ 'dates.format_helper' | translate }}</span>
<input
[(ngModel)]="choice.date_input"
[ngModel]="choice.date_object | date: 'yyyy-MM-dd'"
(ngModelChange)="convertDateInput($event, id)"
class="date-choice-item"
name="dateChoices_{{ id }}"
id="dateChoices_{{ id }}"

View File

@ -180,4 +180,16 @@ export class DayListComponent {
openSimple() {
this.display = !this.display;
}
/**
* convert back date object to datechoices
* @param date_as_string
* @param choice_id
*/
convertDateInput(date_as_string: string, choice_id: number) {
console.log('$event,date_object', date_as_string, choice_id);
let newDate = new Date(date_as_string);
this.dateChoices[choice_id].date_object = newDate;
this.dateChoices[choice_id].date_input = date_as_string;
}
}