Skip to content

Commit

Permalink
Merge pull request #34006 from dimagi/jt/search_input_dd_tag
Browse files Browse the repository at this point in the history
Adds DD tag for Case Search Input
  • Loading branch information
Jtang-1 committed Jan 23, 2024
2 parents f75e099 + 76a412f commit 2becc26
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ hqDefine("cloudcare/js/formplayer/constants", function () {
ENTITIES: "entities",
QUERY: "query",

// values are snake case as recommended for Datadog tags
queryInitiatedBy: {
DYNAMIC_SEARCH: 'dynamic_search',
FIELD_CHANGE: "field_change",
},

SMALL_SCREEN_WIDTH_PX: 992,

BREADCRUMB_HEIGHT_PX: 46.125,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ hqDefine("cloudcare/js/formplayer/menus/api", function () {

var callStartTime = performance.now();
menus.fetch($.extend(true, {}, options)).always(function () {
if (data.query_data && data.query_data.results && data.query_data.results.initiatedBy === "dynamicSearch") {
if (data.query_data && data.query_data.results && data.query_data.results.initiatedBy === constants.queryInitiatedBy.DYNAMIC_SEARCH) {
var callEndTime = performance.now();
var callResponseTime = callEndTime - callStartTime;
$.ajax(initialPageData.reverse('api_histogram_metrics'), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
var kissmetrics = hqImport("analytix/js/kissmetrix"),
cloudcareUtils = hqImport("cloudcare/js/utils"),
markdown = hqImport("cloudcare/js/markdown"),
constants = hqImport("cloudcare/js/form_entry/const"),
formEntryConstants = hqImport("cloudcare/js/form_entry/const"),
formplayerConstants = hqImport("cloudcare/js/formplayer/constants"),
formEntryUtils = hqImport("cloudcare/js/form_entry/utils"),
FormplayerFrontend = hqImport("cloudcare/js/formplayer/app"),
formplayerUtils = hqImport("cloudcare/js/formplayer/utils/utils"),
Expand Down Expand Up @@ -128,7 +129,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
geocoderOnClearCallback = function (addressTopic) {
return function () {
kissmetrics.track.event("Accessibility Tracking - Geocoder Interaction in Case Search");
$.publish(addressTopic, constants.NO_ANSWER);
$.publish(addressTopic, formEntryConstants.NO_ANSWER);
};
},
updateReceiver = function (element) {
Expand All @@ -137,8 +138,8 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
var receiveExpression = element.data().receive;
var receiveField = receiveExpression.split("-")[1];
var value = null;
if (broadcastObj === undefined || broadcastObj === constants.NO_ANSWER) {
value = constants.NO_ANSWER;
if (broadcastObj === undefined || broadcastObj === formEntryConstants.NO_ANSWER) {
value = formEntryConstants.NO_ANSWER;
} else if (broadcastObj[receiveField]) {
value = broadcastObj[receiveField];
} else {
Expand Down Expand Up @@ -400,7 +401,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
// Geocoder doesn't have a real value, doesn't need to be sent to formplayer
return;
}
this.parentView.notifyFieldChange(e, this, useDynamicSearch);
this.parentView.notifyFieldChange(e, this, useDynamicSearch, formplayerConstants.queryInitiatedBy.FIELD_CHANGE);
},

toggleBlankSearch: function (e) {
Expand Down Expand Up @@ -664,10 +665,10 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
return answers;
},

notifyFieldChange: function (e, changedChildView, useDynamicSearch) {
notifyFieldChange: function (e, changedChildView, useDynamicSearch, initiatedBy) {
e.preventDefault();
var self = this;
self.validateFieldChange(changedChildView).always(function (response) {
self.validateFieldChange(changedChildView, initiatedBy).always(function (response) {
var $fields = $(".query-field");
for (var i = 0; i < response.models.length; i++) {
var choices = response.models[i].get('itemsetChoices');
Expand Down Expand Up @@ -742,15 +743,15 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
}
});
if (invalidRequiredFields.length === 0) {
self.performSubmit("dynamicSearch");
self.performSubmit(formplayerConstants.queryInitiatedBy.DYNAMIC_SEARCH);
}
},

validateFieldChange: function (changedChildView) {
validateFieldChange: function (changedChildView, initiatedBy) {
var self = this;
var promise = $.Deferred();

self._updateModelsForValidation().done(function (response) {
self._updateModelsForValidation(initiatedBy).done(function (response) {
//Gather error messages
self._getChildren().forEach(function (childView) {
//Filter out empty required fields and check for validity
Expand Down Expand Up @@ -800,7 +801,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
return promise;
},

_updateModelsForValidation: function () {
_updateModelsForValidation: function (initiatedBy) {
var self = this;
var promise = $.Deferred();
self.updateModelsForValidation = promise;
Expand All @@ -810,7 +811,7 @@ hqDefine("cloudcare/js/formplayer/menus/views/query", function () {
inputs: self.getAnswers(),
execute: false,
forceManualSearch: true,

initiatedBy: initiatedBy,
});
var fetchingPrompts = FormplayerFrontend.getChannel().request("app:select:menus", urlObject);
$.when(fetchingPrompts).done(function (response) {
Expand Down

0 comments on commit 2becc26

Please sign in to comment.