Skip to content

Commit

Permalink
Test setup htmx, with a button on ads detail page to load the faq
Browse files Browse the repository at this point in the history
WIP WIP WIP

One of the issue with htmx that I don't konw how to solve yet is how to
keep data when the form is replaced.

For example, user sets ADS creation date to > 2014, starts filling
fields, then changes the date for < 2014. How to keep the data
previously entered? We don't want to discard everything.
  • Loading branch information
brmzkw committed Apr 12, 2024
1 parent 7adf8a6 commit 860cee4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mesads/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def parse_env_bool(key, default):
"rest_framework.authtoken",
"django_cleanup.apps.CleanupConfig",
"mjml",
"django_htmx",
"mesads.app",
"mesads.users",
"mesads.fradm",
Expand All @@ -129,6 +130,7 @@ def parse_env_bool(key, default):
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware",
"mesads.middleware.BackwardCompatibilityURLMiddleware",
]

Expand Down
2 changes: 2 additions & 0 deletions mesads/templates/webpack/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ $("select[data-autocomplete-light-url]").map((idx, el) =>
);
})
);

import "htmx.org";
9 changes: 9 additions & 0 deletions mesads/templates/webpack/pages/ads_register/ads.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ <h1>
}
</script>
<script src="./ads.ts"></script>


<button hx-get="/faq" hx-swap="outerHTML">
Click Me
</button>




{% endblock %}

{% block endbody %}
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"@gouvfr/dsfr": "^1.5.1",
"alpinejs": "^3.10.3",
"chart.js": "^4.4.0",
"htmx.org": "^1.9.11",
"jquery": "^3.7.0",
"leaflet": "^1.9.3",
"mjml": "^4.13.0"
Expand Down
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ xlsxwriter = "^3.1.2"
openpyxl = "^3.1.2"
unidecode = "^1.3.7"
pyyaml = "^6.0.1"
django-htmx = "^1.17.3"

[tool.poetry.dev-dependencies]
django-debug-toolbar = "^3.2.2"
Expand Down

0 comments on commit 860cee4

Please sign in to comment.