<#-- Retrieves the highest certification level for a given attribute key --> <#-- @param attributeKey The key of the attribute --> <#function getHighestLevelForAttributeKey attributeKey> <#assign maxLevel = 0> <#list referential as AttributeCertificationLevelDto> <#list AttributeCertificationLevelDto.attributeCertificationLevels as attributeCertificationLevel> <#if attributeCertificationLevel.attributeKey == attributeKey && (attributeCertificationLevel.level.level?number gt maxLevel)> <#assign maxLevel = attributeCertificationLevel.level.level?number> <#return maxLevel> <#-- Retrieves the certification level for a given attribute code and attribute key --> <#-- @param code The code of the attribute certification level --> <#-- @param attributeKey The key of the attribute --> <#function getAttributeCertificationLevel code attributeKey> <#list referential as AttributeCertificationLevelDto> <#if AttributeCertificationLevelDto.code == code> <#list AttributeCertificationLevelDto.attributeCertificationLevels as attributeCertificationLevel> <#if attributeCertificationLevel.attributeKey == attributeKey> <#return attributeCertificationLevel.level.level> <#return 0> <#-- Retrieves the attribute code for a given certification level --> <#-- @param level The level of the attribute certification --> <#-- @param attributeKey The key of the attribute --> <#function getAttributeCodeByLevel level attributeKey> <#list referential as AttributeCertificationLevelDto> <#list AttributeCertificationLevelDto.attributeCertificationLevels as attributeCertificationLevel> <#if attributeCertificationLevel.attributeKey == attributeKey && attributeCertificationLevel.level.level == level> <#return AttributeCertificationLevelDto.code> <#return "N/A"> <#-- Retrieves the value of an attribute from a list of attributes --> <#-- @param attrs The list of attributes --> <#-- @param key The key of the attribute --> <#function getAttributeValue attrs key> <#list attrs as attr> <#if attr.key == key> <#if attr.value?exists> <#if attr.value?length == 0 && (key != "address_detail" && key != "preferred_username")> <#return ""> <#elseif key == "gender"> <#switch attr.value> <#case "0"> <#return "N/A"> <#case "1"> <#return "MME"> <#case "2"> <#return "MR"> <#else> <#return attr.value> <#else> <#return ""> <#return ""> <#function isAttributeExists attrs key> <#list attrs as attr> <#if attr.key == key> <#if attr.value?exists> <#return true> <#return false> <#-- Retrieves the certifier pivot badge based on the attributes --> <#-- @param attrs The list of attributes --> <#function getCertifierPivotBadge attrs> <#assign totalAttrs = ["family_name", "first_name", "gender", "birthdate", "birthplace_code", "birthcountry_code"]> <#assign certifierCount = {}> <#assign uncertifiedCount = 0> <#assign totalCertifiedCount = 0> <#list attrs as attr> <#if totalAttrs?seq_contains(attr.key)> <#if attr.certifier??> <#assign totalCertifiedCount = totalCertifiedCount + 1> <#if certifierCount[attr.certifier]??> <#assign temp = certifierCount[attr.certifier]> <#assign temp = temp + 1> <#assign certifierCount = certifierCount + {attr.certifier : temp}> <#else> <#assign certifierCount = certifierCount + {attr.certifier : 1}> <#else> <#assign uncertifiedCount = uncertifiedCount + 1> <#assign result = ""> <#if uncertifiedCount == totalAttrs?size> <#assign result = " Non certifié"> <#elseif totalCertifiedCount == totalAttrs?size> <#if certifierCount?keys?size gt 1> <#assign result = " Mixte"> <#else> <#list certifierCount?keys as certifier> <#assign result = " ${certifier}"> <#elseif totalCertifiedCount gt 0> <#if certifierCount?keys?size gt 1> <#assign result = " Partielle"> <#else> <#list certifierCount?keys as certifier> <#assign result = " Partielle"> <#return result> <#-- Generates data for a chart with attribute certifiers --> <#-- @param attrs The list of attributes --> <#function generateCertifiersDataForChart attrs> <#assign total_attrs = ["family_name", "first_name", "gender", "birthdate", "birthplace_code", "birthcountry_code"]> <#assign certifier_counter = {}> <#list attrs as attr> <#if total_attrs?seq_contains(attr.key)> <#if attr.certifier??> <#if certifier_counter[attr.certifier]??> <#assign temp = certifier_counter[attr.certifier]> <#assign temp = temp + 1> <#assign certifier_counter = certifier_counter + {attr.certifier : temp}> <#else> <#assign certifier_counter = certifier_counter + {attr.certifier : 1}> <#assign labels = "['" + certifier_counter?keys?join("', '") + "']"> <#assign data = "[" + certifier_counter?values?join(", ") + "]"> <#return { 'labels': labels, 'data': data }> <#-- Retrieves the highest level ratio for a given key name and certification code --> <#-- @param keyName The key name of the attribute --> <#-- @param certCode The code of the certification --> <#function highestLevelRatio keyName certCode> <#assign highestLevel = 0> <#assign targetLevel = 0> <#list service_contract.attributeDefinitions as attr> <#list attr.attributeCertifications as certif> <#if certif.level?number gt highestLevel> <#assign highestLevel = certif.level?number> <#if attr.keyName == keyName && certif.code == certCode> <#assign targetLevel = certif.level?number> <#if highestLevel == 0> <#return 0> <#-- avoid division by zero --> <#else> <#return targetLevel / highestLevel> <#-- Retrieves the name of an attribute based on its key name --> <#-- @param keyName The key name of the attribute --> <#function getName keyName > <#assign targetName = ""> <#list service_contract.attributeDefinitions as attr> <#if attr.keyName == keyName> <#assign targetName = "${attr.name}"> <#return targetName> <#macro generateAttributeHtml attr> <#assign isUpdateAllowed = attr.updatable && attr.allowedCertificationList?has_content > <#assign disabled=!isUpdateAllowed> <#if attr.key != 'birthplace_code' && attr.key != 'birthcountry_code'> <#assign certificationFieldName = (attr.key == 'birthplace' || attr.key == 'birthcountry')?then("${attr.key}_code-certif","${attr.key}-certif")> <#assign certifierCode = attr.certifier!''> <#assign certifierFound = false> <#list attr.allowedCertificationList as certif> <#if certif.code == certifierCode> <#assign certifierFound = true> <#assign mandatory = attr.mandatory> <#assign certMandatory><#if mandatory>true<#elseif certifierFound>true<#elseif attr.value??>true<#else>false <#assign noRequiredClass> <#if !mandatory & !certMandatory?boolean>identitydesk-js-rules <#assign class>identitydesk-attribute ${noRequiredClass} <#if attr.key == 'birthplace' & isUpdateAllowed >
<@alert id="birthplace_required_msg" color="primary" iconTitle='arrow-big-up-line' class="d-none my-1" dismissible=false title="Veuillez d'abord saisir le pays de naissance pour modifier le ville de naissance.">
<#if attr.key == 'birthcountry' & isUpdateAllowed >
<@alert id="birthcountry_required_msg" color="primary" iconTitle='arrow-big-up-line' class="d-none my-1" dismissible=false title="Veuillez d'abord saisir la date de naissance pour modifier le pays de naissance.">
<#if attr.key == 'birthplace' & isUpdateAllowed > <@autocomplete id="birthplace" class="identitydesk-attribute" currentValue="${(attr.value)!''}" name="birthplace" suggestionsUrl="${autocomplete_city_endpoint}" searchLabel="${attr.name}" itemValueFieldName="value" itemTitleFieldNames='["displayValue"]' copyFields='[{"inputName":"birthplace_code","resultFieldName":"code"}]' suggestionsPath="result" minimumInputLength=3 additionnalRequestParamInputId="birthdate" formStyle="floating"/>
<@formGroup formStyle="floating" labelFor='${attr.key}' labelKey='${attr.name}' class=class mandatory=mandatory rows=2 > <@input type='text' name="birthplace_external" id="birthplace_external" value="${(attr.value)!''}" />
<#elseif attr.key == 'birthcountry' & isUpdateAllowed> <@autocomplete id="birthcountry" class="identitydesk-attribute" currentValue="${(attr.value)!''}" name="birthcountry" suggestionsUrl="${autocomplete_country_endpoint}" searchLabel="${attr.name}" itemValueFieldName="value" itemTitleFieldNames='["value"]' copyFields='[{"inputName":"birthcountry_code","resultFieldName":"code"}]' suggestionsPath="result" minimumInputLength=3 additionnalRequestParamInputId="birthdate" formStyle="floating"/> <#else> <@formGroup formStyle="floating" labelFor='${attr.key}' labelKey='${attr.name}' class=class mandatory=mandatory rows=2 > <#if attr.key == 'gender'> <@select name='gender' disabled=disabled> <#assign value = "${attr.value!''}"> <#else> <#if attr.key == 'birthdate'> <#if attr.value?has_content> <#assign date_dd_MM_yyyy = formatDate(attr.value)> <@input type='dateHTML5' name="${attr.key}" id="${attr.key}" value=date_dd_MM_yyyy disabled=disabled/> <#else> <@input type='dateHTML5' name="${attr.key}" id="${attr.key}" disabled=disabled/> <#else> <@input type='text' name="${attr.key}" id="${attr.key}" value="${(attr.value)!''}" disabled=disabled/>
<@formGroup formStyle="floating" labelKey="Certification" helpKey='' mandatory=certMandatory?boolean rows=2> <#if attr.allowedCertificationList?has_content> <@select name=certificationFieldName params="data-initial-value=${certifierCode}"> <#if !certifierFound> <#list attr.allowedCertificationList as certif> <#else> <@input type='text' name="${attr.key}" id="${attr.key}" placeHolder="${attr.description}" value="${(attr.certifier)!''}" disabled=disabled/>
<#assign isShowInfo = attribute_info_key_list?seq_contains(attr.key)> <#if isShowInfo >
${attr.description}
<#if certifierCode!="" && !certifierFound>
#i18n{"identitydesk.message.certifier_not_found"} (${certifierCode})
<#if attribute_statuses?size gt 0>
<#list attribute_statuses?filter(s -> s.key == attr.key) as status> <#if status.status.type == 'SUCCESS'> #i18n{${status.messageKey}} <#elseif status.status.type == 'WARNING'> #i18n{${status.messageKey}} <#else> #i18n{${status.messageKey}}
<#else> <@input type="hidden" id="${attr.key}" name="${attr.key}" value="${(attr.value)!''}" /> <#function formatDate inputDate> <#assign parsedDate = inputDate?datetime("dd/MM/yyyy")> <#return parsedDate?string("yyyy-MM-dd")>