Default country in listing #152 #153

This commit is contained in:
Diatrex 2019-11-19 18:03:45 +03:00
parent cdd7f81857
commit e3cf2a68be
3 changed files with 10 additions and 6 deletions

View File

@ -42,7 +42,6 @@
<script>
var select_trans = "{{ trans('visiosoft.module.advs::field.pick_option') }}";
var searchedCountry = {{ searchedCountry }};
var useDefault = {{ useDefault }};
</script>
{% if entries('advs').isEnabled('favs') %}

View File

@ -147,10 +147,15 @@ class AdvsController extends PublicController
$param = $this->requestHttp->toArray();
if (!isset($param['country'])) {
$param['country'] = setting_value('visiosoft.module.advs::default_country');
$useDefault = 1;
if (is_null(Cookie::get('country'))) {
$param['country'] = setting_value('visiosoft.module.advs::default_country');
} else {
$param['country'] = Cookie::get('country');
}
} else {
$useDefault = 0;
if ($param['country'] != setting_value('visiosoft.module.advs::default_country')) {
Cookie::queue(Cookie::make('country', $param['country'], 84000));
}
}
$searchedCountry = $param['country'];
@ -220,7 +225,7 @@ class AdvsController extends PublicController
}
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'textfields', 'checkboxes', 'request',
'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'useDefault');
'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList', 'searchedCountry');
Cookie::queue(Cookie::make('last_search', $this->requestHttp->getRequestUri(), 84000));

View File

@ -26,7 +26,7 @@ FindLocations = (id, table, typeDb, divId, paramName = null) => {
};
// Set selected country in the select menu
if (useDefault) {
if (searchParams.get('country') == null) {
$('#cities').empty();
var table = "cities";
var typeDb = 'parent_country_id';