Skip to content

Commit 6f0843f

Browse files
committed
feature #1338 [Autocomplete] Support the render.loading_more Tom Select option (vgaret)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Autocomplete] Support the `render.loading_more` Tom Select option | Q | A | | ------------ | --------- | | Bug fix? | no | | New feature? | yes | | Issues | Fix #1159 | | License | MIT | Here is my proposal for the support of the `render.loading_more` option from the Virtual Scroll plugin of Tom Select ([docs](https://tom-select.js.org/plugins/virtual_scroll/)). I also suggested a French translation, as it is my main language. NB: I have slightly modified the default value ("Loading more results ... " ➡️ "Loading more results..."). Commits ------- c1ce573 [Autocomplete] Support the `render.loading_more` Tom Select option
2 parents 1db29a3 + c1ce573 commit 6f0843f

38 files changed

+53
-0
lines changed

src/Autocomplete/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## Unreleased
4+
5+
- Add support for the `render.loading_more` Tom Select Virtual Scroll option (`loading_more_text`)
6+
37
## 2.13.2
48

59
- Revert "Change JavaScript package to `type: module`"

src/Autocomplete/assets/dist/controller.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class extends Controller {
1212
static values: {
1313
url: StringConstructor;
1414
optionsAsHtml: BooleanConstructor;
15+
loadingMoreText: StringConstructor;
1516
noResultsFoundText: StringConstructor;
1617
noMoreResultsText: StringConstructor;
1718
minCharacters: NumberConstructor;
@@ -20,6 +21,7 @@ export default class extends Controller {
2021
};
2122
readonly urlValue: string;
2223
readonly optionsAsHtmlValue: boolean;
24+
readonly loadingMoreTextValue: string;
2325
readonly noMoreResultsTextValue: string;
2426
readonly noResultsFoundTextValue: string;
2527
readonly minCharactersValue: number;

src/Autocomplete/assets/dist/controller.js

+4
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
317317
item: function (item) {
318318
return `<div>${item.text}</div>`;
319319
},
320+
loading_more: () => {
321+
return `<div class="loading-more-results">${this.loadingMoreTextValue}</div>`;
322+
},
320323
no_more_results: () => {
321324
return `<div class="no-more-results">${this.noMoreResultsTextValue}</div>`;
322325
},
@@ -342,6 +345,7 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
342345
default_1.values = {
343346
url: String,
344347
optionsAsHtml: Boolean,
348+
loadingMoreText: String,
345349
noResultsFoundText: String,
346350
noMoreResultsText: String,
347351
minCharacters: Number,

src/Autocomplete/assets/src/controller.ts

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class extends Controller {
1515
static values = {
1616
url: String,
1717
optionsAsHtml: Boolean,
18+
loadingMoreText: String,
1819
noResultsFoundText: String,
1920
noMoreResultsText: String,
2021
minCharacters: Number,
@@ -24,6 +25,7 @@ export default class extends Controller {
2425

2526
declare readonly urlValue: string;
2627
declare readonly optionsAsHtmlValue: boolean;
28+
declare readonly loadingMoreTextValue: string;
2729
declare readonly noMoreResultsTextValue: string;
2830
declare readonly noResultsFoundTextValue: string;
2931
declare readonly minCharactersValue: number;
@@ -224,6 +226,9 @@ export default class extends Controller {
224226
item: function (item: any) {
225227
return `<div>${item.text}</div>`;
226228
},
229+
loading_more: (): string => {
230+
return `<div class="loading-more-results">${this.loadingMoreTextValue}</div>`;
231+
},
227232
no_more_results: (): string => {
228233
return `<div class="no-more-results">${this.noMoreResultsTextValue}</div>`;
229234
},

src/Autocomplete/doc/index.rst

+4
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ e.g. ``FoodAutocompleteField`` from above):
213213
an autocomplete-Ajax endpoint (e.g. for a custom ``ChoiceType``), then set this
214214
to change the field into an AJAX-powered select.
215215

216+
``loading_more_text`` (default: 'Loading more results...')
217+
Rendered at the bottom of the list while fetching more results. This message is
218+
automatically translated using the ``AutocompleteBundle`` domain.
219+
216220
``no_results_found_text`` (default: 'No results found')
217221
Rendered when no matching results are found. This message is automatically translated
218222
using the ``AutocompleteBundle`` domain.

src/Autocomplete/src/Form/AutocompleteChoiceTypeExtension.php

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function finishView(FormView $view, FormInterface $form, array $options):
7979
$values['min-characters'] = $options['min_characters'];
8080
}
8181

82+
$values['loading-more-text'] = $this->trans($options['loading_more_text']);
8283
$values['no-results-found-text'] = $this->trans($options['no_results_found_text']);
8384
$values['no-more-results-text'] = $this->trans($options['no_more_results_text']);
8485
$values['preload'] = $options['preload'];
@@ -99,6 +100,7 @@ public function configureOptions(OptionsResolver $resolver): void
99100
'tom_select_options' => [],
100101
'options_as_html' => false,
101102
'allow_options_create' => false,
103+
'loading_more_text' => 'Loading more results...',
102104
'no_results_found_text' => 'No results found',
103105
'no_more_results_text' => 'No more results',
104106
'min_characters' => null,

src/Autocomplete/translations/AutocompleteBundle.ar.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'لم يتم العثور على أي نتائج',
1415
'No more results' => 'لا توجد نتائج أٌخرى',
1516
];

src/Autocomplete/translations/AutocompleteBundle.bg.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Няма намерени съвпадения',
1415
'No more results' => 'Няма повече резултати',
1516
];

src/Autocomplete/translations/AutocompleteBundle.ca.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'No s\'han trobat resultats',
1415
'No more results' => 'No hi ha més resultats',
1516
];

src/Autocomplete/translations/AutocompleteBundle.cs.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Nenalezeny žádné položky',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.da.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Ingen resultater fundet',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.de.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Keine Übereinstimmungen gefunden',
1415
'No more results' => 'Keine weiteren Ergebnisse',
1516
];

src/Autocomplete/translations/AutocompleteBundle.el.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Δεν βρέθηκαν αποτελέσματα',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.en.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'No results found',
1415
'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.es.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'No se han encontrado resultados',
1415
'No more results' => 'No hay más resultados',
1516
];

