Merge pull request #153 from openclassify/dia

Default country in listing #152
This commit is contained in:
Fatih Alp 2019-11-19 18:15:15 +03:00 committed by GitHub
commit b9e9743a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View File

@ -35,13 +35,13 @@
</div>
{% endblock %}
</div>
</section>
<script>
var select_trans = "{{ trans('visiosoft.module.advs::field.pick_option') }}";
var searchedCountry = {{ searchedCountry }};
</script>
{% if entries('advs').isEnabled('favs') %}

View File

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

View File

@ -25,6 +25,15 @@ FindLocations = (id, table, typeDb, divId, paramName = null) => {
});
};
// Set selected country in the select menu
if (searchParams.get('country') == null) {
$('#cities').empty();
var table = "cities";
var typeDb = 'parent_country_id';
var id = searchedCountry;
var divId = "#cities";
FindLocations(id, table, typeDb, divId);
}
setLocations = (response, id, table, typeDb, divId, paramName) => {
@ -40,7 +49,7 @@ setLocations = (response, id, table, typeDb, divId, paramName) => {
//Set Selected Option
if (paramName != null) {
if (divId == "#cities") {
$('#countries').val(searchParams.get('country'));
$('#countries').val(searchedCountry);
$('#countries').select2();
$('#cities').val(findParam("city[]"));
} else {