diff --git a/addons/default/visiosoft/advs-module/resources/js/list.js b/addons/default/visiosoft/advs-module/resources/js/list.js index a5099a2fe..fa86de6d9 100644 --- a/addons/default/visiosoft/advs-module/resources/js/list.js +++ b/addons/default/visiosoft/advs-module/resources/js/list.js @@ -146,11 +146,32 @@ $(document).ready(function () { }); // Country filter - $("select[name=filter_country]").select2({ + const locationFilter = $("select[name=filter_country]") + locationFilter.select2({ placeholder: $('select[name=filter_country] option:first-child').text() }); + locationFilter.change(function () { + if ($(this).val()) { + getCities($(this).val()) + } + }).trigger('change'); + + // City filter + $("select[name=filter_City]").select2({ + placeholder: $('select[name=filter_City] option:first-child').text() + }); }); +function getCities(country) { + return crudAjax(`id=${country}`, '/ajax/getCities', 'POST', () => {}, true) + .then(function (cities) { + $('select[name="filter_City"]').html(""); + $.each(cities, function (index, value) { + $('select[name="filter_City"]').append(""); + }); + }) +} + $("#listFilterForm").submit(function(e) { // Disable unselected inputs const inputs = $('#listFilterForm :input');