Skip to content

[Autocomplete] Support the render.loading_more Tom Select option #1338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Autocomplete/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased

- Add support for the `render.loading_more` Tom Select Virtual Scroll option (`loading_more_text`)

## 2.13.2

- Revert "Change JavaScript package to `type: module`"
Expand Down
2 changes: 2 additions & 0 deletions src/Autocomplete/assets/dist/controller.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class extends Controller {
static values: {
url: StringConstructor;
optionsAsHtml: BooleanConstructor;
loadingMoreText: StringConstructor;
noResultsFoundText: StringConstructor;
noMoreResultsText: StringConstructor;
minCharacters: NumberConstructor;
Expand All @@ -20,6 +21,7 @@ export default class extends Controller {
};
readonly urlValue: string;
readonly optionsAsHtmlValue: boolean;
readonly loadingMoreTextValue: string;
readonly noMoreResultsTextValue: string;
readonly noResultsFoundTextValue: string;
readonly minCharactersValue: number;
Expand Down
4 changes: 4 additions & 0 deletions src/Autocomplete/assets/dist/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
item: function (item) {
return `<div>${item.text}</div>`;
},
loading_more: () => {
return `<div class="loading-more-results">${this.loadingMoreTextValue}</div>`;
},
no_more_results: () => {
return `<div class="no-more-results">${this.noMoreResultsTextValue}</div>`;
},
Expand All @@ -342,6 +345,7 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
default_1.values = {
url: String,
optionsAsHtml: Boolean,
loadingMoreText: String,
noResultsFoundText: String,
noMoreResultsText: String,
minCharacters: Number,
Expand Down
5 changes: 5 additions & 0 deletions src/Autocomplete/assets/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class extends Controller {
static values = {
url: String,
optionsAsHtml: Boolean,
loadingMoreText: String,
noResultsFoundText: String,
noMoreResultsText: String,
minCharacters: Number,
Expand All @@ -24,6 +25,7 @@ export default class extends Controller {

declare readonly urlValue: string;
declare readonly optionsAsHtmlValue: boolean;
declare readonly loadingMoreTextValue: string;
declare readonly noMoreResultsTextValue: string;
declare readonly noResultsFoundTextValue: string;
declare readonly minCharactersValue: number;
Expand Down Expand Up @@ -224,6 +226,9 @@ export default class extends Controller {
item: function (item: any) {
return `<div>${item.text}</div>`;
},
loading_more: (): string => {
return `<div class="loading-more-results">${this.loadingMoreTextValue}</div>`;
},
no_more_results: (): string => {
return `<div class="no-more-results">${this.noMoreResultsTextValue}</div>`;
},
Expand Down
4 changes: 4 additions & 0 deletions src/Autocomplete/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ e.g. ``FoodAutocompleteField`` from above):
an autocomplete-Ajax endpoint (e.g. for a custom ``ChoiceType``), then set this
to change the field into an AJAX-powered select.

``loading_more_text`` (default: 'Loading more results...')
Rendered at the bottom of the list while fetching more results. This message is
automatically translated using the ``AutocompleteBundle`` domain.

``no_results_found_text`` (default: 'No results found')
Rendered when no matching results are found. This message is automatically translated
using the ``AutocompleteBundle`` domain.
Expand Down
2 changes: 2 additions & 0 deletions src/Autocomplete/src/Form/AutocompleteChoiceTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function finishView(FormView $view, FormInterface $form, array $options):
$values['min-characters'] = $options['min_characters'];
}

$values['loading-more-text'] = $this->trans($options['loading_more_text']);
$values['no-results-found-text'] = $this->trans($options['no_results_found_text']);
$values['no-more-results-text'] = $this->trans($options['no_more_results_text']);
$values['preload'] = $options['preload'];
Expand All @@ -99,6 +100,7 @@ public function configureOptions(OptionsResolver $resolver): void
'tom_select_options' => [],
'options_as_html' => false,
'allow_options_create' => false,
'loading_more_text' => 'Loading more results...',
'no_results_found_text' => 'No results found',
'no_more_results_text' => 'No more results',
'min_characters' => null,
Expand Down
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.ar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'لم يتم العثور على أي نتائج',
'No more results' => 'لا توجد نتائج أٌخرى',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.bg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Няма намерени съвпадения',
'No more results' => 'Няма повече резултати',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.ca.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'No s\'han trobat resultats',
'No more results' => 'No hi ha més resultats',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Nenalezeny žádné položky',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.da.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Ingen resultater fundet',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.de.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Keine Übereinstimmungen gefunden',
'No more results' => 'Keine weiteren Ergebnisse',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.el.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Δεν βρέθηκαν αποτελέσματα',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
'Loading more results...' => 'Loading more results...',
'No results found' => 'No results found',
'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.es.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'No se han encontrado resultados',
'No more results' => 'No hay más resultados',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.eu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Ez da bat datorrenik aurkitu',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'هیچ نتیجه‌ای یافت نشد',
'No more results' => 'نتیجه دیگری وجود ندارد',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.fi.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Ei tuloksia',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
'Loading more results...' => 'Chargement d\'autres résultats...',
'No results found' => 'Aucun résultat trouvé',
'No more results' => 'Aucun autre résultat trouvé',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.gl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Non se atoparon resultados',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.hr.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Nema rezultata',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.hu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
'Loading more results...' => 'További találatok betöltése...',
'No results found' => 'Nincs találat',
'No more results' => 'Nincs több találat',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.id.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Tidak ada hasil yang ditemukan',
'No more results' => 'Tidak ada hasil lagi',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.it.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Nessun risultato trovato',
'No more results' => 'Non ci sono altri risultati',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.lb.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Keng Resultater fonnt',
'No more results' => 'Keng weider Resultater',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.lt.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Atitikmenų nerasta',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
'Loading more results...' => 'Meer resultaten aan het laden...',
'No results found' => 'Geen resultaten gevonden…',
'No more results' => 'Niet meer resultaten gevonden…',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Brak wyników',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Sem resultados',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.pt_BR.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Nenhum resultado encontrado',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.ro.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Nu au fost găsite rezultate',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Совпадений не найдено',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.sl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Ni zadetkov',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.sr_RS.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Nema rezultata',
'No more results' => 'Nema više rezultata',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.sv.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Inga träffar',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.tr.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Sonuç bulunamadı',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.uk.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => 'Нічого не знайдено',
// 'No more results' => 'No more results',
];
1 change: 1 addition & 0 deletions src/Autocomplete/translations/AutocompleteBundle.zh_CN.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

return [
// 'Loading more results...' => 'Loading more results...',
'No results found' => '未找到结果',
// 'No more results' => 'No more results',
];