diff --git a/changelog.d/1557.changed.md b/changelog.d/1557.changed.md new file mode 100644 index 000000000..50d5dd4e7 --- /dev/null +++ b/changelog.d/1557.changed.md @@ -0,0 +1 @@ +Split user preferences into multiple sections diff --git a/src/argus/htmx/static/styles.css b/src/argus/htmx/static/styles.css index c0a228993..4ad5dc297 100644 --- a/src/argus/htmx/static/styles.css +++ b/src/argus/htmx/static/styles.css @@ -5187,6 +5187,11 @@ details.collapse summary::-webkit-details-marker { margin-bottom: 1rem; } +.mx-auto { + margin-left: auto; + margin-right: auto; +} + .-ml-2 { margin-left: -0.5rem; } @@ -5393,6 +5398,14 @@ details.collapse summary::-webkit-details-marker { max-width: 20rem; } +.max-w-md { + max-width: 28rem; +} + +.max-w-screen-md { + max-width: 768px; +} + .flex-1 { flex: 1 1 0%; } @@ -5656,6 +5669,11 @@ details.collapse summary::-webkit-details-marker { border-style: none; } +.border-base-200 { + --tw-border-opacity: 1; + border-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-border-opacity, 1))); +} + .border-neutral-content { --tw-border-opacity: 1; border-color: var(--fallback-nc,oklch(var(--nc)/var(--tw-border-opacity, 1))); @@ -5801,6 +5819,10 @@ details.collapse summary::-webkit-details-marker { padding: 1.5rem; } +.p-0\.5 { + padding: 0.125rem; +} + .px-1 { padding-left: 0.25rem; padding-right: 0.25rem; @@ -6183,6 +6205,10 @@ details.collapse summary::-webkit-details-marker { .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } + + .lg\:grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } } @media (min-width: 1280px) { diff --git a/src/argus/htmx/templates/htmx/user/preference_form/_base_form.html b/src/argus/htmx/templates/htmx/user/preference_form/_base_form.html new file mode 100644 index 000000000..a06cf49c3 --- /dev/null +++ b/src/argus/htmx/templates/htmx/user/preference_form/_base_form.html @@ -0,0 +1,19 @@ +
+

+ {% block section_title %} + {% endblock section_title %} +

+
+ +
+ + +
+
+
diff --git a/src/argus/htmx/templates/htmx/user/preference_form/_incident_table_form.html b/src/argus/htmx/templates/htmx/user/preference_form/_incident_table_form.html new file mode 100644 index 000000000..315279798 --- /dev/null +++ b/src/argus/htmx/templates/htmx/user/preference_form/_incident_table_form.html @@ -0,0 +1,10 @@ +{% extends "htmx/user/preference_form/_base_form.html" %} +{% block section_id %} + user-settings +{% endblock section_id %} +{% block section_title %} + Incident Table +{% endblock section_title %} +{% block section_forms %} + {% for form in incident_forms %}{{ form }}{% endfor %} +{% endblock section_forms %} diff --git a/src/argus/htmx/templates/htmx/user/preference_form/_preference_form_script.html b/src/argus/htmx/templates/htmx/user/preference_form/_preference_form_script.html new file mode 100644 index 000000000..4fb7e8fa7 --- /dev/null +++ b/src/argus/htmx/templates/htmx/user/preference_form/_preference_form_script.html @@ -0,0 +1,26 @@ + diff --git a/src/argus/htmx/templates/htmx/user/preference_form/_theme_and_format_form.html b/src/argus/htmx/templates/htmx/user/preference_form/_theme_and_format_form.html new file mode 100644 index 000000000..8ebcba682 --- /dev/null +++ b/src/argus/htmx/templates/htmx/user/preference_form/_theme_and_format_form.html @@ -0,0 +1,10 @@ +{% extends "htmx/user/preference_form/_base_form.html" %} +{% block section_id %} + theme-settings +{% endblock section_id %} +{% block section_title %} + Theme and Format +{% endblock section_title %} +{% block section_forms %} + {% for form in theme_forms %}{{ form }}{% endfor %} +{% endblock section_forms %} diff --git a/src/argus/htmx/templates/htmx/user/preferences_list.html b/src/argus/htmx/templates/htmx/user/preferences_list.html index 0f330dfb3..e24bba503 100644 --- a/src/argus/htmx/templates/htmx/user/preferences_list.html +++ b/src/argus/htmx/templates/htmx/user/preferences_list.html @@ -2,13 +2,11 @@ {% extends "htmx/base.html" %} {% block main %}
-

{{ page_title }}

-
- -
+ {% include "htmx/components/_page_title.html" %} + {% block preferences %} + {% include "htmx/user/preference_form/_theme_and_format_form.html" %} + {% include "htmx/user/preference_form/_incident_table_form.html" %} + {% include "htmx/user/preference_form/_preference_form_script.html" %} + {% endblock preferences %}
{% endblock main %} diff --git a/src/argus/htmx/templates/htmx/user/radio_option.html b/src/argus/htmx/templates/htmx/user/radio_option.html index 3e588a4de..d5339d41a 100644 --- a/src/argus/htmx/templates/htmx/user/radio_option.html +++ b/src/argus/htmx/templates/htmx/user/radio_option.html @@ -2,9 +2,7 @@ + autocomplete="off" /> diff --git a/src/argus/htmx/user/views.py b/src/argus/htmx/user/views.py index 998545919..fc21350f7 100644 --- a/src/argus/htmx/user/views.py +++ b/src/argus/htmx/user/views.py @@ -9,15 +9,21 @@ from argus.htmx.user.preferences.utils import setup_preference_forms +THEME_PREFERENCES = ["theme", "datetime_format_name"] + + @require_GET def user_preferences(request) -> HttpResponse: """Renders the main preferences page for a user""" forms = setup_preference_forms(request) + theme_forms = [form for name, form in forms.items() if name in THEME_PREFERENCES] + incident_forms = [form for name, form in forms.items() if name not in THEME_PREFERENCES] context = { "page_title": "User preferences", - "forms": forms, + "theme_forms": theme_forms, + "incident_forms": incident_forms, } return render(request, "htmx/user/preferences_list.html", context=context)