Merge pull request #128 from Ann2827/pull

Fix bugs on error.ftl template
This commit is contained in:
Joseph Garrone 2022-07-03 15:52:42 +02:00 committed by GitHub
commit 30315027c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,50 +30,66 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
</#attempt> </#attempt>
"printIfExists": function (fieldName, x) { "printIfExists": function (fieldName, x) {
<#list fieldNames as fieldName> <#if messagesPerField?? >
if(fieldName === "${fieldName}" ){ <#list fieldNames as fieldName>
<#attempt> if(fieldName === "${fieldName}" ){
return "${messagesPerField.printIfExists(fieldName,'1')}" ? x : undefined; <#attempt>
<#recover> return "${messagesPerField.printIfExists(fieldName,'1')}" ? x : undefined;
</#attempt> <#recover>
} </#attempt>
</#list> }
throw new Error("There is no " + fieldName + " field"); </#list>
throw new Error("There is no " + fieldName + " field");
<#else>
return undefined;
</#if>
}, },
"existsError": function (fieldName) { "existsError": function (fieldName) {
<#list fieldNames as fieldName> <#if messagesPerField?? >
if(fieldName === "${fieldName}" ){ <#list fieldNames as fieldName>
<#attempt> if(fieldName === "${fieldName}" ){
return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>; <#attempt>
<#recover> return <#if messagesPerField.existsError('${fieldName}')>true<#else>false</#if>;
</#attempt> <#recover>
} </#attempt>
</#list> }
throw new Error("There is no " + fieldName + " field"); </#list>
throw new Error("There is no " + fieldName + " field");
<#else>
return false;
</#if>
}, },
"get": function (fieldName) { "get": function (fieldName) {
<#list fieldNames as fieldName> <#if messagesPerField?? >
if(fieldName === "${fieldName}" ){ <#list fieldNames as fieldName>
<#attempt> if(fieldName === "${fieldName}" ){
<#if messagesPerField.existsError('${fieldName}')> <#attempt>
return "${messagesPerField.get('${fieldName}')?no_esc}"; <#if messagesPerField.existsError('${fieldName}')>
</#if> return "${messagesPerField.get('${fieldName}')?no_esc}";
<#recover> </#if>
</#attempt> <#recover>
} </#attempt>
</#list> }
throw new Error("There is no " + fieldName + " field"); </#list>
throw new Error("There is no " + fieldName + " field");
<#else>
return '';
</#if>
}, },
"exists": function (fieldName) { "exists": function (fieldName) {
<#list fieldNames as fieldName> <#if messagesPerField?? >
if(fieldName === "${fieldName}" ){ <#list fieldNames as fieldName>
<#attempt> if(fieldName === "${fieldName}" ){
return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>; <#attempt>
<#recover> return <#if messagesPerField.exists('${fieldName}')>true<#else>false</#if>;
</#attempt> <#recover>
} </#attempt>
</#list> }
throw new Error("There is no " + fieldName + " field"); </#list>
throw new Error("There is no " + fieldName + " field");
<#else>
return false;
</#if>
} }
}; };
@ -137,6 +153,9 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc};
key == "identityProviderBrokerCtx" && key == "identityProviderBrokerCtx" &&
are_same_path(path, []) && are_same_path(path, []) &&
["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId) ["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId)
) || (
["masterAdminClient", "delegateForUpdate", "defaultRole"]?seq_contains(key) &&
are_same_path(path, ["realm"])
) )
> >
<#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]> <#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]>