diff --git a/DEV_FAQ.md b/DEV_FAQ.md index 04d8b580c1a9..31519c6e9fad 100644 --- a/DEV_FAQ.md +++ b/DEV_FAQ.md @@ -38,6 +38,11 @@ Formplayer isn't running properly. See [Formplayer](https://github.com/dimagi/co It happens, try restarting. +> I'm getting TemplateSyntaxErrors related to Webpack. + +Please run `yarn dev`. If this build is failing, and you didn't make any changes to JavaScript files on your branch, +please raise this as an issue. + ## Generating Sample Data ### SMS diff --git a/DEV_SETUP.md b/DEV_SETUP.md index 53beb1a16f3b..2b3701ba65bc 100644 --- a/DEV_SETUP.md +++ b/DEV_SETUP.md @@ -762,7 +762,23 @@ This can also be used to promote a user created by signing up to a superuser. Note that promoting a user to superuser status using this command will also give them the ability to assign other users as superuser in the in-app Superuser Management page. -### Step 11: Running CommCare HQ +### Step 11: Running `yarn dev` + +In order to build JavaScript bundles with Webpack, you will need to have `yarn dev` +running in the background. It will watch any existing Webpack Entry Point, aka modules +included on a page using the `webpack_main` template tag. + +When you add a new entry point (`webpack_main` tag), please remember to restart `yarn dev` so +that it can identify the new entry point it needs to watch. + +To build Webpack bundles like it's done in production environments, pleas use `yarn build`. +This command does not have a watch functionality, so it needs to be re-run every time you make +changes to javascript files bundled by Webpack. + +For more information about JavaScript and Static Files, please see the +[Dimagi JavaScript Guide](https://commcare-hq.readthedocs.io/js-guide/README.html) on Read the Docs. + +### Step 12: Running CommCare HQ Make sure the required services are running (PostgreSQL, Redis, CouchDB, Kafka, Elasticsearch). @@ -794,6 +810,9 @@ yarn install --frozen-lockfile ./manage.py fix_less_imports_collectstatic ``` +See the [Dimagi JavaScript Guide](https://commcare-hq.readthedocs.io/js-guide/README.html) for additional +useful background and tips. + ## Running Formplayer and submitting data with Web Apps Formplayer is a Java service that allows us to use applications on the web instead of on a mobile device. diff --git a/corehq/apps/export/static/export/js/bootstrap3/download_data_files.js b/corehq/apps/export/static/export/js/bootstrap3/download_data_files.js deleted file mode 100644 index ccea8464579d..000000000000 --- a/corehq/apps/export/static/export/js/bootstrap3/download_data_files.js +++ /dev/null @@ -1,67 +0,0 @@ -hqDefine("export/js/bootstrap3/download_data_files",[ - 'jquery', - 'hqwebapp/js/bootstrap3/alert_user', - 'hqwebapp/js/initial_page_data', - 'hqwebapp/js/assert_properties', -], function ($, alertUserModule, initialPageData, assertProperties) { - var alertUser = alertUserModule.alert_user; - /** - * Copies the URL of a data file to the clipboard - * - * The function will first attempt to copy the URL to the clipboard without - * any further user interaction. If that fails, the user will be given a - * dialog box with the URL selected, and prompted to press Ctrl-C and Enter. - * - * @param url: The URL to be copied to the clipboard - * @param textareaElem: A hidden - - - {% trans "Available until" %}: {{ data_file.delete_after|to_user_time:request }} - - - - - - - - - - - {% if is_admin %} - - - - {% endif %} - - - {% endfor %} - - - - {% else %} -

{% trans "There are no data files available to download at the moment." %}

- {% endif %} - - {% if is_admin %} -
-
-
-
- {% csrf_token %} -
- {% trans "Upload file for transfer" %} - -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
-
-
- {% endif %} - - {% endblock main_column_content %} -{% endblock %} diff --git a/corehq/apps/export/templates/export/bootstrap5/download_data_files.html b/corehq/apps/export/templates/export/download_data_files.html similarity index 65% rename from corehq/apps/export/templates/export/bootstrap5/download_data_files.html rename to corehq/apps/export/templates/export/download_data_files.html index 666bed49502d..11a11d900aa4 100644 --- a/corehq/apps/export/templates/export/bootstrap5/download_data_files.html +++ b/corehq/apps/export/templates/export/download_data_files.html @@ -6,7 +6,7 @@ {% block title %}{% trans "Download Files" %}{% endblock %} -{% requirejs_main_b5 'export/js/bootstrap5/download_data_files' %} +{% requirejs_main_b5 'export/js/download_data_files' %} {% block page_content %} @@ -29,12 +29,12 @@

{% trans "Download Files" %}

{{ data_file.description }} - {# todo B5: inline style #} + {% trans "Available until" %}: {{ data_file.delete_after|to_user_time:request }} - {# todo B5: inline style #} + {% trans "Download Files" %}
{% trans "Upload file for transfer" %} -
{# todo B5: css:form-group #} -
diff --git a/corehq/apps/export/views/utils.py b/corehq/apps/export/views/utils.py index 9c39a0026513..b2235a292349 100644 --- a/corehq/apps/export/views/utils.py +++ b/corehq/apps/export/views/utils.py @@ -38,6 +38,7 @@ ) from corehq.apps.export.models.new import DataFile, DatePeriod, CaseExportInstance from corehq.apps.export.tasks import generate_schema_for_all_builds, process_populate_export_tables +from corehq.apps.hqwebapp.decorators import use_bootstrap5 from corehq.apps.locations.models import SQLLocation from corehq.apps.locations.permissions import location_safe from corehq.apps.reports.util import datespan_from_beginning @@ -310,9 +311,10 @@ class DashboardFeedPaywall(BaseProjectDataView): @location_safe @method_decorator(login_and_domain_required, name='dispatch') +@method_decorator(use_bootstrap5, name='dispatch') class DataFileDownloadList(BaseProjectDataView): urlname = 'download_data_files' - template_name = 'export/bootstrap3/download_data_files.html' + template_name = 'export/download_data_files.html' page_title = gettext_lazy("Secure File Transfer") def dispatch(self, request, *args, **kwargs): diff --git a/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/export/download_data_files.html.diff.txt b/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/export/download_data_files.html.diff.txt deleted file mode 100644 index e0f67f8b4eac..000000000000 --- a/corehq/apps/hqwebapp/tests/data/bootstrap5_diffs/export/download_data_files.html.diff.txt +++ /dev/null @@ -1,92 +0,0 @@ ---- -+++ -@@ -1,4 +1,4 @@ --{% extends "hqwebapp/bootstrap3/base_section.html" %} -+{% extends "hqwebapp/bootstrap5/base_section.html" %} - {% load hq_shared_tags %} - {% load i18n %} - {% load compress %} -@@ -6,7 +6,7 @@ - {% block title %}{% trans "Download Files" %}{% endblock %} - - --{% requirejs_main 'export/js/bootstrap3/download_data_files' %} -+{% requirejs_main_b5 'export/js/bootstrap5/download_data_files' %} - - - {% block page_content %} -@@ -17,7 +17,7 @@ - - {% if data_files %} -
--
-+
- - {% for data_file in data_files %} - -@@ -29,12 +29,12 @@ - - - --
- {{ data_file.description }} -- -+ {# todo B5: inline style #} - - {% trans "Available until" %}: {{ data_file.delete_after|to_user_time:request }} - -+ {# todo B5: inline style #} - -
--
-+
-
- {% csrf_token %} -
- {% trans "Upload file for transfer" %} - --
--