Skip to content

Commit d19eb01

Browse files
committed
use input replace button
1 parent 1e07214 commit d19eb01

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

adminlteui/templates/adminlte/date_range_filter.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
{% get_current_language as LANGUAGE_CODE %}
33

44
<div class="form-group" style="margin-bottom: 5px;">
5-
<button id="id_filter_{{ field_name }}" type="button" class="btn btn-default pull-right">
6-
<i class="fa fa-calendar"></i><span> {{ title }} </span><i class="fa fa-caret-down"></i>
7-
</button>
8-
<input id="id_filter_{{ field_name }}__gte" hidden type="text">
9-
<input id="id_filter_{{ field_name }}__lte" hidden type="text">
5+
<div class="input-group">
6+
<div class="input-group-addon">
7+
<i class="fa fa-calendar"></i>
8+
</div>
9+
<input type="text" class="form-control pull-right" id="id_filter_{{ field_name }}" value="{{ title }}">
10+
<input id="id_filter_{{ field_name }}__gte" hidden type="text">
11+
<input id="id_filter_{{ field_name }}__lte" hidden type="text">
12+
</div>
1013

1114
<script>
1215
$(document).ready(function () {
@@ -35,21 +38,19 @@
3538
'{% trans "This Month" %}' : [moment().startOf('month'), moment().endOf('month')],
3639
'{% trans "Last Month" %}' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
3740
},
38-
startDate: moment().subtract(29, 'days'),
39-
endDate : moment()
4041
},
4142
function (start, end) {
42-
$drp_input.find('span').html(' ' + start.format('{{ choices.0.date_format }}') + ' - ' + end.format('{{ choices.0.date_format }}') + ' ')
43+
$drp_input.val(start.format('{{ choices.0.date_format }}') + ' - ' + end.format('{{ choices.0.date_format }}'))
4344
}
4445
);
4546
// act on date range selection via widget
4647
$drp_input.on('apply.daterangepicker', function(ev, picker) {
47-
$drp_input.find('span').html(' ' + picker.startDate.format('{{ choices.0.date_format }}') + ' - ' + picker.endDate.format('{{ choices.0.date_format }}') + ' ')
48+
$drp_input.val(picker.startDate.format('{{ choices.0.date_format }}') + ' - ' + picker.endDate.format('{{ choices.0.date_format }}'))
4849
$('#id_filter_{{ field_name }}__gte').attr('name', '{{ field_name }}__gte').val(picker.startDate.format('YYYY-MM-DD'));
4950
$('#id_filter_{{ field_name }}__lte').attr('name', '{{ field_name }}__lte').val(picker.endDate.format('YYYY-MM-DD'));
5051
});
5152
$drp_input.on('cancel.daterangepicker', function(ev, picker) {
52-
$drp_input.find('span').html('{{ title }}' + ' ')
53+
$drp_input.val('{{ title }}')
5354
$('#id_filter_{{ field_name }}__gte').attr('name', '').val('');
5455
$('#id_filter_{{ field_name }}__lte').attr('name', '').val('');
5556
});
@@ -63,8 +64,10 @@
6364
picker.setEndDate(moment(vals[1], 'YYYY-MM-DD'));
6465
$('#id_filter_{{ field_name }}__gte').attr('name', '{{ field_name }}__gte').val(vals[0]);
6566
$('#id_filter_{{ field_name }}__lte').attr('name', '{{ field_name }}__lte').val(vals[1]);
66-
$drp_input.find('span').html(' ' + (moment(vals[0], 'YYYY-MM-DD').format('{{ choices.0.date_format }}') + ' - ' + moment(vals[1], 'YYYY-MM-DD').format('{{ choices.0.date_format }}') + ' '));
67+
$drp_input.val(moment(vals[0], 'YYYY-MM-DD').format('{{ choices.0.date_format }}') + ' - ' + moment(vals[1], 'YYYY-MM-DD').format('{{ choices.0.date_format }}'));
6768
}
69+
} else {
70+
$drp_input.val('{{ title }}')
6871
}
6972
});
7073
</script>

0 commit comments

Comments
 (0)