Skip to content

Commit

Permalink
Updated date and time widgets to display default values
Browse files Browse the repository at this point in the history
  • Loading branch information
orangejenny committed Jun 24, 2024
1 parent 0f3cad3 commit f3da6fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion corehq/apps/cloudcare/static/cloudcare/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ hqDefine('cloudcare/js/utils', [
useCurrent: true,
};
if (date.isValid()) {
options.viewDate = new hqTempusDominus.tempusDominus.DateTime(date.format(timeFormat));
options.viewDate = new hqTempusDominus.tempusDominus.DateTime(date.format(dateFormat + ' ' + timeFormat));
}
hqTempusDominus.createTimePicker($el.get(0), options);
};
Expand Down
10 changes: 8 additions & 2 deletions corehq/apps/hqwebapp/static/hqwebapp/js/tempus_dominus.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ hqDefine("hqwebapp/js/tempus_dominus", [
window.Popper = Popper;

let createDatePicker = function (el, options) {
return new tempusDominus.TempusDominus(el, _addDefaultOptions(options, {
let picker = new tempusDominus.TempusDominus(el, _addDefaultOptions(options, {
display: {
theme: 'light',
components: {
Expand All @@ -31,6 +31,9 @@ hqDefine("hqwebapp/js/tempus_dominus", [
format: 'yyyy-MM-dd',
}),
}));
if (options.viewDate) {
picker.dates.setValue(options.viewDate);
}
};

// This replaces createBootstrap3DefaultDateRangePicker in hqwebapp/js/daterangepicker.config
Expand Down Expand Up @@ -71,7 +74,7 @@ hqDefine("hqwebapp/js/tempus_dominus", [
};

let createTimePicker = function (el, options) {
return new tempusDominus.TempusDominus(el, _addDefaultOptions(options, {
var picker = new tempusDominus.TempusDominus(el, _addDefaultOptions(options, {
display: {
theme: 'light',
components: {
Expand All @@ -83,6 +86,9 @@ hqDefine("hqwebapp/js/tempus_dominus", [
format: 'H:mm',
}),
}));
if (options.viewDate) {
picker.dates.setValue(options.viewDate);
}
};

// Combine user-passed TD options with default options.
Expand Down

0 comments on commit f3da6fb

Please sign in to comment.