mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-31 04:32:06 +08:00
Refactor datepicker limits [SCI-9338]
This commit is contained in:
parent
a499a0f0ea
commit
6e405d40a6
5 changed files with 39 additions and 16 deletions
|
@ -192,13 +192,13 @@
|
|||
|
||||
// Clear filters
|
||||
$filterDropdown.on('filter:clear', function() {
|
||||
$(this).find('input').val('');
|
||||
if ($startedOnFromFilter.data('DateTimePicker')) $startedOnFromFilter.data('DateTimePicker').clear();
|
||||
if ($startedOnToFilter.data('DateTimePicker')) $startedOnToFilter.data('DateTimePicker').clear();
|
||||
if ($modifiedOnFromFilter.data('DateTimePicker')) $modifiedOnFromFilter.data('DateTimePicker').clear();
|
||||
if ($modifiedOnToFilter.data('DateTimePicker')) $modifiedOnToFilter.data('DateTimePicker').clear();
|
||||
if ($archivedOnFromFilter.data('DateTimePicker')) $archivedOnFromFilter.data('DateTimePicker').clear();
|
||||
if ($archivedOnToFilter.data('DateTimePicker')) $archivedOnToFilter.data('DateTimePicker').clear();
|
||||
$textFilter.val('');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,8 @@ var ProtocolsIndex = (function() {
|
|||
$filterDropdown.on('filter:clear', function() {
|
||||
dropdownSelector.clearData($publishedByFilter);
|
||||
dropdownSelector.clearData($accessByFilter);
|
||||
|
||||
$(this).find('input').val('');
|
||||
if ($publishedOnFromFilter.data('DateTimePicker')) $publishedOnFromFilter.data('DateTimePicker').clear();
|
||||
if ($publishedOnToFilter.data('DateTimePicker')) $publishedOnToFilter.data('DateTimePicker').clear();
|
||||
if ($modifiedOnFromFilter.data('DateTimePicker')) $modifiedOnFromFilter.data('DateTimePicker').clear();
|
||||
|
|
|
@ -5,26 +5,39 @@
|
|||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
let dt = $(this);
|
||||
let selectedDate = {};
|
||||
const dt = $(this);
|
||||
|
||||
$('.calendar-input').slice(0, 2).each(function(index, element) {
|
||||
if ($(element).val().length > 0 ) {
|
||||
selectedDate.index = index;
|
||||
selectedDate.date = moment($(element).val(), element.dataset.dateFormat).toDate();
|
||||
}
|
||||
});
|
||||
if (dt.data('DateTimePicker')) {
|
||||
dt.data('DateTimePicker').show();
|
||||
return;
|
||||
}
|
||||
|
||||
const linkedMin = dt.data('linked-min');
|
||||
const linkedMax = dt.data('linked-max');
|
||||
|
||||
let options = {
|
||||
ignoreReadonly: true
|
||||
};
|
||||
ignoreReadonly: true,
|
||||
useCurrent: false
|
||||
}
|
||||
|
||||
if (selectedDate.date) {
|
||||
if (selectedDate.index == 0) {
|
||||
options.minDate = selectedDate.date;
|
||||
} else if (selectedDate.index == 1) {
|
||||
options.maxDate = selectedDate.date;
|
||||
if (linkedMin) {
|
||||
if ($(linkedMin).val()) {
|
||||
options.minDate = moment($(linkedMin).val(), $(linkedMin).data('dateFormat')).toDate();
|
||||
}
|
||||
|
||||
$(linkedMin).on("dp.change", function (e) {
|
||||
dt.data("DateTimePicker").minDate(e.date);
|
||||
});
|
||||
}
|
||||
|
||||
if (linkedMax) {
|
||||
if ($(linkedMax).val()) {
|
||||
options.maxDate = moment($(linkedMax).val(), $(linkedMax).data('dateFormat')).toDate();
|
||||
}
|
||||
|
||||
$(linkedMax).on("dp.change", function (e) {
|
||||
dt.data("DateTimePicker").maxDate(e.date);
|
||||
});
|
||||
}
|
||||
|
||||
if (dt.data('DateTimePicker')) {
|
||||
|
|
|
@ -26,6 +26,10 @@ var filterDropdown = (function() {
|
|||
var $textFilter = $('#textSearchFilterInput', $filterContainer);
|
||||
|
||||
$filterContainer.on('show.bs.dropdown', function() {
|
||||
if (!$(this).hasClass('filters-applied')) {
|
||||
$(this).find('input').val('');
|
||||
}
|
||||
|
||||
let $filterDropdown = $filterContainer.find('.dropdown-menu');
|
||||
let teamId = $filterDropdown.data('team-id');
|
||||
$('#textSearchFilterHistory').find('li').remove();
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
<div class="datetime-picker-container flex">
|
||||
<span class="sn-icon sn-icon-calendar"></span>
|
||||
<input type="datetime"
|
||||
id="<%= "#{container_class}_from" %>"
|
||||
data-linked-max="#<%= "#{container_class}_to" %>"
|
||||
data-toggle='date-time-picker'
|
||||
class="form-control calendar-input from-date"
|
||||
readonly
|
||||
|
@ -19,6 +21,8 @@
|
|||
<span class="sn-icon sn-icon-calendar"></span>
|
||||
<input type="datetime"
|
||||
data-toggle='date-time-picker'
|
||||
id="<%= "#{container_class}_to" %>"
|
||||
data-linked-min="#<%= "#{container_class}_from" %>"
|
||||
class="form-control calendar-input to-date"
|
||||
readonly
|
||||
placeholder="<%= t('filters_modal.to_placeholder') %>"
|
||||
|
|
Loading…
Reference in a new issue