Skip to content

Commit 9610139

Browse files
committed
Merge #19968 - Fix performance of table/create
Pull-request: #19968 Fixes: #19967 Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents fd8c24d + 4040d12 commit 9610139

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

resources/templates/columns_definitions/column_attributes.twig

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,8 @@
6161
</td>
6262
<td class="text-center">
6363
{# column collation #}
64-
<select lang="en" dir="ltr" name="field_collation[{{ column_number }}]" id="field_{{ column_number }}_{{ ci - ci_offset }}" class="form-select">
65-
<option value=""></option>
66-
{% for charset in charsets %}
67-
<optgroup label="{{ charset.name }}" title="{{ charset.description }}">
68-
{% for collation in charset.collations %}
69-
<option value="{{ collation.name }}" title="{{ collation.description }}"
70-
{{- column_meta['Collation'] is defined and collation.name == column_meta['Collation'] ? ' selected' }}>
71-
{{- collation.name -}}
72-
</option>
73-
{% endfor %}
74-
</optgroup>
75-
{% endfor %}
76-
</select>
64+
<select lang="en" dir="ltr" name="field_collation[{{ column_number }}]" id="field_{{ column_number }}_{{ ci - ci_offset }}" class="form-select collation-select"
65+
{{- column_meta['Collation'] is defined ? ('data-selected="' ~ column_meta['Collation'] ~ '"')|raw : '' }}></select>
7766
{% set ci = ci + 1 %}
7867
</td>
7968
<td class="text-center">

resources/templates/columns_definitions/table_fields_definitions.twig

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
<div class="responsivetable">
2+
<template id="collation_select_options">
3+
<option value=""></option>
4+
{% for charset in charsets %}
5+
<optgroup label="{{ charset.name }}" title="{{ charset.description }}">
6+
{% for collation in charset.collations %}
7+
<option value="{{ collation.name }}" title="{{ collation.description }}">
8+
{{- collation.name -}}
9+
</option>
10+
{% endfor %}
11+
</optgroup>
12+
{% endfor %}
13+
</template>
214
<table id="table_columns" class="table table-striped caption-top align-middle mb-0 noclick">
315
<caption>
416
{{ t('Structure') }}
@@ -112,10 +124,24 @@
112124
'attribute_types': attribute_types,
113125
'privs_available': privs_available,
114126
'max_length': max_length,
115-
'charsets': charsets,
116127
'relation_parameters': relation_parameters
117128
}) only %}
118129
</tr>
119130
{% endfor %}
120131
</table>
132+
<script>
133+
function populate_collation_select() {
134+
const select = this;
135+
const selectOptions = document.getElementById('collation_select_options').content.cloneNode(true);
136+
select.appendChild(selectOptions);
137+
const selectedValue = select.dataset.selected;
138+
if (selectedValue) {
139+
select.value = selectedValue;
140+
}
141+
$(select).off('focus', populate_collation_select);
142+
}
143+
144+
$('.collation-select').on('focus', populate_collation_select);
145+
$('.collation-select[data-selected]').each(populate_collation_select);
146+
</script>
121147
</div>

0 commit comments

Comments
 (0)