On click within start or due date, update the datepicker restricitions

pull/8461/head
Henriette Darge 4 years ago
parent 75aa80a9ba
commit 2dc2088ef1
  1. 2
      frontend/src/app/components/datepicker/datepicker.helper.ts
  2. 4
      frontend/src/app/components/datepicker/datepicker.modal.html
  3. 6
      frontend/src/app/components/datepicker/datepicker.modal.ts
  4. 2
      frontend/src/app/modules/common/op-date-picker/datepicker.ts

@ -111,7 +111,7 @@ export class DatepickerHelper {
this.selectRangeFromUntil(firstDay, selectedElements[0]);
}
} else if (this.datepickerIsInDateRange(monthContainer[i], dates)) {
jQuery('.dayContainer .flatpickr-day').addClass('inRange');
jQuery(monthContainer[i]).find('.flatpickr-day').addClass('inRange');
}
}
}

@ -43,7 +43,7 @@
[ngClass]="{'-current' : datepickerHelper.isStateOfCurrentActivatedField('start')}"
[ngModel]="dates.start"
(ngModelChange)="updateDate('start', $event)"
(click)="datepickerHelper.setCurrentActivatedField('start')">
(click)="setCurrentActivatedField('start')">
</div>
<a class="form--field-inline-action"
[title]="text.clear"
@ -64,7 +64,7 @@
[ngClass]="{'-current' : datepickerHelper.isStateOfCurrentActivatedField('end')}"
[ngModel]="dates.end"
(ngModelChange)="updateDate('end', $event)"
(click)="datepickerHelper.setCurrentActivatedField('end')">
(click)="setCurrentActivatedField('end')">
</div>
<a class="form--field-inline-action"
[title]="text.clear"

@ -161,6 +161,12 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit {
});
}
setCurrentActivatedField(key:DateKeys) {
this.datepickerHelper.setCurrentActivatedField(key);
this.datepickerHelper.setDatepickerRestrictions(this.dates, this.datePickerInstance);
this.datepickerHelper.setRangeClasses(this.dates);
}
private initializeDatepicker() {
this.datePickerInstance = new DatePicker(
'#flatpickr-input',

@ -134,7 +134,7 @@ export class DatePicker {
return document.elementFromPoint(input.offset()!.left, input.offset()!.top) === input[0] &&
document.activeElement === input[0];
} catch (e) {
console.error("Failed to test visibleAndActive " + e)
console.error("Failed to test visibleAndActive " + e);
return false;
}
};

Loading…
Cancel
Save