evol: champs optionnels profil et nettoyage templates

This commit is contained in:
Arnaud Delcasse
2026-02-25 17:16:29 +01:00
parent 10b2599f91
commit 67d38ede79
7 changed files with 92 additions and 91 deletions

View File

@@ -89,36 +89,7 @@
<dd class="mt-1 text-sm text-gray-900">{{.ViewState.beneficiary.Data.file_number}}</dd>
</div>
{{end}}
{{if and .ViewState.beneficiary.Data.other_properties .ViewState.beneficiary.Data.other_properties.status}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Statut</dt>
<dd class="mt-1 text-sm text-gray-900">{{.ViewState.beneficiary.Data.other_properties.status}}</dd>
</div>
{{end}}
{{if and .ViewState.beneficiary.Data.other_properties .ViewState.beneficiary.Data.other_properties.situation}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Situation sociale</dt>
<dd class="mt-1 text-sm text-gray-900">{{.ViewState.beneficiary.Data.other_properties.situation}}</dd>
</div>
{{end}}
{{if and .ViewState.beneficiary.Data.other_properties .ViewState.beneficiary.Data.other_properties.subscription_reason}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Motif d'inscription</dt>
<dd class="mt-1 text-sm text-gray-900">{{.ViewState.beneficiary.Data.other_properties.subscription_reason}}</dd>
</div>
{{end}}
{{if and .ViewState.beneficiary.Data.other_properties .ViewState.beneficiary.Data.other_properties.last_subscription_date}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Dernière adhésion</dt>
<dd class="mt-1 text-sm text-gray-900">{{ (timeFrom .ViewState.beneficiary.Data.other_properties.last_subscription_date).Format "02/01/2006" }}</dd>
</div>
{{end}}
{{if and .ViewState.beneficiary.Data.other_properties .ViewState.beneficiary.Data.other_properties.comment}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Commentaire</dt>
<dd class="mt-1 text-sm text-gray-900">{{.ViewState.beneficiary.Data.other_properties.comment}}</dd>
</div>
{{end}}
{{ template "profile_optional_fields_display" dict "other_properties" .ViewState.beneficiary.Data.other_properties "fields" $.ViewState.profile_optional_fields }}
</dl>
</div>
</div>

View File

@@ -7,15 +7,15 @@
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8 mt-8"
x-data="{
fields: {
first_name: '{{ .ViewState.beneficiary.Data.first_name }}',
last_name: '{{ .ViewState.beneficiary.Data.last_name }}',
email: '{{ .ViewState.beneficiary.Data.email }}',
phone_number: '{{ .ViewState.beneficiary.Data.phone_number }}',
birthdate: {{if .ViewState.beneficiary.Data.birthdate}}'{{ (timeFrom .ViewState.beneficiary.Data.birthdate).Format "2006-01-02" }}'{{else}}null{{end}},
file_number: '{{ .ViewState.beneficiary.Data.file_number }}',
gender: {{.ViewState.beneficiary.Data.gender}}
first_name: null,
last_name: null,
email: null,
phone_number: null,
birthdate: null,
file_number: null,
gender: 0
},
other_properties: {{if .ViewState.beneficiary.Data.other_properties}}{{ json .ViewState.beneficiary.Data.other_properties }}{{else}}{}{{end}},
other_properties: {},
other_properties_serialized: null,
rules: {
first_name: ['required'],
@@ -37,6 +37,19 @@
}
},
isFormValid: true,
init() {
const data = window.__PARCOURSMOB_DATA__ || {};
this.fields.first_name = data.first_name || '';
this.fields.last_name = data.last_name || '';
this.fields.email = data.email || '';
this.fields.phone_number = data.phone_number || '';
this.fields.file_number = data.file_number || '';
this.fields.gender = data.gender || 0;
if (data.birthdate) {
this.fields.birthdate = String(data.birthdate).substring(0, 10);
}
this.other_properties = data.other_properties || {};
},
validate() {
this.formValidation = Iodine.assert(this.fields, this.rules)
},