From c54be73dd1385b05a150b0dca3e2030b2c78838d Mon Sep 17 00:00:00 2001 From: Matt Riley Date: Fri, 21 Feb 2025 15:25:10 -0500 Subject: [PATCH 01/11] Removed demo form contact fields --- .../analytics/static/analytix/js/cta_forms.js | 73 +------------------ .../analytics/static/analytix/js/hubspot.js | 4 - .../forms/bootstrap3/hubspot_cta_form.html | 57 --------------- 3 files changed, 1 insertion(+), 133 deletions(-) diff --git a/corehq/apps/analytics/static/analytix/js/cta_forms.js b/corehq/apps/analytics/static/analytix/js/cta_forms.js index 7658f14b2c55..431b2e7f138d 100644 --- a/corehq/apps/analytics/static/analytix/js/cta_forms.js +++ b/corehq/apps/analytics/static/analytix/js/cta_forms.js @@ -5,7 +5,6 @@ hqDefine('analytix/js/cta_forms', [ 'underscore', 'hqwebapp/js/initial_page_data', 'hqwebapp/js/assert_properties', - 'intl-tel-input/build/js/intlTelInput.min', 'hqwebapp/js/bootstrap3/validators.ko', // needed for validation of startDate and endDate ], function ( $, @@ -13,26 +12,18 @@ hqDefine('analytix/js/cta_forms', [ _, initialPageData, assertProperties, - intlTelInput, ) { let hubspotCtaForm = function (config) { let self = {}; assertProperties.assertRequired(config, [ 'hubspotFormId', - 'showContactMethod', 'showPreferredLanguage', - 'useWhatsApp', - 'useGoogleHangouts', 'nextButtonText', - 'phoneNumberSelector', 'submitCallbackFn', ]); - self.showContactMethod = ko.observable(config.showContactMethod); self.showPreferredLanguage = ko.observable(config.showPreferredLanguage); - self.useWhatsApp = ko.observable(config.useWhatsApp); - self.useGoogleHangouts = ko.observable(config.useGoogleHangouts); self.nextButtonText = ko.observable(config.nextButtonText); self.firstname = ko.observable() @@ -67,23 +58,6 @@ hqDefine('analytix/js/cta_forms', [ emailRFC2822: true, }); - self.preferred_method_of_contact = ko.observable(); - - self.phone = ko.observable(); - - self.skype__c = ko.observable(); - self.preferred_whatsapp_number = ko.observable(); - - self.showPhoneNumber = ko.computed(function () { - return self.preferred_method_of_contact() === "Phone"; - }); - self.showSkype = ko.computed(function () { - return self.preferred_method_of_contact() === "Skype"; - }); - self.showWhatsApp = ko.computed(function () { - return self.preferred_method_of_contact() === "WhatsApp"; - }); - self.language__c = ko.observable(); self.areMainFieldsValid = ko.computed(function () { @@ -97,25 +71,12 @@ hqDefine('analytix/js/cta_forms', [ }); }); - self.areContactFieldsValid = ko.computed(function () { - if (!self.showContactMethod()) { - return true; - } - if (!self.preferred_method_of_contact()) { - return false; - } - let isWhatsAppValid = self.showWhatsApp() && !!self.preferred_whatsapp_number(), - isPhoneValid = self.showPhoneNumber() && !!self.phone(), - isSkypeValid = self.showSkype() && !!self.skype__c(); - return isWhatsAppValid || isPhoneValid || isSkypeValid; - }); - self.isLanguageFieldValid = ko.computed(function () { return !self.showPreferredLanguage() || !!self.language__c(); }); self.isFormReadyToSubmit = ko.computed(function () { - return self.areContactFieldsValid() && self.areMainFieldsValid() && self.isLanguageFieldValid(); + return self.areMainFieldsValid() && self.isLanguageFieldValid(); }); self.isSubmitDisabled = ko.computed(function () { @@ -127,26 +88,6 @@ hqDefine('analytix/js/cta_forms', [ return !!self.errorMessage(); }); - var phoneNumberWidget = intlTelInput(config.phoneNumberSelector.get(0), { - containerClass: "w-100", - separateDialCode: true, - loadUtils: () => import("intl-tel-input/utils"), - initialCountry: "auto", - geoIpLookup: function (success) { - $.get("https://ipinfo.io", function () {}, "jsonp").always(function (resp) { - var countryCode = (resp && resp.country) ? resp.country : ""; - if (!countryCode) { - countryCode = "us"; - } - success(countryCode); - }); - }, - }); - - self.getFullPhoneNumber = function () { - return phoneNumberWidget.getNumber(); - }; - self.submitForm = function () { let submitData = { hubspot_form_id: config.hubspotFormId, @@ -159,18 +100,6 @@ hqDefine('analytix/js/cta_forms', [ page_url: window.location.href, page_name: document.title, }; - if (self.showContactMethod()) { - submitData.preferred_method_of_contact = self.preferred_method_of_contact(); - } - if (self.showPhoneNumber()) { - submitData.phone = self.phone(); - } - if (self.showWhatsApp()) { - submitData.preferred_whatsapp_number = self.preferred_whatsapp_number(); - } - if (self.showSkype()) { - submitData.skype__c = self.skype__c(); - } if (self.showPreferredLanguage()) { submitData.language__c = self.language__c(); } diff --git a/corehq/apps/analytics/static/analytix/js/hubspot.js b/corehq/apps/analytics/static/analytix/js/hubspot.js index 4a065f2cd07f..6ae6a54ae481 100644 --- a/corehq/apps/analytics/static/analytix/js/hubspot.js +++ b/corehq/apps/analytics/static/analytix/js/hubspot.js @@ -60,12 +60,8 @@ hqDefine('analytix/js/hubspot', [ demoForm = ctaForms.hubspotCtaForm({ hubspotFormId: formId, - showContactMethod: isVariant, showPreferredLanguage: false, - useWhatsApp: false, - useGoogleHangouts: true, nextButtonText: gettext("Submit Request"), - phoneNumberSelector: $form.find('input[name="phone"]'), submitCallbackFn: function () { $('#get-demo-cta-success').fadeIn(); $('#get-demo-cta-form-content').addClass('hidden').addClass('d-none'); // todo after bootstrap 5 migration diff --git a/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html b/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html index d26151000c46..c9d015c906fb 100644 --- a/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html +++ b/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html @@ -58,63 +58,6 @@ class="form-control"> -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
+
From 95510f9c564ef07569d737f964326031c27bdb64 Mon Sep 17 00:00:00 2001 From: Matt Riley Date: Fri, 21 Feb 2025 16:34:31 -0500 Subject: [PATCH 05/11] Added job title demo field --- .../analytics/static/analytix/js/cta_forms.js | 9 +++++ .../forms/bootstrap3/hubspot_cta_form.html | 35 ++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/corehq/apps/analytics/static/analytix/js/cta_forms.js b/corehq/apps/analytics/static/analytix/js/cta_forms.js index 598162ba9797..0b228b8e5e25 100644 --- a/corehq/apps/analytics/static/analytix/js/cta_forms.js +++ b/corehq/apps/analytics/static/analytix/js/cta_forms.js @@ -44,6 +44,13 @@ hqDefine('analytix/js/cta_forms', [ params: true, }, }); + self.jobtitle = ko.observable() + .extend({ + required: { + message: gettext("Please enter your job title."), + params: true, + }, + }); self.email = ko.observable() .extend({ required: { @@ -64,6 +71,7 @@ hqDefine('analytix/js/cta_forms', [ self.firstname, self.lastname, self.company, + self.jobtitle, self.email, ], function (prop) { return prop() !== undefined && prop.isValid(); @@ -97,6 +105,7 @@ hqDefine('analytix/js/cta_forms', [ firstname: self.firstname(), lastname: self.lastname(), company: self.company(), + jobtitle: self.jobtitle(), email: self.email(), preferred_language: self.language(), marketing_purposes___how_did_you_hear_about_us_: self.discoverySource(), diff --git a/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html b/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html index 511b46d9e663..254c5229155e 100644 --- a/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html +++ b/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html @@ -36,15 +36,32 @@
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
From 31e169b67acda320f83b12a708aecb1a3fd33e9f Mon Sep 17 00:00:00 2001 From: Matt Riley Date: Fri, 21 Feb 2025 16:42:38 -0500 Subject: [PATCH 06/11] Move and rephrase demo email --- .../forms/bootstrap3/hubspot_cta_form.html | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html b/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html index 254c5229155e..3b999db7acb8 100644 --- a/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html +++ b/corehq/apps/analytics/templates/analytics/forms/bootstrap3/hubspot_cta_form.html @@ -36,6 +36,17 @@
+
+ +
+ +
+
@@ -64,17 +75,6 @@
-
- -
- -
-
+
@@ -28,10 +30,12 @@ {% trans "Last name" %}*
- +
@@ -41,10 +45,12 @@ {% trans "Professional email" %}*
- +
@@ -54,10 +60,12 @@ {% trans "Organization" %}*
- +
@@ -67,10 +75,12 @@ {% trans "Job title" %}*
- +
@@ -80,9 +90,11 @@ {% trans "Preferred language" %}*
- @@ -94,9 +106,11 @@ - @@ -112,10 +126,12 @@ {% trans "We'd love to hear more! Please specify -" %}
- +
{% blocktrans %} @@ -125,9 +141,11 @@ {% endblocktrans %} diff --git a/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/analytics/forms/hubspot_cta_form.html.diff.txt b/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/analytics/forms/hubspot_cta_form.html.diff.txt index 568b5ada7627..6c8b8e873188 100644 --- a/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/analytics/forms/hubspot_cta_form.html.diff.txt +++ b/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/analytics/forms/hubspot_cta_form.html.diff.txt @@ -8,7 +8,7 @@ {% csrf_token %} @@ -20,10 +20,12 @@ - {% trans "First name" %}* - -
-- +- -
- + -
-- +- -
- -- -- --
-- --
+ - ++ class="form-control">
-
-
+-
+-
+-
+- +-
+- +-
+-
+-
+-
+-
+- +-
+- +-
+-
+-
+
+ --
-- --
++ {% trans "Professional email address" %}* ++ +
--
+-
-