src/Autocomplete/translations/AutocompleteBundle.eu.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Ez da bat datorrenik aurkitu',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.fa.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'هیچ نتیجه‌ای یافت نشد',
1415
'No more results' => 'نتیجه دیگری وجود ندارد',
1516
];

src/Autocomplete/translations/AutocompleteBundle.fi.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Ei tuloksia',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.fr.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
'Loading more results...' => 'Chargement d\'autres résultats...',
1314
'No results found' => 'Aucun résultat trouvé',
1415
'No more results' => 'Aucun autre résultat trouvé',
1516
];

src/Autocomplete/translations/AutocompleteBundle.gl.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Non se atoparon resultados',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.hr.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Nema rezultata',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.hu.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
'Loading more results...' => 'További találatok betöltése...',
1314
'No results found' => 'Nincs találat',
1415
'No more results' => 'Nincs több találat',
1516
];

src/Autocomplete/translations/AutocompleteBundle.id.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Tidak ada hasil yang ditemukan',
1415
'No more results' => 'Tidak ada hasil lagi',
1516
];

src/Autocomplete/translations/AutocompleteBundle.it.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Nessun risultato trovato',
1415
'No more results' => 'Non ci sono altri risultati',
1516
];

src/Autocomplete/translations/AutocompleteBundle.lb.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Keng Resultater fonnt',
1415
'No more results' => 'Keng weider Resultater',
1516
];

src/Autocomplete/translations/AutocompleteBundle.lt.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Atitikmenų nerasta',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.nl.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
'Loading more results...' => 'Meer resultaten aan het laden...',
1314
'No results found' => 'Geen resultaten gevonden…',
1415
'No more results' => 'Niet meer resultaten gevonden…',
1516
];

src/Autocomplete/translations/AutocompleteBundle.pl.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Brak wyników',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.pt.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Sem resultados',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.pt_BR.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Nenhum resultado encontrado',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.ro.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Nu au fost găsite rezultate',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.ru.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Совпадений не найдено',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.sl.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Ni zadetkov',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.sr_RS.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Nema rezultata',
1415
'No more results' => 'Nema više rezultata',
1516
];

src/Autocomplete/translations/AutocompleteBundle.sv.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Inga träffar',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.tr.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Sonuç bulunamadı',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.uk.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => 'Нічого не знайдено',
1415
// 'No more results' => 'No more results',
1516
];

src/Autocomplete/translations/AutocompleteBundle.zh_CN.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
return [
13+
// 'Loading more results...' => 'Loading more results...',
1314
'No results found' => '未找到结果',
1415
// 'No more results' => 'No more results',
1516
];

0 commit comments

Comments
 (0)