location filter default country

This commit is contained in:
muammertop 2020-12-18 00:18:35 +03:00
parent 0583b64a65
commit f207b63ceb
2 changed files with 7 additions and 3 deletions

View File

@ -19,7 +19,8 @@ $('.filter-country-btn').on('click', function () {
$('.filter-location-modal .countries').html(null_msg); $('.filter-location-modal .countries').html(null_msg);
else if ($('input[name="country"]').val() != ""){ else if ($('input[name="country"]').val() != ""){
$.each(selected__country_request.split(','), function (index, value){ $.each(selected__country_request.split(','), function (index, value){
$(".filter-location-body .countries li[data-id='" + value.trim() + "'] input[type='checkbox']").prop('checked', true); console.log(value.trim())
$(".filter-location-body .countries li[data-id='" + value.trim() + "'] input[type='checkbox']")
}) })
} }
resolve(); resolve();
@ -38,6 +39,7 @@ $('.filter-country-btn').on('click', function () {
//City //City
$('.filter-city-btn').on('click', function () { $('.filter-city-btn').on('click', function () {
var countries_value = $('input[name="country[]"]').val(); var countries_value = $('input[name="country[]"]').val();
countries_value += ',' + defaultCountry
var selected__city_request = $('input[name="city[]"]').val(); var selected__city_request = $('input[name="city[]"]').val();
if (cities == undefined || $(this).attr('data-parent') != countries_value) { if (cities == undefined || $(this).attr('data-parent') != countries_value) {
$(this).attr('data-parent', countries_value); $(this).attr('data-parent', countries_value);
@ -242,10 +244,11 @@ function locationCrud(params, url, type, beforeSend, callback) {
} }
function item(field_name, id, value, abv = '') { function item(field_name, id, value, abv = '') {
var selected = defaultCountry === id ? "checked" : "";
if (field_name === 'country') { if (field_name === 'country') {
return '<li class="px-2" data-id="' + id + '">\n' + return '<li class="px-2" data-id="' + id + '">\n' +
' <label class="w-100">\n' + ' <label class="w-100">\n' +
' <input type="checkbox" data-field="' + field_name + '" data-id="' + id + '">\n' + ' <input type="checkbox" data-field="' + field_name + '" data-id="' + id + '" '+ selected +'>\n' +
' <span class="flag ml-1 flag-' + abv + '">\n' + ' <span class="flag ml-1 flag-' + abv + '">\n' +
' </span>\n' + ' </span>\n' +
' <small>' + value + '</small>\n' + ' <small>' + value + '</small>\n' +
@ -255,7 +258,7 @@ function item(field_name, id, value, abv = '') {
} else { } else {
return '<li class="px-2" data-id="' + id + '">\n' + return '<li class="px-2" data-id="' + id + '">\n' +
' <label class="w-100">\n' + ' <label class="w-100">\n' +
' <input type="checkbox" data-field="' + field_name + '" data-id="' + id + '">\n' + ' <input type="checkbox" data-field="' + field_name + '" data-id="' + id + '" '+ selected +'>\n' +
' <small>' + value + '</small>\n' + ' <small>' + value + '</small>\n' +
' </label>\n' + ' </label>\n' +
' </li>'; ' </li>';

View File

@ -120,4 +120,5 @@
<script> <script>
var null_msg = "{{ trans('visiosoft.module.location::message.null_msg') }}!" var null_msg = "{{ trans('visiosoft.module.location::message.null_msg') }}!"
var defaultCountry = {{ defaultCountry }}
</script> </script>