From 5195caf0405eea7a6b34f60cb0a1bea3026bac3c Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 6 Nov 2017 12:13:52 +0100 Subject: Ajax support for Select, emptyOption support --- src/main/assets/js/ajax-bootstrap-select.pl-PL.js | 88 ++++++++++++++++++++++ src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 30 ++++++++ .../kotlin/pl/treksoft/kvision/core/KVManager.kt | 4 + .../pl/treksoft/kvision/form/select/AjaxOptions.kt | 33 ++++++-- .../pl/treksoft/kvision/form/select/Select.kt | 15 +++- .../pl/treksoft/kvision/form/select/SelectInput.kt | 30 +++++--- 6 files changed, 181 insertions(+), 19 deletions(-) create mode 100644 src/main/assets/js/ajax-bootstrap-select.pl-PL.js (limited to 'src/main') diff --git a/src/main/assets/js/ajax-bootstrap-select.pl-PL.js b/src/main/assets/js/ajax-bootstrap-select.pl-PL.js new file mode 100644 index 00000000..3006d5af --- /dev/null +++ b/src/main/assets/js/ajax-bootstrap-select.pl-PL.js @@ -0,0 +1,88 @@ +/*! + * Ajax Bootstrap Select + * + * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. + * + * @version 1.4.2 + * @author Adam Heim - https://github.com/truckingsim + * @link https://github.com/truckingsim/Ajax-Bootstrap-Select + * @copyright 2017 Adam Heim + * @license Released under the MIT license. + * + * Contributors: + * Mark Carver - https://github.com/markcarver + * + * Last build: 2017-11-01 11:24:59 AM EDT + */ +!(function ($) { +/*! + * Polish translation for the "pl-PL" and "pl" language codes. + * Robert Jaros +*/ +$.fn.ajaxSelectPicker.locale['pl-PL'] = { + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} currentlySelected = 'Currently Selected' + * @markdown + * The text to use for the label of the option group when currently selected options are preserved. + */ + currentlySelected: 'Aktualnie wybrane', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} emptyTitle = 'Select and begin typing' + * @markdown + * The text to use as the title for the select element when there are no items to display. + */ + emptyTitle: 'Wybierz i zacznij pisać', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} errorText = ''Unable to retrieve results' + * @markdown + * The text to use in the status container when a request returns with an error. + */ + errorText: 'Nie udało się pobrać wyników', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} searchPlaceholder = 'Search...' + * @markdown + * The text to use for the search input placeholder attribute. + */ + searchPlaceholder: 'Szukaj...', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusInitialized = 'Start typing a search query' + * @markdown + * The text used in the status container when it is initialized. + */ + statusInitialized: 'Zacznij pisać warunek wyszukiwania', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusNoResults = 'No Results' + * @markdown + * The text used in the status container when the request returns no results. + */ + statusNoResults: 'Brak wyników', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusSearching = 'Searching...' + * @markdown + * The text to use in the status container when a request is being initiated. + */ + statusSearching: 'Szukam...', + + /** + * @member $.fn.ajaxSelectPicker.locale + * @cfg {String} statusTooShort = 'Please enter more characters' + * @markdown + * The text used in the status container when the request returns no results. + */ + statusTooShort: 'Wprowadź więcej znaków' +}; +$.fn.ajaxSelectPicker.locale.pl = $.fn.ajaxSelectPicker.locale['pl-PL']; +})(jQuery); diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index 985f9f98..a3fec251 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -187,6 +187,36 @@ class Showcase : ApplicationBase() { } root.add(select7) + val select8 = Select(label = "Wybierz repozytorium").apply { + emptyOption = true + ajaxOptions = AjaxOptions("https://api.github.com/search/repositories", processData = { + it.items.map { item -> + obj { + this.value = item.id + this.text = item.name + this.data = obj { + this.subtext = item.owner.login + } + } + } + }, processParams = obj { + q = "{{{q}}}" + }, minLength = 3, requestDelay = 1000) + setEventListener