diff --git a/subscription/static/bundled/subscription/creation-form-existing-user-index.ts b/subscription/static/bundled/subscription/creation-form-existing-user-index.ts index f582a756..553c2fcc 100644 --- a/subscription/static/bundled/subscription/creation-form-existing-user-index.ts +++ b/subscription/static/bundled/subscription/creation-form-existing-user-index.ts @@ -7,16 +7,15 @@ Alpine.data("existing_user_subscription_form", () => ({ dateOfBirth: "", dateOfBirthHidden: true, - async init() { + init() { this.$watch("selectedUser", async () => { await this.loadProfile(Number.parseInt(this.selectedUser, 10)); }); - // Wait for web components to load - await this.$nextTick(); - - // Force to detect the initial value - this.selectedUser = this.$refs.userSelect.widget.getValue(); + this.$nextTick(() => { + // Force to detect the initial value + this.selectedUser = this.$refs.userSelect.widget.getValue(); + }); }, async loadProfile(userId: number) { diff --git a/subscription/static/subscription/css/subscription.scss b/subscription/static/subscription/css/subscription.scss index 850abc76..561598a2 100644 --- a/subscription/static/subscription/css/subscription.scss +++ b/subscription/static/subscription/css/subscription.scss @@ -5,7 +5,8 @@ margin-top: 0; } - fieldset p:first-of-type, & > p:first-of-type { + fieldset p:first-of-type, + &>p:first-of-type { margin-top: 0; } @@ -24,7 +25,7 @@ fieldset { flex: 0 1 auto; - p:has(input[hidden]) { + .form-group:has(input[hidden]) { // when the input is hidden, hide the whole label+input+help text group display: none; } diff --git a/subscription/templates/subscription/fragments/creation_form_existing_user.jinja b/subscription/templates/subscription/fragments/creation_form_existing_user.jinja index c7dffc16..e6333e98 100644 --- a/subscription/templates/subscription/fragments/creation_form_existing_user.jinja +++ b/subscription/templates/subscription/fragments/creation_form_existing_user.jinja @@ -6,41 +6,29 @@ > {% csrf_token %} - {% set alpine_input_attrs = { - 'id_member': 'x-ref=userSelect,x-model=selectedUser', - 'id_birthdate': ':value=dateOfBirth,:hidden=dateOfBirthHidden', - } %} - - {% set alpine_field_attrs = { - 'id_birthdate': (':hidden=dateOfBirthHidden', 'x-cloack') - } %} - -
+
- {% if form.errors %} - {{ form.errors.__all__ }} - {% endif %} - {% for field in form %} -
- {{ field.label_tag() }} - {{ field|add_attr(alpine_input_attrs.get(field.auto_id, "")) }} - {% if field.help_text %} - {{ field.help_text }} - {% endif %} - {% if field.name == "payment_method" %} - - {% trans trimmed %} - If the subscription is done using the AE account, - you must also click it on the AE counter. - {% endtrans %} - - {% endif %} -
- {% endfor %} + {{ form.non_field_errors() }} +
+ {{ form.member.label_tag() }} + {{ form.member|add_attr("x-ref=userSelect,x-model=selectedUser") }} +
+
+ {{ form.birthdate.label_tag() }} + {{ form.birthdate|add_attr(":value=dateOfBirth,:hidden=dateOfBirthHidden,:type=dateOfBirthHidden ? 'hidden' : 'date'") }} + {{ form.birthdate.help_text }} +
+
{{ form.subscription_type.as_field_group() }}
+
+ {{ form.payment_method.as_field_group() }} + + {% trans trimmed %} + If the subscription is done using the AE account, + you must also click it on the AE counter. + {% endtrans %} + +
+
{{ form.location.as_field_group() }}