Skip to content

Commit

Permalink
fix(js): Adjust daterange defaults (#12608)
Browse files Browse the repository at this point in the history
* Set the dateragepicker blank by default
  • Loading branch information
harriebird authored Sep 30, 2024
1 parent 36fadcd commit 5f6dc62
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions weblate/static/loader-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1422,10 +1422,9 @@ $(function () {
$("input[name='period']").daterangepicker(
{
autoApply: false,
startDate:
$("input[name='period']#id_period").attr("data-start-date") || moment(),
endDate:
$("input[name='period']#id_period").attr("data-end-date") || moment(),
autoUpdateInput: false,
startDate: $("input[name='period']#id_period").attr("data-start-date"),
endDate: $("input[name='period']#id_period").attr("data-end-date"),
alwaysShowCalendars: true,
cancelButtonClasses: "btn-warning",
opens: "left",
Expand Down Expand Up @@ -1485,6 +1484,12 @@ $(function () {
(start, end, label) => {},
);

$("input[name='period']").on("apply.daterangepicker", function (ev, picker) {
$(this).val(
`${picker.startDate.format("MM/DD/YYYY")} - ${picker.endDate.format("MM/DD/YYYY")}`,
);
});

$("input[name='period']").on("cancel.daterangepicker", (_ev, picker) => {
picker.element.val("");
});
Expand Down

0 comments on commit 5f6dc62

Please sign in to comment.