Merge pull request #203 from openclassify/basetheme

Basetheme
This commit is contained in:
Fatih Alp 2020-01-06 15:21:26 +03:00 committed by GitHub
commit 35594a1f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 858 additions and 283 deletions

View File

@ -18,10 +18,11 @@
{% include "visiosoft.module.advs::ad-detail/partials/author-button" %}
<!-- admin -->
<!-- breadcrumb -->
{% include "visiosoft.module.advs::ad-detail/partials/breadcrumb" %}
<!-- breadcrumb -->
{% if setting_value('visiosoft.theme.base::breadcrumbs') %}
<!-- breadcrumb -->
{% include "visiosoft.module.advs::ad-detail/partials/breadcrumb" %}
<!-- breadcrumb -->
{% endif %}
<h2 class="title">
{{ adv.title }}
{{ addBlock('ad-detail/title/action',{'adv_id':adv.id})|raw }}
@ -32,23 +33,25 @@
<div class="row">
{% include "visiosoft.module.advs::ad-detail/partials/slider" %}
<div class="col-md-5">
{% include "visiosoft.module.advs::ad-detail/partials/detail" %}
{% if setting_value('visiosoft.theme.base::ad_details') %}
{% include "visiosoft.module.advs::ad-detail/partials/detail" %}
{% endif %}
</div>
</div>
</div>
<!--detail-ad -->
{% if setting_value('visiosoft.theme.base::ad_details_tab') %}
{% if blocks('ad-item-content-block-area') is null %}
{% include "visiosoft.module.advs::ad-detail/partials/content" %}
{% else %}
{{ blocks('ad-item-content-block-area') }}
{% if blocks('ad-item-content-block-area') is null %}
{% include "visiosoft.module.advs::ad-detail/partials/content" %}
{% else %}
{{ blocks('ad-item-content-block-area') }}
{% endif %}
{{ addBlock('ad-detail/widget', {'price': adv.price, 'id': adv.id})|raw }}
{% endif %}
{{ addBlock('ad-detail/widget', {'price': adv.price, 'id': adv.id})|raw }}
</div>
</section>

View File

