Apply review comments

This commit is contained in:
2026-05-10 13:02:13 +02:00
parent 2d86ba67f4
commit 5551fdc953
3 changed files with 30 additions and 42 deletions
@@ -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) {
@@ -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;
}
@@ -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')
} %}
<div x-data="existing_user_subscription_form()" class="form-content existing-user">
<div x-data="existing_user_subscription_form" class="form-content existing-user">
<fieldset>
{% if form.errors %}
{{ form.errors.__all__ }}
{% endif %}
{% for field in form %}
<div
class="form-group"
{% for attr in alpine_field_attrs.get(field.auto_id, []) %}
{{ attr }}
{% endfor %}>
{{ field.label_tag() }}
{{ field|add_attr(alpine_input_attrs.get(field.auto_id, "")) }}
{% if field.help_text %}
<span class="helptext">{{ field.help_text }}</span>
{% endif %}
{% if field.name == "payment_method" %}
<i>
{% trans trimmed %}
If the subscription is done using the AE account,
you must also click it on the AE counter.
{% endtrans %}
</i>
{% endif %}
</div>
{% endfor %}
{{ form.non_field_errors() }}
<div class="form-group">
{{ form.member.label_tag() }}
{{ form.member|add_attr("x-ref=userSelect,x-model=selectedUser") }}
</div>
<div class="form-group">
{{ form.birthdate.label_tag() }}
{{ form.birthdate|add_attr(":value=dateOfBirth,:hidden=dateOfBirthHidden,:type=dateOfBirthHidden ? 'hidden' : 'date'") }}
<span class="helptext">{{ form.birthdate.help_text }}</span>
</div>
<div class="form-group">{{ form.subscription_type.as_field_group() }}</div>
<div class="form-group">
{{ form.payment_method.as_field_group() }}
<i>
{% trans trimmed %}
If the subscription is done using the AE account,
you must also click it on the AE counter.
{% endtrans %}
</i>
</div>
<div class="form-group">{{ form.location.as_field_group() }}</div>
</fieldset>
<div
id="subscription-form-user-mini-profile"