From 931dc9d24386e6915f503df4ad5262f5de833bdf Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 18 Aug 2018 08:14:26 +0200 Subject: [PATCH] Reset the date shortcut checkbox on value changes when it's not the shortcut value --- public/viewjs/components/datetimepicker.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/viewjs/components/datetimepicker.js b/public/viewjs/components/datetimepicker.js index 1d7bc286..762d82f1 100644 --- a/public/viewjs/components/datetimepicker.js +++ b/public/viewjs/components/datetimepicker.js @@ -14,6 +14,14 @@ Grocy.Components.DateTimePicker.SetValue = function(value) { Grocy.Components.DateTimePicker.GetInputElement().val(value); Grocy.Components.DateTimePicker.GetInputElement().trigger('change'); + + // "Click" the shortcut checkbox when the desired value is + // not the shortcut value and it is currently set + var shortcutValue = $("#datetimepicker-shortcut").data("datetimepicker-shortcut-value"); + if (value != shortcutValue && $("#datetimepicker-shortcut").is(":checked")) + { + $("#datetimepicker-shortcut").click(); + } } var startDate = null;