mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Default country in listing #152
This commit is contained in:
parent
08a687faeb
commit
abe87ea262
@ -35,13 +35,14 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<script>
|
||||
var select_trans = "{{ trans('visiosoft.module.advs::field.pick_option') }}";
|
||||
var searchedCountry = {{ searchedCountry }};
|
||||
var useDefault = {{ useDefault }};
|
||||
</script>
|
||||
|
||||
{% if entries('advs').isEnabled('favs') %}
|
||||
|
||||
@ -146,6 +146,13 @@ class AdvsController extends PublicController
|
||||
$subCats = array();
|
||||
|
||||
$param = $this->requestHttp->toArray();
|
||||
if (!isset($param['country'])) {
|
||||
$param['country'] = setting_value('visiosoft.module.advs::default_country');
|
||||
$useDefault = 1;
|
||||
} else {
|
||||
$useDefault = 0;
|
||||
}
|
||||
$searchedCountry = $param['country'];
|
||||
|
||||
$countries = $this->country_repository->viewAll();
|
||||
|
||||
@ -213,7 +220,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', 'useDefault');
|
||||
|
||||
Cookie::queue(Cookie::make('last_search', $this->requestHttp->getRequestUri(), 84000));
|
||||
|
||||
|
||||
@ -25,6 +25,15 @@ FindLocations = (id, table, typeDb, divId, paramName = null) => {
|
||||
});
|
||||
};
|
||||
|
||||
// Set selected country in the select menu
|
||||
if (useDefault) {
|
||||
$('#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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user