Fix option with RoleWithoutScope distinction. Remove flag.

This commit is contained in:
2023-04-18 21:13:24 +02:00
parent a0d0c3840f
commit 034e2553bc
5 changed files with 39 additions and 14 deletions

View File

@@ -44,13 +44,13 @@
{%- endif -%}
</td>
<td>
<span class="role_scope role">{{ role_scope.role|trans|replace({'(⚑)': ''}) }}</span>
<span class="role_scope role">{{ role_scope.role|trans }}</span>
{% if expanded_roles[role_scope.role]|length > 1 %}
<div class="help-text">
<span style="text-decoration: underline dotted;">{{ 'Which implies'|trans }}&nbsp;:</span>
{% for role in expanded_roles[role_scope.role] %}
{% if role != role_scope.role %}
{{ role|trans|replace({'(⚑)': ''}) }}
{{ role|trans }}
{% if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}
@@ -83,7 +83,7 @@
{{ form_widget(add_role_scopes_form.composed_role_scope.role, { 'attr': { 'class': 'w-50' }}) }}
{{ form_widget(add_role_scopes_form.composed_role_scope.scope) }}
</div>
<div class="help-text mb-3">{{ 'Help to pick role an scope'|trans }}</div>
<div id="role_scope_legend" class="help-text mb-3">{{ 'Help to pick role and scope'|trans }}</div>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
@@ -102,3 +102,26 @@
{% endblock %}
{% block js %}
<script>
// An event listener give contextual legend when choosing an option.
const select = document.getElementById('form_composed_role_scope_role');
const legend = document.getElementById('role_scope_legend');
select.addEventListener('change', function() {
const option = this.options[this.selectedIndex];
const hasScope = option.getAttribute('data-has-scope');
legend.style.display = 'block';
if (hasScope === '0') {
legend.innerText = '{{ 'The role does not need scope'|trans }}';
} else if (hasScope === '1') {
legend.innerText = '{{ 'The role need scope'|trans }}';
} else {
legend.innerText = '{{ 'Help to pick role and scope'|trans }}';
}
});
</script>
{% endblock %}

View File

@@ -37,13 +37,13 @@
{%- endif -%}
</td>
<td>
<span class="role_scope role">{{ role_scope.role|trans|replace({'(⚑)': ''}) }}</span>
<span class="role_scope role">{{ role_scope.role|trans }}</span>
{% if expanded_roles[role_scope.role]|length > 1 %}
<div class="help-text">
<span style="text-decoration: underline dotted;">{{ 'Which implies'|trans }}&nbsp;:</span>
{% for role in expanded_roles[role_scope.role] %}
{% if role != role_scope.role %}
{{ role|trans|replace({'(⚑)': ''}) }}
{{ role|trans }}
{% if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}