Skip to content
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

Migrate Web Apps to RequireJS #34271

Merged
merged 94 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
4813367
Added requirejs_main and removed unused decorators
orangejenny Oct 2, 2022
879ce59
Updated debugger.js
orangejenny Oct 3, 2022
151e22a
Updated form_entry/const.js
orangejenny Oct 3, 2022
17cc35d
Updated entries.js
orangejenny Oct 3, 2022
a2c64bd
Updated form_entry/errors.js
orangejenny Oct 3, 2022
05201de
Updated form_entry/form_ui.js
orangejenny Oct 3, 2022
bf0f2c2
Updated form_entry/task_queue.js
orangejenny Oct 3, 2022
eb4e060
Updated form_entry/utils.js
orangejenny Oct 3, 2022
d7296bc
Updated form_entry/web_form_session.js
orangejenny Oct 3, 2022
64032bb
Updated formplayer/app.js
orangejenny Oct 3, 2022
e4e6c6f
Updated formplayer/apps/api.js
orangejenny Oct 3, 2022
80b931c
Updated formplayer/apps/collections.js
orangejenny Oct 3, 2022
5f1b12c
Updated formplayer/apps/controller.js
orangejenny Oct 3, 2022
13ada35
Updated formplayer/apps/models.js
orangejenny Oct 3, 2022
417b7c2
Updated apps/views.js
orangejenny Oct 3, 2022
3f6fb3d
Updated constants.js
orangejenny Oct 3, 2022
483ecf5
Updated formplayer/hq_events.js
orangejenny Oct 3, 2022
76b6fe8
Updated formplayer/layout/views/progress_bar.js
orangejenny Oct 3, 2022
6e95811
Updated formplayer/layout/views/settings.js
orangejenny Oct 3, 2022
d50a396
Updated formplayer/main.js
orangejenny Oct 3, 2022
c59446a
Updated formplayer/menus/api.js
orangejenny Oct 3, 2022
679b48a
Updated formplayer/menus/collections.js
orangejenny Oct 3, 2022
7c65cf7
Updated formplayer/menus/controller.js
orangejenny Oct 3, 2022
84de812
Updated formplayer/menus/utils.js
orangejenny Oct 3, 2022
64b0634
Updated formplayer/menus/views.js
orangejenny Oct 3, 2022
97cca47
Updated formplayer/menus/views/query.js
orangejenny Dec 9, 2022
e359914
Updated formplayer/middleware.js
orangejenny Oct 3, 2022
90e4c72
Updated formplayer/router.js
orangejenny Oct 3, 2022
bdded02
Updated formplayer/sessions/api.js
orangejenny Oct 3, 2022
64e8b9b
Updated formplayer/sessions/collections.js
orangejenny Oct 3, 2022
5155cef
Updated sessions/controller.js
orangejenny Oct 3, 2022
b5a4da2
Updated formplayer/sessions/models.js
orangejenny Oct 3, 2022
2b6629b
Updated formplayer/sessions/views.js
orangejenny Oct 3, 2022
05beb0e
Updated formplayer/users/collections.js
orangejenny Oct 3, 2022
d9b284d
Updated formplayer/users/controller.js
orangejenny Oct 3, 2022
a9e3bbe
Updated formplayer/users/models.js
orangejenny Oct 3, 2022
e13bc99
Updated formplayer/users/utils.js
orangejenny Oct 3, 2022
7823784
Updated users/views.js
orangejenny Oct 3, 2022
5412c4e
Updated formplayer/utils/utils.js
orangejenny Oct 3, 2022
abdd207
Updated preview_app/main.js
orangejenny Oct 3, 2022
68d6226
Updated preview_app/preview_app.js
orangejenny Oct 3, 2022
9423151
Updated utils.js
orangejenny Oct 3, 2022
258ff20
Removed most remaining script tags
orangejenny Oct 3, 2022
2406101
Removed HMAC callout dependencies
orangejenny Oct 4, 2022
a9f8b0b
Updated Ethiopian calendar entry
orangejenny Oct 4, 2022
19cf0b6
Removed compress tags
orangejenny Nov 8, 2022
04eb525
Added dependencies for channel requests
orangejenny Dec 13, 2022
3fc9379
Updated app_manager/js/preview_app
orangejenny Dec 26, 2022
18a1f01
Updated app preview to use RequireJS
orangejenny Dec 26, 2022
8615c13
Moved navigate into utils/utils
orangejenny Dec 27, 2022
57ea0a1
Fixed notifications URL error
orangejenny Dec 27, 2022
3b5f59b
Removed appselect channel responses in favor of directly calling apps…
orangejenny Dec 27, 2022
ee00d00
Removed hqRequire from resourceMap response
orangejenny Dec 27, 2022
bf313af
Moved current user dependencies from app.js to users models
orangejenny Jul 4, 2023
38ee37f
Moved HQ events tests to requirejs
orangejenny Jul 4, 2023
9b2bd2b
Added menu_list_test back
orangejenny Jul 4, 2023
d25ea12
Added session_middleware_spec back
orangejenny Jul 4, 2023
92c5d20
Added user_spec back
orangejenny Jul 4, 2023
6a8874d
Added formplayer utils_spec back
orangejenny Jul 4, 2023
beb92fd
Added formplayer integration_spec back
orangejenny Jul 4, 2023
6994776
Restored spec/tils_spec
orangejenny Jan 22, 2024
89b17df
Added query_spec back
orangejenny Jul 4, 2023
ff0a775
Added split_screen_case_search_spec back
orangejenny Jul 4, 2023
c1322f6
Added markdown_spec back
orangejenny Aug 19, 2023
0963ecb
Added menu_utils_spec back
orangejenny Jan 22, 2024
6ea68a3
Added debugger_spec back
orangejenny Jul 4, 2023
5777f79
Added requirejs_main to form entry tests
orangejenny Dec 28, 2022
f851ff9
Restored case_list_pagination_spec
orangejenny Jul 4, 2023
e8550f4
Restored form_entry/spec/utils_spec
orangejenny Dec 28, 2022
daf75bb
Restored form_entry integration_spec
orangejenny Jul 4, 2023
1a9318e
Restored web_form_session_spec
orangejenny Jul 4, 2023
0c0e6a7
Restored form_ui_spec
orangejenny Jul 4, 2023
81ce4aa
Restored entries_spec
orangejenny Jul 4, 2023
68b27f2
Updated display functions to be synchronous again
orangejenny Jan 17, 2023
2e7fd6e
Moved display options functions into users models
orangejenny Jan 17, 2023
095f4b9
Reduced scope of integration tests
orangejenny Jan 17, 2023
7f0fc28
Moved display options tests into users_spec.js
orangejenny Jul 4, 2023
dfe5c21
Switched to uncompressed mapbox
orangejenny Mar 12, 2024
c4d07cf
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Mar 13, 2024
dff2fd1
Replaced recently-introduced hqImport
orangejenny Mar 13, 2024
53b6a98
Updated progress bar dependencies in utils.js
orangejenny Mar 13, 2024
e1bd773
Added wrapShim to requirejs_config
orangejenny Mar 13, 2024
3b6bd7e
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Mar 14, 2024
3460c5b
Removed unused import
orangejenny Mar 14, 2024
615ebbd
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Mar 14, 2024
4bff9f8
Updated CKEDITOR_BASEPATH assignment
orangejenny Mar 18, 2024
1683c4c
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Mar 18, 2024
b5929e3
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Mar 20, 2024
8d277d6
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Mar 20, 2024
d280bb5
Fixed bad merge - toggles is already in the top-level dependencies
orangejenny Mar 20, 2024
32c5a98
Updated hqwebapp/js/atwho dependencies to include Caret
orangejenny Mar 25, 2024
dd654d1
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Apr 3, 2024
6557aa1
Merge branch 'master' into jls/web-apps-requirejs
orangejenny Apr 23, 2024
f4ec1ce
"Bootstrap 5 Migration - Rebuilt diffs"
orangejenny Apr 24, 2024
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
36 changes: 23 additions & 13 deletions corehq/apps/app_manager/static/app_manager/js/preview_app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
"use strict";
hqDefine('app_manager/js/preview_app', function () {
'use strict';
hqDefine('app_manager/js/preview_app', [
'jquery',
'analytix/js/google',
'analytix/js/kissmetrix',
'app_manager/js/app_manager_utils',
'hqwebapp/js/layout',
], function (
$,
googleAnalytics,
kissAnalytics,
appManagerUtils,
layoutController
) {
var module = {};
var _private = {};

Expand Down Expand Up @@ -38,8 +49,8 @@
$(module.SELECTORS.PREVIEW_ACTION_TEXT_HIDE).removeClass('hide');

if (triggerAnalytics) {
hqImport('analytix/js/kissmetrix').track.event("[app-preview] Clicked Show App Preview");
hqImport('analytix/js/google').track.event("App Preview", "Clicked Show App Preview");
kissAnalytics.track.event("[app-preview] Clicked Show App Preview");
googleAnalytics.track.event("App Preview", "Clicked Show App Preview");
}

var $offsetContainer = (_private.isFormdesigner) ? $(module.SELECTORS.FORMDESIGNER) : $(module.SELECTORS.APP_MANAGER_BODY);
Expand All @@ -60,8 +71,8 @@
}

if (triggerAnalytics) {
hqImport('analytix/js/kissmetrix').track.event("[app-preview] Clicked Hide App Preview");
hqImport('analytix/js/google').track.event("App Preview", "Clicked Hide App Preview");
kissAnalytics.track.event("[app-preview] Clicked Hide App Preview");
googleAnalytics.track.event("App Preview", "Clicked Hide App Preview");
}
};

Expand All @@ -72,7 +83,7 @@
_private.triggerPreviewEvent('tablet-view');

if (triggerAnalytics) {
hqImport('analytix/js/kissmetrix').track.event('[app-preview] User turned on tablet mode');
kissAnalytics.track.event('[app-preview] User turned on tablet mode');
}
};

Expand All @@ -83,7 +94,7 @@
_private.triggerPreviewEvent('phone-view');

if (triggerAnalytics) {
hqImport('analytix/js/kissmetrix').track.event('[app-preview] User turned off tablet mode');
kissAnalytics.track.event('[app-preview] User turned off tablet mode');
}
};

