Skip to content

Es/tempus dominus #35629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';

Check warning on line 1 in corehq/apps/cloudcare/static/cloudcare/js/form_entry/entries.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'use strict' is unnecessary inside of modules
hqDefine("cloudcare/js/form_entry/entries", [
'jquery',
'knockout',
Expand Down Expand Up @@ -784,6 +784,8 @@
*/
function DateTimeEntryBase(question, options) {
var self = this;
self.templateType = 'datetime';
self.datetimeIconClass = "fcc fcc-fd-datetime";

EntrySingleAnswer.call(self, question, options);

Expand Down Expand Up @@ -818,7 +820,7 @@
DateTimeEntryBase.prototype.serverFormat = undefined;

function DateEntry(question, options) {
this.templateType = 'date';
this.datetimeIconClass = "fa-solid fa-calendar-days";
DateTimeEntryBase.call(this, question, options);
}
DateEntry.prototype = Object.create(DateTimeEntryBase.prototype);
Expand All @@ -831,7 +833,7 @@
};

function TimeEntry(question, options) {
this.templateType = 'time';
this.datetimeIconClass = "fa-regular fa-clock";
if (question.style) {
if (question.stylesContains(constants.TIME_12_HOUR)) {
this.clientFormat = 'h:mm A';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';

Check warning on line 1 in corehq/apps/cloudcare/static/cloudcare/js/formplayer/menus/views/query.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'use strict' is unnecessary inside of modules
hqDefine("cloudcare/js/formplayer/menus/views/query", [
'jquery',
'underscore',
Expand Down Expand Up @@ -267,6 +267,7 @@
errorMessage: this.errorMessage,
itemsetChoicesDict: itemsetChoicesDict,
contentTag: this.parentView.options.sidebarEnabled ? "div" : "td",
cid: this.options.model.cid,
};
},

Expand Down Expand Up @@ -474,7 +475,7 @@
});
cloudcareUtils.initDatePicker(this.ui.date, this.model.get('value'));
this.ui.dateRange.each(function (index, el) {
hqTempusDominus.createDefaultDateRangePicker(el, {
hqTempusDominus.createDefaultDateRangePicker(el.parentNode, {
localization: {
format: dateFormat,
},
Expand Down
4 changes: 2 additions & 2 deletions corehq/apps/cloudcare/static/cloudcare/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';

Check warning on line 1 in corehq/apps/cloudcare/static/cloudcare/js/utils.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'use strict' is unnecessary inside of modules
hqDefine('cloudcare/js/utils', [
'jquery',
'underscore',
Expand Down Expand Up @@ -379,7 +379,7 @@
if (selectedDate) {
options.viewDate = new hqTempusDominus.tempusDominus.DateTime(selectedDate);
}
let picker = hqTempusDominus.createDatePicker($el.get(0), options);
let picker = hqTempusDominus.createDatePicker($el[0].parentNode, options);

$el.attr("placeholder", dateFormat);
$el.attr("pattern", "[0-9\\-\\/]+");
Expand Down Expand Up @@ -410,7 +410,7 @@
if (date.isValid()) {
options.viewDate = new hqTempusDominus.tempusDominus.DateTime(date);
}
return hqTempusDominus.createTimePicker($el.get(0), options);
return hqTempusDominus.createTimePicker($el[0].parentNode, options);
};

var smallScreenIsEnabled = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
{% include 'cloudcare/partials/form_entry/entry_blank.html' %}
{% include 'cloudcare/partials/form_entry/entry_button.html' %}
{% include 'cloudcare/partials/form_entry/entry_choice_label.html' %}
{% include 'cloudcare/partials/form_entry/entry_date.html' %}
{% include 'cloudcare/partials/form_entry/entry_datetime.html' %}
{% include 'cloudcare/partials/form_entry/entry_dropdown.html' %}
{% include 'cloudcare/partials/form_entry/entry_ethiopian_date.html' %}
Expand All @@ -27,7 +26,6 @@
{% include 'cloudcare/partials/form_entry/entry_signature.html' %}
{% include 'cloudcare/partials/form_entry/entry_str.html' %}
{% include 'cloudcare/partials/form_entry/entry_text.html' %}
{% include 'cloudcare/partials/form_entry/entry_time.html' %}
{% include 'cloudcare/partials/form_entry/entry_unsupported.html' %}
{% include 'cloudcare/partials/form_entry/form.html' %}
{% include 'cloudcare/partials/form_entry/form_navigation.html' %}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<script type="text/html" id="datetime-entry-ko-template">
<div class="input-group">
<div
class="input-group"
data-td-target-input="nearest"
data-td-target-toggle="nearest"
>
<input type="text" class="form-control" data-bind="
css: { 'is-invalid': $parent.hasError() },
attr: { id: entryId, 'aria-required': $parent.required() ? 'true' : 'false' },
attr: {id: entryId, 'aria-required': $parent.required() ? 'true' : 'false',},
"/>
<span class="input-group-text"><i class="fcc fcc-fd-datetime"></i></span>
<button
class="btn btn-outline-secondary"
type="button"
data-td-toggle="datetimepicker"
>
<i data-bind="class: datetimeIconClass"></i>
</button>
</div>
</script>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,25 @@
<% } %>
</select>

<% } else if (input === "date") { %>
<div class="input-group">
<% } else if (input === "date" | input === "daterange") { %>
<div class="input-group"
data-td-target-input="nearest"
data-td-target-toggle="nearest"
>
<input id="<%- text ? text : "" %>"
type="text"
class="date query-field form-control<% if (errorMessage) { %> is-invalid<% } %>"
class="<%- input %> query-field form-control<% if (errorMessage) { %> is-invalid<% } %>"
value="<%- value %>"
<% if (required) { %> aria-required="true"<% } %>>
<span class="input-group-text"><i class="fa-solid fa-calendar-days"></i></span>
<% if (required) { %> aria-required="true"<% } %>
>
<button class="btn btn-outline-secondary"
type="button"
data-td-toggle="datetimepicker"
>
<i class="fa-solid fa-calendar-days"></i>
</button>
</div>

<% } else if (input === "daterange") { %>
<input id="<%- text ? text : "" %>"
type="text"
class="daterange query-field form-control<% if (errorMessage) { %> is-invalid<% } %>"
value="<%- value %>"
<% if (required) { %> aria-required="true"<% } %>>

<% } else if (input === "checkbox") { %>
<fieldset multiple
class="query-field<% if (errorMessage) { %> is-invalid<% } %>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";

Check warning on line 1 in corehq/apps/hqwebapp/static/hqwebapp/js/bootstrap5/requirejs_config.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'use strict' is unnecessary inside of modules
requirejs.config({
baseUrl: '/static/',
paths: {
Expand All @@ -20,7 +20,7 @@
"popper": "@popperjs/core/dist/umd/popper.min",
"sentry_browser": "sentry/js/sentry.browser.7.28.0.min",
"sentry_captureconsole": "sentry/js/sentry.captureconsole.7.28.0.min",
"tempusDominus": "@eonasdan/tempus-dominus/dist/js/tempus-dominus.min",
"tempusDominus": "tempus-dominus/js/tempus-dominus",
"underscore": "underscore/underscore",
"nvd3/nv.d3.latest.min": "nvd3-1.8.6/build/nv.d3.min",
"stripe": "https://js.stripe.com/v2/?noext",
Expand Down
9 changes: 8 additions & 1 deletion corehq/apps/hqwebapp/static/hqwebapp/js/tempus_dominus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";

Check warning on line 1 in corehq/apps/hqwebapp/static/hqwebapp/js/tempus_dominus.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

'use strict' is unnecessary inside of modules
/**
* This replaces hqwebapp/js/daterangepicker.config, which is tied to bootstrap3
*
Expand Down Expand Up @@ -61,6 +61,7 @@
let picker = new tempusDominus.TempusDominus(
el, {
dateRange: true,
useCurrent: false,
multipleDatesSeparator: separator,
display: {
theme: 'light',
Expand All @@ -84,9 +85,15 @@
picker.dates.setValue(new tempusDominus.DateTime(end), 1);
}

picker.subscribe("change.td", function () {
// This won't close automatically on single-date ranges
if (picker.dates.picked.length === 2) {
picker.hide();
}
});

// Handle single-date ranges
picker.subscribe("hide.td", function () {
// Handle single-date ranges
if (picker.dates.picked.length === 1) {
picker.dates.setValue(picker.dates.picked[0], 0);
picker.dates.setValue(picker.dates.picked[0], 1);
Expand Down
Loading
Loading