diff --git a/public/js/icinga/behavior/datetime-picker.js b/public/js/icinga/behavior/datetime-picker.js index 0a28004f9..36b9887af 100644 --- a/public/js/icinga/behavior/datetime-picker.js +++ b/public/js/icinga/behavior/datetime-picker.js @@ -87,6 +87,9 @@ return format === this.dateFormat ? Flatpickr.formatDate(date, format, locale) : dateTimeFormatter.format(date); + }, + onOpen: function (selectedDates, dateStr, instance) { + _this.closePickers(instance); } }; @@ -135,6 +138,20 @@ }, this); }; + /** + * Close all other flatpickr instances and keep the given one + * + * @param fp {Flatpickr} + */ + DatetimePicker.prototype.closePickers = function (fp) { + var containerId = this._pickers.get(fp); + this._pickers.forEach(function (cId, fp2) { + if (cId === containerId && fp2 !== fp) { + fp2.close(); + } + }, this); + }; + DatetimePicker.prototype.createFormatter = function (withDate, withTime) { var options = {}; if (withDate) {