@ -74,7 +74,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
if (!empty($param['country'])) {
$query = $query->where('country_id', $param['country']);
}
if (!empty($param['city'])) {
if (isset($param['city']) and !empty(array_filter($param['city']))) {
$query = $query->whereIn('city', $param['city']);
}
if (!empty($param['cat'])) {
@ -90,14 +90,14 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
if (!empty($param['user'])) {
$query = $query->where('advs_advs.created_by_id', $param['user']);
}
if (!empty($param['district'])) {
$query = $query->where('district', $param['district']);
if (isset($param['district']) and !empty(array_filter($param['district']))) {
$query = $query->whereIn('district', $param['district']);
}
if (!empty($param['neighborhood'])) {
$query = $query->where('neighborhood', $param['neighborhood']);
if (isset($param['neighborhood']) and !empty(array_filter($param['neighborhood']))) {
$query = $query->whereIn('neighborhood', $param['neighborhood']);
}
if (!empty($param['village'])) {
$query = $query->where('village', $param['village']);
if (isset($param['village']) and !empty(array_filter($param['village']))) {
$query = $query->whereIn('village', $param['village']);
}
if (!empty($param['min_price'])) {
$num = $param['min_price'];

View File

@ -146,27 +146,14 @@ 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();
$isActiveDopings = $this->adv_model->is_enabled('dopings');
$isActiveCustomFields = $this->adv_model->is_enabled('customfields');
$advs = $this->adv_repository->searchAdvs('list', $param, $customParameters);
$advs = $this->adv_repository->addAttributes($advs);

View File

@ -0,0 +1,16 @@
<?php
return [
'monitoring' => [
'stacked' => false,
'tabs' => [
'catalog_mode' => [
'title' => 'visiosoft.theme.base::section.catalog_mode.name',
'fields' => [
'navigation_title', 'navigation_action', 'date_fields', 'price_fields',
'breadcrumbs', 'ad_details', 'ad_details_tab','latest_and_view_all_btn'
],
],
],
],
];

View File

@ -0,0 +1,53 @@
<?php
return [
'navigation_title' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'navigation_action' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'date_fields' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'price_fields' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'breadcrumbs' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'ad_details' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'ad_details_tab' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
'latest_and_view_all_btn' => [
'type' => 'anomaly.field_type.boolean',
"config" => [
"default_value" => 1,
]
],
];

View File

@ -8,4 +8,13 @@
.table-img-100 {
max-width: 100px;
}
.loading {
background-image: url("{{ img('visiosoft.theme.base::images/loading.gif').url }}");
background-position: center;
background-size: 25px;
background-repeat: no-repeat;
height: 50px;
width: 100%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -7,4 +7,13 @@ return [
'show_all' => [
'name' => 'Show All',
],
'login' => [
'name' => 'Login',
],
'logout' => [
'name' => 'Logout',
],
'profile' => [
'name' => 'Profile',
],
];

View File

@ -0,0 +1,7 @@
<?php
return [
'catalog_mode' => [
'name' => 'Catalog Mode',
],
];

View File

@ -0,0 +1,31 @@
<?php
return [
'navigation_title' => [
'name' => 'Navigation Title',
],
'navigation_action' => [
'name' => 'Navigation Action',
],
'country_fields' => [
'name' => 'Country Fields',
],
'date_fields' => [
'name' => 'Date Fields',
],
'price_fields' => [
'name' => 'Price Fields',
],
'breadcrumbs' => [
'name' => 'Breadcrumb',
],
'ad_details' => [
'name' => 'Ad Details',
],
'ad_details_tab' => [
'name' => 'Ad Details Tab',
],
'latest_and_view_all_btn' => [
'name' => 'Latest and View All Btn',
],
];

View File

@ -0,0 +1,7 @@
<?php
return [
'catalog_mode' => [
'name' => 'Katalog Modu',
],
];

View File

@ -1,13 +1,14 @@
<div class="album bg-light">
<div class="row p-2">
<div class="col-md-6">
<h4 class="p-2">{{ trans('theme::field.latest_ads.name') }}</h4>
</div>
<div class="col-md-6 text-right">
<a class="btn btn-outline-secondary"
href="{{ url_route('visiosoft.module.advs::list') }}">{{ trans('theme::field.show_all.name') }}</a>
</div>
{% if setting_value('visiosoft.theme.base::latest_and_view_all_btn') %}
<div class="col-md-6">
<h4 class="p-2">{{ trans('theme::field.latest_ads.name') }}</h4>
</div>
<div class="col-md-6 text-right">
<a class="btn btn-outline-secondary"
href="{{ url_route('visiosoft.module.advs::list') }}">{{ trans('theme::field.show_all.name') }}</a>
</div>
{% endif %}
</div>
<div class="container">
@ -25,28 +26,32 @@
</div>
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<b>{{ latestAd.price }} {{ latestAd.currency }}</b>
</div>
{% if setting_value('visiosoft.theme.base::price_fields') %}
<div class="d-flex justify-content-between align-items-center">
<b>{{ latestAd.price }} {{ latestAd.currency }}</b>
</div>
{% endif %}
<div class="d-flex justify-content-between align-items-center text-truncate">
<a href="{{ latestAd.detail_url }}">
<p class="card-title d-inline-block">{{ latestAd.name }}</p>
</a>
</div>
{% if setting_value('visiosoft.module.location::home_page_location') %}
<div class="d-flex justify-content-between align-items-center">
<small>
<i class="fas fa-location-arrow text-primary"></i>
{{ latestAd.city_name }}, {{ latestAd.country_name }}
</small>
</div>
<div class="d-flex justify-content-between align-items-center">
<small>
<i class="fas fa-location-arrow text-primary"></i>
{{ latestAd.city_name }}, {{ latestAd.country_name }}
</small>
</div>
{% endif %}
{% if setting_value('visiosoft.theme.base::date_fields') %}
<div class="d-flex justify-content-between align-items-center">
<small>
<i class="far fa-clock text-dark"></i>
{{ latestAd.created_at|date('d/m/Y') }}
</small>
</div>
{% endif %}
<div class="d-flex justify-content-between align-items-center">
<small>
<i class="far fa-clock text-dark"></i>
{{ latestAd.created_at|date('d/m/Y') }}
</small>
</div>
</div>
</div>
</div>

View File

@ -1,6 +1,9 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="{{ url("/") }}">{{ setting_value('streams::name', config_get('streams::distribution.name')) }}</a>
{% if setting_value('visiosoft.theme.base::navigation_title') %}
<a class="navbar-brand"
href="{{ url("/") }}">{{ setting_value('streams::name', config_get('streams::distribution.name')) }}</a>
{% endif %}
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarContent"
aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -20,38 +23,44 @@
.childListClass('dropdown-menu')
.cache({'namespace': 'user'})
.render()|raw }}
<ul class="nav navbar-nav navbar-right d-block d-sm-none">
<li class="nav-item">
{% if auth_check() %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::logout') }}">Logout</a>
{% else %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::login') }}">Login</a>
{% endif %}
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_route('profile::profile') }}">Profile</a>
</li>
<li class="nav-item">
<a href="/advs/create_adv" class="btn btn-primary">{{ trans("theme::button.post_ad.name") }}</a>
</li>
</ul>
{% if setting_value('visiosoft.theme.base::navigation_action') %}
<ul class="nav navbar-nav navbar-right d-block d-sm-none">
<li class="nav-item">
{% if auth_check() %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::logout') }}">{{ trans('visiosoft.theme.base::field.logout.name') }}</a>
{% else %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::login') }}">{{ trans('visiosoft.theme.base::field.login.name') }}</a>
{% endif %}
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_route('profile::profile') }}">{{ trans('visiosoft.theme.base::field.profile.name') }}</a>
</li>
<li class="nav-item">
<a href="/advs/create_adv" class="btn btn-primary">{{ trans("theme::button.post_ad.name") }}</a>
</li>
</ul>
{% endif %}
</div>
<div class="d-none d-sm-block">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
{% if auth_check() %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::logout') }}">Logout</a>
{% else %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::login') }}">Login</a>
{% endif %}
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_route('profile::profile') }}">Profile</a>
</li>
<li class="nav-item">
<a href="/advs/create_adv" class="btn btn-primary">{{ trans("theme::button.post_ad.name") }}</a>
</li>
</ul>
{% if setting_value('visiosoft.theme.base::navigation_action') %}
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
{% if auth_check() %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::logout') }}">{{ trans('visiosoft.theme.base::field.logout.name') }}</a>
{% else %}
<a class="nav-link" href="{{ url_route('anomaly.module.users::login') }}">{{ trans('visiosoft.theme.base::field.login.name') }}</a>
{% endif %}
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_route('profile::profile') }}">{{ trans('visiosoft.theme.base::field.profile.name') }}</a>
</li>
<li class="nav-item">
<a href="/advs/create_adv" class="btn btn-primary">{{ trans("theme::button.post_ad.name") }}</a>
</li>
</ul>
{% endif %}
</div>
</div>
</nav>

View File

@ -19,4 +19,11 @@ return [
'default_value' => true,
],
],
'default_country' => [
'type' => 'anomaly.field_type.relationship',
"config" => [
"related" => \Visiosoft\LocationModule\Country\CountryModel::class,
'default_value' => 212,
]
],
];

View File

@ -1,4 +1,29 @@
#location .select2-selection__rendered {
display: inline-block;
padding-left: 4px;
.filter-location-back {
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 200;
background-color: #000;
opacity: .3;
-ms-filter: "alpha(opacity=30)";
filter: alpha(opacity=30);
-ms-filter: "alpha(opacity=50)";
}
.filter-location-body ul li:hover {
background: #227af3;
color: #fff;
}
.filter-location-body .countries,
.filter-location-body .cities,
.filter-location-body .districts,
.filter-location-body .neighborhoods,
.filter-location-body .village {
height: 200px;
overflow: auto;
display: none
}

View File

@ -1,155 +1,332 @@
let searchParams = new URLSearchParams(window.location.search);
var countries;
var cities;
var districts;
var neighborhoods;
var village;
//Set Select2 Type for Location Fields
$('.cities, .countries, .districts, .neighborhoods, .village').select2({
placeholder: select_trans
//Country
$('.filter-country-btn').on('click', function () {
if (countries == undefined) {
var promiseForCountries = new Promise(function (resolve, reject) {
crud('', '/ajax/getCountry', 'POST', beforeSend(), function (callback) {
countries = callback;
resetValue('country', true, false)
$.each(countries, function (index, value) {
$('.filter-location-modal .countries').append(item('country', value.id, value.name));
});
if (countries == "")
$('.filter-location-modal .countries').html(null_msg);
else if ($('input[name="country"]').val() != "")
$(".filter-location-body .countries li[data-id='" + $('input[name="country"]').val() + "'] input[type='checkbox']").prop('checked', true);
resolve();
})
});
promiseForCountries.then(function () {
SelectOnClick();
})
}
$('.filter-location-modal .countries').show();
$('.filter-location-modal').show();
$('.filter-location-back').show();
scroolToModal()
});
//City
$('.filter-city-btn').on('click', function () {
var countries_value = $('input[name="country"]').val();
var selected__city_request = $('input[name="city[]"]').val();
if (cities == undefined || $(this).attr('data-parent') != countries_value) {
$(this).attr('data-parent', countries_value)
var promiseForCities = new Promise(function (resolve, reject) {
crud('id=' + countries_value, '/ajax/getCities', 'POST', beforeSend(), function (callback) {
cities = callback;
resetValue('city', true, false)
$.each(cities, function (index, value) {
$('.filter-location-modal .cities').append(item('city', value.id, value.name));
});
if (cities == "")
$('.filter-location-modal .cities').html(null_msg);
else if (selected__city_request != "") {
$.each(selected__city_request.split(','), function (index, value) {
$(".filter-location-body .cities li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true);
});
}
resolve();
})
});
promiseForCities.then(function () {
SelectOnClick();
})
}
$('.filter-location-modal .cities').show();
$('.filter-location-modal').show();
$('.filter-location-back').show();
scroolToModal()
});
//District
$('.filter-district-btn').on('click', function () {
var city_value = $('input[name="city[]"]').val();
var selected_district_request = $('input[name="district[]"]').val();
if (districts == undefined || $(this).attr('data-parent') != city_value) {
$(this).attr('data-parent', city_value)
var promiseForDistricts = new Promise(function (resolve, reject) {
crud('id=' + city_value, '/ajax/getDistricts', 'POST', beforeSend(), function (callback) {
districts = callback;
resetValue('district', true, false)
$.each(districts, function (index, value) {
$('.filter-location-modal .districts').append(item('district', value.id, value.name));
});
if (districts == "")
$('.filter-location-modal .districts').html(null_msg);
else if (selected_district_request != "") {
$.each(selected_district_request.split(','), function (index, value) {
$(".filter-location-body .districts li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true);
});
}
resolve();
})
});
promiseForDistricts.then(function () {
SelectOnClick();
})
}
$('.filter-location-modal .districts').show();
$('.filter-location-modal').show();
$('.filter-location-back').show();
scroolToModal()
});
//Neighborhood
$('.filter-neighborhood-btn').on('click', function () {
var district_value = $('input[name="district[]"]').val();
var selected_neighborhood_request = $('input[name="neighborhood[]"]').val();
if (neighborhoods == undefined || $(this).attr('data-parent') != district_value) {
$(this).attr('data-parent', district_value)
var promiseForNeighborhoods = new Promise(function (resolve, reject) {
crud('id=' + district_value, '/ajax/getNeighborhoods', 'POST', beforeSend(), function (callback) {
neighborhoods = callback;
resetValue('neighborhood', true, false)
$.each(neighborhoods, function (index, value) {
$('.filter-location-modal .neighborhoods').append(item('neighborhood', value.id, value.name));
});
if (neighborhoods == "")
$('.filter-location-modal .neighborhoods').html(null_msg);
else if (selected_neighborhood_request != "") {
$.each(selected_neighborhood_request.split(','), function (index, value) {
$(".filter-location-body .neighborhoods li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true);
});
}
resolve();
})
});
promiseForNeighborhoods.then(function () {
SelectOnClick();
})
}
$('.filter-location-modal .neighborhoods').show();
$('.filter-location-modal').show();
$('.filter-location-back').show();
scroolToModal()
});
//Village
$('.filter-village-btn').on('click', function () {
var neighborhood_value = $('input[name="neighborhood[]"]').val();
var selected_village_request = $('input[name="village[]"]').val();
if (village == undefined || $(this).attr('data-parent') != neighborhood_value) {
$(this).attr('data-parent', neighborhood_value)
var promiseForVillage = new Promise(function (resolve, reject) {
crud('id=' + neighborhood_value, '/ajax/getVillage', 'POST', beforeSend(), function (callback) {
village = callback;
$('.filter-location-modal .village').html("");
$.each(village, function (index, value) {
$('.filter-location-modal .village').append(item('village', value.id, value.name));
});
if (village == "")
$('.filter-location-modal .village').html(null_msg);
else if (selected_village_request != "") {
$.each(selected_village_request.split(','), function (index, value) {
$(".filter-location-body .village li[data-id='" + value + "'] input[type='checkbox']").prop('checked', true);
});
}
resolve();
})
});
promiseForVillage.then(function () {
SelectOnClick();
})
}
$('.filter-location-modal .village').show();
$('.filter-location-modal').show();
$('.filter-location-back').show();
scroolToModal()
});
FindLocations = (id, table, typeDb, divId, paramName = null) => {
$('.filter-modal-close , .filter-location-back').on('click', function () {
$('.filter-location-modal').hide();
$('.filter-location-back').hide();
$('.filter-location-modal .countries').hide();
$('.filter-location-modal .cities').hide();
$('.filter-location-modal .districts').hide();
$('.filter-location-modal .neighborhoods').hide();
$('.filter-location-modal .village').hide();
});
function SelectOnClick() {
$(".filter-location-body input[type='checkbox']").unbind();
searchLocationName()
$('.loading').hide();
return $(".filter-location-body input[type='checkbox']").change(function () {
resetValue($(this).attr('data-field'), false, true)
var input = $('input[name="' + $(this).attr('data-field') + '[]"]');
var input_text = $(this).parent().find('small').html();
var text_html = $('.selected-' + $(this).attr('data-field') + ' small');
var text = "";
var input_val = input.val();
var id = $(this).attr('data-id');
if ($(this).attr('data-field') == "country") {
input.val(id)
text_html.html(input_text)
$(".filter-location-body input[type='checkbox']").prop('checked', false);
$(".filter-location-body li[data-id='" + id + "'] input[type='checkbox']").prop('checked', true);
} else {
if (input_val != "") {
input_val = input_val.split(',');
text = text_html.html().split(',');
} else {
input_val = [];
text = [];
}
if (this.checked) {
input_val.push(id);
text.push(input_text)
} else {
input_val.splice($.inArray(id, input_val), 1);
text.splice($.inArray(input_text, text), 1);
}
input.val(input_val.join(','))
text_html.html(text.join(','))
}
});
}
function crud(params, url, type, beforeSend, callback) {
$.ajax({
type: 'get',
url: '/getlocations',
data: {
id: id,
table: table,
typeDb: typeDb,
type: type,
data: params,
url: url,
beforeSend: function () {
beforeSend
},
success: function (response) {
setLocations(response, id, table, typeDb, divId, paramName);
return response;
callback(response);
},
error: function (err) {
reject(Error("It broke"));
}
});
};
}
function item(field_name, id, value) {
return '<li class="px-2" data-id="' + id + '">\n' +
' <label class="w-100">\n' +
' <input type="checkbox" data-field="' + field_name + '" data-id="' + id + '">\n' +
' <small>' + value + '</small>\n' +
' </label>\n' +
' </li>';
}
setLocations = (response, id, table, typeDb, divId, paramName) => {
function resetValue(location_type, reset_this, reset_parent) {
var list_class, inputs;
var selected_type = false;
//For City
if (location_type == "country") {
inputs = ['city', 'district', 'neighborhood', 'village']
list_class = ['cities', 'districts', 'neighborhoods', 'village']
selected_type = true
//Add Options
if(divId != ".cities")
{
$(divId).append("<option value></option>")
}
response.forEach(function (options) {
$(divId).append("<option value=" + options.id + ">" + options.name + "</option>")
});
//Set Selected Option
if (paramName != null) {
if (divId == ".cities") {
$('.countries').val(searchParams.get('country'));
$('.countries').select2();
$('.cities').val(findParam("city[]"));
//For City
if (location_type == "city") {
if (reset_this || selected_type) {
inputs = ['city', 'district', 'neighborhood', 'village']
list_class = ['cities', 'districts', 'neighborhoods', 'village']
} else {
$(divId).val(searchParams.get(paramName));
location_type = "district";
selected_type = true
}
$(divId).select2();
}
};
//For District
if (location_type == "district") {
if (reset_this || selected_type) {
inputs = ['district', 'neighborhood', 'village']
list_class = ['districts', 'neighborhoods', 'village']
} else {
location_type = "neighborhood";
selected_type = true
}
//Category Change
$('.countries').on('change', function () {
$('.cities').empty();
var table = "cities";
var typeDb = 'parent_country_id';
var id = $(this).val();
var divId = ".cities";
FindLocations(id, table, typeDb, divId);
});
//City Change
$('.cities, .select2-selection__choice__remove').on('change', function () {
$('.districts').empty();
var table = "districts";
var typeDb = 'parent_city_id';
var id = $(this).val();
var divId = ".districts";
FindLocations(id, table, typeDb, divId);
});
//Districts Change
$('.districts').on('change', function () {
var table = "neighborhoods";
var typeDb = 'parent_district_id';
var id = $(this).val();
var divId = ".neighborhoods";
FindLocations(id, table, typeDb, divId);
});
//Neighborhoods Change
$('.neighborhoods').on('change', function () {
var table = "village";
var typeDb = 'parent_neighborhood_id';
var id = $(this).val();
var divId = ".village";
FindLocations(id, table, typeDb, divId);
});
jQuery(document).ready(function ($) {
}).promise().done(function () {
//Get City && Set Country
if (searchParams.get('country') != '') {
$('.cities').empty();
var table = "cities";
var typeDb = 'parent_country_id';
var id = searchParams.get('country');
var divId = ".cities";
var paramName = 'city';
FindLocations(id, table, typeDb, divId, paramName);
}
}).promise().done(function () {
//get District && set city
if (findParam('city[]').length) {
$('.districts').empty();
var table = "districts";
var typeDb = 'parent_city_id';
var id = findParam('city[]');
var divId = ".districts";
var paramName = 'district';
FindLocations(id, table, typeDb, divId, paramName);
//For Neighborhood
if (location_type == "neighborhood") {
if (reset_this || selected_type) {
inputs = ['neighborhood', 'village']
list_class = ['neighborhoods', 'village']
} else {
inputs = ['village']
list_class = ['village']
}
}
}).promise().done(function () {
//Reset All List Class From list_class
$.each(list_class, function (index, value) {
$('.filter-location-modal .' + value).html("");
});
//get neighborhood && set districts
if (searchParams.get('district') != '') {
$('.neighborhoods').empty();
var table = "neighborhoods";
var typeDb = 'parent_district_id';
var id = searchParams.get('district');
var divId = ".neighborhoods";
var paramName = 'neighborhood';
//Reset All Input Value From inputs
$.each(inputs, function (index, value) {
$('input[name="' + value + '"]').val("");
if (reset_parent)
$('.filter-' + value + '-btn').attr("data-parent", "");
});
}
FindLocations(id, table, typeDb, divId, paramName);
}
function scroolToModal() {
//Scrool Screen
$([document.documentElement, document.body]).animate({
scrollTop: $('.filter-location-modal').offset().top - 250
}, 1000);
}
}).promise().done(function () {
function searchLocationName() {
var searchField = $("#searchLocation");
searchField.unbind();
searchField.on("keyup", function () {
var value = this.value.toLowerCase().trim();
$('.filter-location-modal li').show().filter(function () {
return $(this).text().toLowerCase().trim().indexOf(value) == -1;
}).hide();
});
}
//get village && set neighborhoods
if (searchParams.get('neighborhood') != '') {
$('.village').empty();
var table = "village";
var typeDb = 'parent_neighborhood_id';
var id = searchParams.get('neighborhood');
var divId = ".village";
var paramName = 'village';
FindLocations(id, table, typeDb, divId, paramName);
}
});
function beforeSend() {
$('.loading').show()
$('.filter-location-modal li').show();
$("#searchLocation").val('');
}

View File

@ -31,4 +31,7 @@ return [
'pick_option' => [
'name' => 'Pick an option',
],
'address' => [
'name' => 'Address',
],
];

View File

@ -1,4 +1,6 @@
<?php
return [
'placeholder' => 'Type here to search',
'null_msg' => 'Not Found',
];

View File

@ -13,4 +13,7 @@ return [
'show_search_location_btn' => [
'name' => 'Show Search Location Button',
],
'default_country' => [
'name' => 'Default Country',
],
];

View File

@ -1,7 +1,7 @@
<?php
return[
"title" =>"Yer",
"name" =>"Yer Modülü",
"description" =>"ıklama"
"title" =>"Bölge",
"name" =>"Bölge Modülü",
"description" =>"Bölge Modülü"
];

View File

@ -2,8 +2,8 @@
return[
"new_country" =>"Yeni ülke",
"new_city" =>"Yeni şehir",
"new_district" =>"Yeni bölge",
"new_city" =>"Yeni İl",
"new_district" =>"Yeni İlçe",
"new_neighborhood" =>"Yeni mahalle",
"new_village" =>"Yeni köy",
"sub_cities" =>"Alt Şehirler",

View File

@ -10,11 +10,11 @@ return[
],
"city" => [
"name" =>"Kent",
"name" =>"İl",
],
"country" => [
"name" =>"ülke",
"name" =>"Ülke",
],
"district" => [
@ -22,20 +22,23 @@ return[
],
"order" => [
"name" =>"Sıralama düzeni",
"name" =>"Sıralama",
],
"neighborhood" => [
"name" =>"Komşuluk",
"name" =>"Mahalle",
],
"village" => [
"name" =>"köy",
"name" =>"Köy",
],
"description" => [
"name" =>"ıklama",
],
'address' => [
'name' => 'Adres',
],
];

View File

@ -1,5 +1,6 @@
<?php
return[
];
return [
'placeholder' => 'Ara',
'null_msg' => 'Bulunamadı',
];

View File

@ -1,15 +0,0 @@
<?php
return[
"village" => [
"name" =>"köy",
"option" => [
"read" =>"Köy okuyabilir mi ",
"write" =>"Köy oluşturabilir / düzenleyebilir mi? ",
"delete" =>"Köyü silebilir mi?",
],
],
];

View File

@ -2,19 +2,19 @@
return[
"countries" => [
"title" =>"Ülkeler",
"title" =>"Ülke",
],
"cities" => [
"title" =>"Şehirler",
"title" =>"İl",
],
"districts" => [
"title" =>"İlçeler",
"title" =>"İlçer",
],
"neighborhoods" => [
"title" =>"Çevredekiler",
"title" =>"Mahalle",
],
"village" => [

View File

@ -1,42 +1,102 @@
<div class="row w-100 px-2 m-0">
<div class="col-12 px-0 py-1">
<label class="label-filter-location">{{ trans("visiosoft.module.location::field.country.name") }}</label>
<select class="form-control countries" name="country" id="countries">
{% for country in params.countries %}
<option value="{{ country.id }}">{{ country.name }}</option>
{% endfor %}
</select>
<div class="col-12 px-0 py-1 px-2">
<b>
<span class="float-left">{{ trans('visiosoft.module.location::field.address.name') }}</span>
</b>
<a href="#" class="a-sahibinden-type selected-country filter-country-btn float-right">
<small>{{ getCountry(setting_value('visiosoft.module.location::default_country')).name }}</small>
</a>
{% set country = setting_value('visiosoft.module.location::default_country') %}
{% if app.request.get('country') %}
{% set country = app.request.get('country') %}
{% endif %}
<input name="country" value="{{ country }}" type="hidden">
</div>
<div class="col-12 px-0 py-1">
<label class="label-filter-location">{{ trans("visiosoft.module.location::field.city.name") }}</label>
<select class="form-control cities" name="city[]" id="cities" multiple>
{% for city in params.cities %}
<option value="{{ city.id }}">{{ city.name }}</option>
{% endfor %}
</select>
<button type="button" class="btn btn-default border border-1 w-100 filter-city-btn" data-toggle="modal"
data-parent="">
<span class="float-left">{{ trans("visiosoft.module.location::field.city.name") }}</span>
<i class="fas fa-sort-down float-right"></i>
</button>
{% set selected_cities = app.request.get('city') %}
{% set selected_cities_name = [] %}
{% for selected_city in selected_cities[0]|split(',') %}
{% set selected_cities_name = selected_cities_name|merge([getCity(selected_city|trim(',')).name]) %}
{% endfor %}
<div class="text-muted selected-city">
<small>{{ selected_cities_name|join(',') }}</small>
</div>
<input name="city[]" value="{{ app.request.get('city')|join(',') }}" type="hidden">
</div>
<div class="col-12 px-0 py-1">
<label class="label-filter-location">{{ trans("visiosoft.module.location::field.district.name") }}</label>
<select class="form-control districts" name="district" id="districts">
{% for district in params.districts %}
<option value="{{ district.id }}">{{ district.name }}</option>
{% endfor %}
</select>
<button type="button" class="btn btn-default border border-1 w-100 filter-district-btn" data-toggle="modal"
data-parent="">
<span class="float-left">{{ trans("visiosoft.module.location::field.district.name") }}</span>
<i class="fas fa-sort-down float-right"></i>
</button>
{% set selected_districts = app.request.get('district') %}
{% set selected_districts_name = [] %}
{% for selected_district in selected_districts[0]|split(',') %}
{% set selected_districts_name = selected_districts_name|merge([getDistrict(selected_district|trim(',')).name]) %}
{% endfor %}
<div class="text-muted selected-district">
<small>{{ selected_districts_name|join(',') }}</small>
</div>
<input name="district[]" value="{{ app.request.get('district')|join(',') }}" type="hidden">
</div>
<div class="col-12 px-0 py-1">
<label class="label-filter-location">{{ trans("visiosoft.module.location::field.neighborhood.name") }}</label>
<select class="form-control neighborhoods" name="neighborhood" id="neighborhoods">
{% for neighborhood in params.neighborhoods %}
<option value="{{ neighborhood.id }}">{{ neighborhood.name }}</option>
{% endfor %}
</select>
<button type="button" class="btn btn-default border border-1 w-100 filter-neighborhood-btn" data-toggle="modal"
data-parent="">
<span class="float-left">{{ trans("visiosoft.module.location::field.neighborhood.name") }}</span>
<i class="fas fa-sort-down float-right"></i>
</button>
{% set selected_neighborhoods = app.request.get('neighborhood') %}
{% set selected_neighborhoods_name = [] %}
{% for selected_neighborhood in selected_neighborhoods[0]|split(',') %}
{% set selected_neighborhoods_name = selected_neighborhoods_name|merge([getNeighborhood(selected_neighborhood|trim(',')).name]) %}
{% endfor %}
<div class="text-muted selected-neighborhood">
<small>{{ selected_neighborhoods_name|join(',') }}</small>
</div>
<input name="neighborhood[]" value="{{ app.request.get('neighborhood')|join(',') }}" type="hidden">
</div>
<div class="col-12 px-0 py-1">
<label class="label-filter-location">{{ trans("visiosoft.module.location::field.village.name") }}</label>
<select class="form-control village" name="village" id="village">
{% for village in params.villages %}
<option value="{{ village.id }}">{{ village.name }}</option>
{% endfor %}
</select>
<button type="button" class="btn btn-default border border-1 w-100 filter-village-btn" data-toggle="modal"
data-parent="">
<span class="float-left">{{ trans("visiosoft.module.location::field.village.name") }}</span>
<i class="fas fa-sort-down float-right"></i>
</button>
{% set selected_villages = app.request.get('village') %}
{% set selected_villages_name = [] %}
{% for selected_village in selected_villages[0]|split(',') %}
{% set selected_villages_name = selected_villages_name|merge([getVillage(selected_village|trim(',')).name]) %}
{% endfor %}
<div class="text-muted selected-village">
<small>{{ selected_villages_name|join(',') }}</small>
</div>
<input name="village[]" value="{{ app.request.get('village')|join(',') }}" type="hidden">
</div>
</div>
</div>
<div class="modal-content position-absolute filter-location-modal" style="z-index: 9999;display: none">
<div class="modal-header">
<input type="text" id="searchLocation" class="form-control"
placeholder="{{ trans('visiosoft.module.location::message.placeholder') }}">
<button type="button" class="close filter-modal-close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body filter-location-body">
<div class="loading"></div>
<ul class="list-unstyled countries"></ul>
<ul class="list-unstyled cities"></ul>
<ul class="list-unstyled districts"></ul>
<ul class="list-unstyled neighborhoods"></ul>
<ul class="list-unstyled village"></ul>
</div>
</div>
<div class="filter-location-back" style="display: none"></div>
<script>
var null_msg = "{{ trans('visiosoft.module.location::message.null_msg') }}!"
</script>

View File

@ -0,0 +1,106 @@
<?php namespace Visiosoft\LocationModule\Http\Controller;
use Anomaly\Streams\Platform\Http\Controller\PublicController;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\Country\CountryModel;
use Visiosoft\LocationModule\District\DistrictModel;
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
use Visiosoft\LocationModule\Village\VillageModel;
class AjaxController extends PublicController
{
/**
* @var CountryModel
*/
private $country_model;
/**
* @var CityModel
*/
private $city_model;
/**
* @var DistrictModel
*/
private $district_model;
/**
* @var NeighborhoodModel
*/
private $neighborhood_model;
/**
* @var VillageModel
*/
private $village_model;
/**
* AjaxController constructor.
* @param CountryModel $countryModel
*/
public function __construct(
CountryModel $countryModel,
CityModel $cityModel,
DistrictModel $districtModel,
NeighborhoodModel $neighborhoodModel,
VillageModel $villageModel)
{
$this->country_model = $countryModel;
$this->city_model = $cityModel;
$this->district_model = $districtModel;
$this->neighborhood_model = $neighborhoodModel;
$this->village_model = $villageModel;
parent::__construct();
}
/**
* @return mixed
*/
public function getCountries()
{
if ($this->request->id)
return $this->country_model->find($this->request->id);
else
return $this->country_model->get();
}
/**
* @return mixed
*/
public function getCities()
{
if ($this->request->id) {
$id = explode(',', $this->request->id);
return $this->city_model->whereIn('parent_country_id', $id)->get();
}
}
/**
* @return mixed
*/
public function getDistricts()
{
if ($this->request->id) {
$id = explode(',', $this->request->id);
return $this->district_model->whereIn('parent_city_id', $id)->get();
}
}
/**
* @return mixed
*/
public function getNeighborhoods()
{
if ($this->request->id) {
$id = explode(',', $this->request->id);
return $this->neighborhood_model->whereIn('parent_district_id', $id)->get();
}
}
/**
* @return mixed
*/
public function getVillage()
{
if ($this->request->id) {
$id = explode(',', $this->request->id);
return $this->village_model->whereIn('parent_neighborhood_id', $id)->get();
}
}
}

View File

@ -5,6 +5,7 @@ use Visiosoft\LocationModule\City\Command\GetCity;
use Visiosoft\LocationModule\Country\Command\GetCountry;
use Visiosoft\LocationModule\District\Command\GetDistrict;
use Visiosoft\LocationModule\Neighborhood\Command\GetNeighborhood;
use Visiosoft\LocationModule\Village\Command\GetVillage;
class LocationModulePlugin extends Plugin
{
@ -56,6 +57,17 @@ class LocationModulePlugin extends Plugin
return null;
}
return $ad;
}
),
new \Twig_SimpleFunction(
'getVillage',
function ($id) {
if (!$ad = $this->dispatch(new GetVillage($id))) {
return null;
}
return $ad;
}
),

View File

@ -75,6 +75,27 @@ class LocationModuleServiceProvider extends AddonServiceProvider
'admin/location/neighborhoods' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@index',
'admin/location/neighborhoods/create' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@create',
'admin/location/neighborhoods/edit/{id}' => 'Visiosoft\LocationModule\Http\Controller\Admin\NeighborhoodsController@edit',
'ajax/getCountry' => [
'as' => 'location::getCountry',
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getCountries'
],
'ajax/getCities' => [
'as' => 'location::getCities',
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getCities'
],
'ajax/getDistricts' => [
'as' => 'location::getDistricts',
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getDistricts'
],
'ajax/getNeighborhoods' => [
'as' => 'location::getNeighborhoods',
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getNeighborhoods'
],
'ajax/getVillage' => [
'as' => 'location::getVillage',
'uses' => 'Visiosoft\LocationModule\Http\Controller\AjaxController@getVillage'
],
];
/**

View File

@ -0,0 +1,34 @@
<?php namespace Visiosoft\LocationModule\Village\Command;
use Visiosoft\LocationModule\Village\VillageModel;
class GetVillage
{
/**
* @var $id
*/
protected $id;
/**
* GetProduct constructor.
* @param $id
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* @param VillageModel $groups
* @return |null
*/
public function handle(VillageModel $groups)
{
if ($this->id) {
return $groups->find($this->id);
}
return null;
}
}