Expand Down Expand Up @@ -150,8 +161,7 @@

module.initPreviewWindow = function () {

var layoutController = hqImport("hqwebapp/js/layout"),
$appPreview = $(module.SELECTORS.PREVIEW_WINDOW),
var $appPreview = $(module.SELECTORS.PREVIEW_WINDOW),
$appBody = $(module.SELECTORS.APP_MANAGER_BODY),
$togglePreviewBtn = $(module.SELECTORS.BTN_TOGGLE_PREVIEW),
$iframe = $(module.SELECTORS.PREVIEW_WINDOW_IFRAME),
Expand Down Expand Up @@ -220,10 +230,10 @@
$('.js-preview-refresh').click(function () {
$(module.SELECTORS.BTN_REFRESH).removeClass('app-out-of-date');
_private.triggerPreviewEvent('refresh');
hqImport('analytix/js/kissmetrix').track.event("[app-preview] Clicked Refresh App Preview");
hqImport('analytix/js/google').track.event("App Preview", "Clicked Refresh App Preview");
kissAnalytics.track.event("[app-preview] Clicked Refresh App Preview");
googleAnalytics.track.event("App Preview", "Clicked Refresh App Preview");
});
hqImport("app_manager/js/app_manager_utils").handleAjaxAppChange(function () {
appManagerUtils.handleAjaxAppChange(function () {

Check warning on line 236 in corehq/apps/app_manager/static/app_manager/js/preview_app.js

View workflow job for this annotation

GitHub Actions / Lint Javascript

Expected indentation of 8 spaces but found 12
$(module.SELECTORS.BTN_REFRESH).addClass('app-out-of-date');
});
var onload = function () {
Expand Down
26 changes: 21 additions & 5 deletions corehq/apps/cloudcare/static/cloudcare/js/debugger/debugger.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
'use strict';
/* globals ace, Clipboard */
hqDefine('cloudcare/js/debugger/debugger', function () {
var kissmetrics = hqImport("analytix/js/kissmetrix"),
readableForm = hqImport("reports/js/readable_form");

hqDefine('cloudcare/js/debugger/debugger', [
'jquery',
'knockout',
'underscore',
'clipboard/dist/clipboard',
'ace-builds/src-min-noconflict/ace',
'analytix/js/kissmetrix',
'reports/js/readable_form',
'hqwebapp/js/atwho', // $.atwho
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the comment for documentation? Because I don't understand it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I've gotten in the habit of commenting on dependencies that don't map to a named module, usually because they add a jquery plugin or knockout bindings. Otherwise it's hard to know why a dependency is included and when/if it can be removed. Granted, this one is pretty obvious, it's more helpful for dependencies like jquery ui and hqwebapp knockout_bindings that contain multiple features.

'ace-builds/src-min-noconflict/mode-json',
'ace-builds/src-min-noconflict/mode-xml',
'ace-builds/src-min-noconflict/ext-searchbox',
], function (
$,
ko,
_,
Clipboard,
ace,
kissmetrics,
readableForm
) {
/**
* These define tabs that are availabe in the debugger.
* {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
hqDefine("cloudcare/js/form_entry/const", function () {
hqDefine("cloudcare/js/form_entry/const", [], function () {
return {
GROUP_TYPE: 'sub-group',
REPEAT_TYPE: 'repeat-juncture',
Expand Down
44 changes: 34 additions & 10 deletions corehq/apps/cloudcare/static/cloudcare/js/form_entry/entries.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
'use strict';
/* globals moment, SignaturePad, DOMPurify */
hqDefine("cloudcare/js/form_entry/entries", function () {
var kissmetrics = hqImport("analytix/js/kissmetrix"),
cloudcareUtils = hqImport("cloudcare/js/utils"),
constants = hqImport("cloudcare/js/form_entry/const"),
formEntryUtils = hqImport("cloudcare/js/form_entry/utils"),
initialPageData = hqImport("hqwebapp/js/initial_page_data"),
toggles = hqImport("hqwebapp/js/toggles");

hqDefine("cloudcare/js/form_entry/entries", [
'jquery',
'knockout',
'underscore',
'DOMPurify/dist/purify.min',
'moment',
'fast-levenshtein/levenshtein',
'hqwebapp/js/initial_page_data',
'hqwebapp/js/toggles',
'analytix/js/kissmetrix',
'cloudcare/js/utils',
'cloudcare/js/form_entry/const',
'cloudcare/js/form_entry/utils',
'signature_pad/dist/signature_pad.umd.min',
'mapbox.js/dist/mapbox.uncompressed',
'cloudcare/js/formplayer/utils/calendar-picker-translations', // EthiopianDateEntry
'select2/dist/js/select2.full.min',
], function (
$,
ko,
_,
DOMPurify,
moment,
Levenshtein,
initialPageData,
toggles,
kissmetrics,
cloudcareUtils,
constants,
formEntryUtils,
SignaturePad,
L
) {
/**
* The base Object for all entries. Each entry takes a question object
* @param {Object} question - A question object
Expand Down Expand Up @@ -677,7 +701,7 @@ hqDefine("cloudcare/js/form_entry/entries", function () {
var isFuzzyMatch = function (haystack, query, distanceThreshold) {
return (
haystack === query ||
(query.length > 3 && window.Levenshtein.get(haystack, query) <= distanceThreshold)
(query.length > 3 && Levenshtein.get(haystack, query) <= distanceThreshold)
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
hqDefine("cloudcare/js/form_entry/errors", function () {
hqDefine("cloudcare/js/form_entry/errors", [], function () {
return {
GENERIC_ERROR: gettext("Something unexpected went wrong on that request. " +
"If you have problems filling in the rest of your form please submit an issue. " +
Expand Down
32 changes: 25 additions & 7 deletions corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
'use strict';
/* global DOMPurify */
hqDefine("cloudcare/js/form_entry/form_ui", function () {
var markdown = hqImport("cloudcare/js/markdown"),
constants = hqImport("cloudcare/js/form_entry/const"),
entries = hqImport("cloudcare/js/form_entry/entries"),
formEntryUtils = hqImport("cloudcare/js/form_entry/utils");
hqDefine("cloudcare/js/form_entry/form_ui", [
'jquery',
'knockout',
'underscore',
'DOMPurify/dist/purify.min',
'hqwebapp/js/toggles',
'cloudcare/js/markdown',
'cloudcare/js/utils',
'cloudcare/js/form_entry/const',
'cloudcare/js/form_entry/entries',
'cloudcare/js/form_entry/utils',
'jquery-tiny-pubsub/dist/ba-tiny-pubsub', // $.pubsub
], function (
$,
ko,
_,
DOMPurify,
toggles,
markdown,
cloudcareUtils,
constants,
entries,
formEntryUtils
) {
var groupNum = 0;

_.delay(function () {
Expand Down Expand Up @@ -391,7 +409,7 @@ hqDefine("cloudcare/js/form_entry/form_ui", function () {
self.blockSubmit = ko.observable(false);
self.hasSubmitAttempted = ko.observable(false);
self.isSubmitting = ko.observable(false);
self.isAnchoredSubmitStyle = hqImport('hqwebapp/js/toggles').toggleEnabled('WEB_APPS_ANCHORED_SUBMIT');
self.isAnchoredSubmitStyle = toggles.toggleEnabled('WEB_APPS_ANCHORED_SUBMIT');
self.submitClass = constants.FULL_WIDTH + ' text-center' +
(self.isAnchoredSubmitStyle ? ' anchored-submit' : ' nonanchored-submit');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
'use strict';
/* eslint-env mocha */
/* globals moment */
hqDefine("cloudcare/js/form_entry/spec/entries_spec", function () {
hqDefine("cloudcare/js/form_entry/spec/entries_spec", [
"underscore",
"sinon/pkg/sinon",
"moment",
"hqwebapp/js/initial_page_data",
"cloudcare/js/form_entry/const",
"cloudcare/js/form_entry/entries",
"cloudcare/js/form_entry/form_ui",
"cloudcare/js/utils",
], function (
_,
sinon,
moment,
initialPageData,
constants,
entries,
formUI,
utils
) {
describe('Entries', function () {
var constants = hqImport("cloudcare/js/form_entry/const"),
entries = hqImport("cloudcare/js/form_entry/entries"),
formUI = hqImport("cloudcare/js/form_entry/form_ui"),
utils = hqImport("cloudcare/js/utils"),
questionJSON,
var questionJSON,
spy;

before(function () {
hqImport("hqwebapp/js/initial_page_data").register(
initialPageData.register(
"has_geocoder_privs",
true
);
hqImport("hqwebapp/js/initial_page_data").register(
initialPageData.register(
"toggles_dict",
{
WEB_APPS_UPLOAD_QUESTIONS: true,
Expand All @@ -25,7 +38,7 @@ hqDefine("cloudcare/js/form_entry/spec/entries_spec", function () {
});

after(function () {
hqImport("hqwebapp/js/initial_page_data").unregister("toggles_dict");
initialPageData.unregister("toggles_dict");
});

beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';
hqDefine("cloudcare/js/form_entry/spec/fixtures", function () {
hqDefine("cloudcare/js/form_entry/spec/fixtures", [
"underscore",
], function (
_
) {
return {
textJSON: (options = {}) => (_.defaults(options, {
"caption_audio": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
'use strict';
/* eslint-env mocha */
hqDefine("cloudcare/js/form_entry/spec/form_ui_spec", function () {
hqDefine("cloudcare/js/form_entry/spec/form_ui_spec", [
"underscore",
"sinon/pkg/sinon",
"hqwebapp/js/initial_page_data",
"cloudcare/js/form_entry/const",
"cloudcare/js/form_entry/form_ui",
"cloudcare/js/form_entry/spec/fixtures",
], function (
_,
sinon,
initialPageData,
constants,
formUI,
fixtures
) {
describe('Fullform formUI', function () {
var constants = hqImport("cloudcare/js/form_entry/const"),
formUI = hqImport("cloudcare/js/form_entry/form_ui"),
fixtures = hqImport("cloudcare/js/form_entry/spec/fixtures"),
questionJSON,
var questionJSON,
formJSON,
groupJSON,
noQuestionGroupJSON,
Expand All @@ -15,7 +26,7 @@ hqDefine("cloudcare/js/form_entry/spec/form_ui_spec", function () {
repeatNestJSON;

before(function () {
hqImport("hqwebapp/js/initial_page_data").register(
initialPageData.register(
"toggles_dict",
{
WEB_APPS_UPLOAD_QUESTIONS: true,
Expand All @@ -25,7 +36,7 @@ hqDefine("cloudcare/js/form_entry/spec/form_ui_spec", function () {
});

after(function () {
hqImport("hqwebapp/js/initial_page_data").unregister("toggles_dict");
initialPageData.unregister("toggles_dict");
});

beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
'use strict';
/* eslint-env mocha */
hqDefine("cloudcare/js/form_entry/spec/integration_spec", function () {
hqDefine("cloudcare/js/form_entry/spec/integration_spec", [
"underscore",
"hqwebapp/js/initial_page_data",
"sinon/pkg/sinon",
"cloudcare/js/form_entry/const",
"cloudcare/js/form_entry/form_ui",
], function (
_,
initialPageData,
sinon,
constants,
formUI
) {
describe('Integration', function () {
var constants = hqImport("cloudcare/js/form_entry/const"),
formUI = hqImport("cloudcare/js/form_entry/form_ui"),
formJSON,
var formJSON,
questionJSONMulti,
questionJSONString;

before(function () {
hqImport("hqwebapp/js/initial_page_data").register("toggles_dict", { WEB_APPS_ANCHORED_SUBMIT: false });
initialPageData.register("toggles_dict", { WEB_APPS_ANCHORED_SUBMIT: false });
});

after(function () {
hqImport("hqwebapp/js/initial_page_data").unregister("toggles_dict");
initialPageData.unregister("toggles_dict");
});

beforeEach(function () {
Expand Down Expand Up @@ -74,7 +84,6 @@ hqDefine("cloudcare/js/form_entry/spec/integration_spec", function () {
this.clock.restore();
});


it('Should reconcile questions answered at the same time for strings', function () {
var questionJSONString2 = {};
$.extend(questionJSONString2, questionJSONString);
Expand Down
Loading
Loading