mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 14:56:13 -06:00
Merge branch 'master' of https://github.com/openclassify/openclassify into muammertop
This commit is contained in:
commit
05fe86bdd5
@ -26,4 +26,5 @@ return [
|
|||||||
'replicated_success' => 'The ad has been replicated successfully!',
|
'replicated_success' => 'The ad has been replicated successfully!',
|
||||||
'ad_doesnt_exist' => "This ad doesn't exist!",
|
'ad_doesnt_exist' => "This ad doesn't exist!",
|
||||||
'select_location_error' => "Please select a location on the map!",
|
'select_location_error' => "Please select a location on the map!",
|
||||||
|
'this_ad_is_not_valid_anymore' => "This ad is not valid anymore!",
|
||||||
];
|
];
|
||||||
|
|||||||
@ -77,7 +77,12 @@ class AjaxController extends PublicController
|
|||||||
}
|
}
|
||||||
$my_advs = $my_advs->select(['id', 'cover_photo', 'slug', 'price', 'currency', 'city', 'country_id', 'cat1', 'cat2', 'status'])
|
$my_advs = $my_advs->select(['id', 'cover_photo', 'slug', 'price', 'currency', 'city', 'country_id', 'cat1', 'cat2', 'status'])
|
||||||
->orderByDesc('id');
|
->orderByDesc('id');
|
||||||
$my_advs = $advRepository->addAttributes($my_advs->get());
|
|
||||||
|
if (\request()->paginate === 'true') {
|
||||||
|
$my_advs = $advRepository->addAttributes($my_advs->paginate(setting_value('streams::per_page')));
|
||||||
|
} else {
|
||||||
|
$my_advs = $advRepository->addAttributes($my_advs->get());
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($my_advs as $index => $ad) {
|
foreach ($my_advs as $index => $ad) {
|
||||||
$my_advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list');
|
$my_advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list');
|
||||||
|
|||||||
@ -436,9 +436,10 @@ class AdvsController extends PublicController
|
|||||||
|
|
||||||
$user = null;
|
$user = null;
|
||||||
if (\request()->user) {
|
if (\request()->user) {
|
||||||
$user = $this->userRepository->find(\request()->user);
|
if ($user = $this->userRepository->find(\request()->user)) {
|
||||||
$showTitle = false;
|
$showTitle = false;
|
||||||
$metaTitle = $user->name() . ' ' . trans('visiosoft.module.advs::field.ads');
|
$metaTitle = $user->name() . ' ' . trans('visiosoft.module.advs::field.ads');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->set('showTitle', $showTitle);
|
$this->template->set('showTitle', $showTitle);
|
||||||
@ -484,6 +485,11 @@ class AdvsController extends PublicController
|
|||||||
$adv = $this->adv_repository->getListItemAdv($id);
|
$adv = $this->adv_repository->getListItemAdv($id);
|
||||||
|
|
||||||
if ($adv && (!$adv->expired() || $adv->created_by_id === \auth()->id())) {
|
if ($adv && (!$adv->expired() || $adv->created_by_id === \auth()->id())) {
|
||||||
|
// Check if created by exists
|
||||||
|
if (!$adv->created_by) {
|
||||||
|
$this->messages->error('visiosoft.module.advs::message.this_ad_is_not_valid_anymore');
|
||||||
|
return $this->redirect->route('visiosoft.module.advs::list');
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->adv_model->is_enabled('complaints')) {
|
if ($this->adv_model->is_enabled('complaints')) {
|
||||||
$complaints = ComplaintsComplainTypesEntryModel::all();
|
$complaints = ComplaintsComplainTypesEntryModel::all();
|
||||||
|
|||||||
@ -0,0 +1,85 @@
|
|||||||
|
let initModal = function () {
|
||||||
|
|
||||||
|
let modal = $('.modal.remote:not([data-initialized])');
|
||||||
|
|
||||||
|
let loading = '<div class="modal-loading text-center"><div class="active spinner-border spinner-border text-secondary m-5"></div></div>';
|
||||||
|
|
||||||
|
// Loading state
|
||||||
|
modal.on('loading', function() {
|
||||||
|
$(this).find('.modal-content').append(loading);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clear remote modals when closed.
|
||||||
|
modal.on('hidden.bs.modal', function () {
|
||||||
|
|
||||||
|
$(this).removeData('bs.modal');
|
||||||
|
|
||||||
|
$(this).find('.modal-content').html(loading);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show loader for remote modals.
|
||||||
|
modal.on('show.bs.modal', function () {
|
||||||
|
$(this).find('.modal-content').html(loading);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle ajax links in modals.
|
||||||
|
modal.on('click', 'a.ajax, .pagination a', function (e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
let wrapper = $(this).closest('.modal-content');
|
||||||
|
|
||||||
|
wrapper.append(loading);
|
||||||
|
|
||||||
|
$.get($(this).attr('href'), function (html) {
|
||||||
|
wrapper.html(html);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle ajax forms in modals.
|
||||||
|
modal.on('submit', 'form.ajax', function (e) {
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
let wrapper = $(this).closest('.modal-content');
|
||||||
|
|
||||||
|
wrapper.append(loading);
|
||||||
|
|
||||||
|
if ($(this).attr('method') == 'GET') {
|
||||||
|
$.get($(this).attr('action'), $(this).serializeArray(), function (html) {
|
||||||
|
wrapper.html(html);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.post($(this).attr('action'), $(this).serializeArray(), function (html) {
|
||||||
|
wrapper.html(html);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle load indicators in modals.
|
||||||
|
modal.on('click', '[data-toggle="loader"]', function () {
|
||||||
|
|
||||||
|
let wrapper = $(this).closest('.modal-content');
|
||||||
|
|
||||||
|
wrapper.append(loading);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mark as initialized.
|
||||||
|
modal.attr('data-initialized', '');
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
initModal();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ajaxComplete(function () {
|
||||||
|
initModal();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('show.bs.modal', '.modal', function () {
|
||||||
|
let zIndex = 1040 + (10 * $('.modal:visible').length);
|
||||||
|
$(this).css('z-index', zIndex);
|
||||||
|
setTimeout(function() {
|
||||||
|
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
191
addons/default/visiosoft/base-theme/resources/js/theme/search.js
Normal file
191
addons/default/visiosoft/base-theme/resources/js/theme/search.js
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
$(function () {
|
||||||
|
|
||||||
|
var form = $('#search');
|
||||||
|
var input = form.find('input');
|
||||||
|
var list = form.find('.results');
|
||||||
|
var items = list.find('a');
|
||||||
|
var selected = null;
|
||||||
|
|
||||||
|
// Don't submit on return.
|
||||||
|
form.on('submit', function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Open search
|
||||||
|
input.on('focus', function () {
|
||||||
|
form.addClass('open');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close search.
|
||||||
|
$(window).click(function () {
|
||||||
|
form.removeClass('open');
|
||||||
|
});
|
||||||
|
|
||||||
|
form.click(function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle simple searching
|
||||||
|
input.on('keydown', function (e) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture the down arrow.
|
||||||
|
*/
|
||||||
|
if (e.which == 40) {
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we have a selection then
|
||||||
|
* push to the next visible option.
|
||||||
|
*/
|
||||||
|
if (selected.nextAll('a:visible').length) {
|
||||||
|
items.removeClass('active');
|
||||||
|
selected = selected.nextAll('a:visible').first();
|
||||||
|
selected.addClass('active');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otherwise select the first
|
||||||
|
* visible option in the list.
|
||||||
|
*/
|
||||||
|
selected = items.filter('a:visible').first();
|
||||||
|
selected.addClass('active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture the up arrow.
|
||||||
|
*/
|
||||||
|
if (e.which == 38) {
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we have a selection then push
|
||||||
|
* to the previous visible option.
|
||||||
|
*/
|
||||||
|
if (selected.prevAll('a:visible').length) {
|
||||||
|
items.removeClass('active');
|
||||||
|
selected = selected.prevAll('a:visible').first();
|
||||||
|
selected.addClass('active');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otherwise select the last
|
||||||
|
* visible option in the list.
|
||||||
|
*/
|
||||||
|
selected = items.filter('a:visible').last();
|
||||||
|
selected.addClass('active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture the enter key.
|
||||||
|
*/
|
||||||
|
if (e.which == 13) {
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the key press was the return
|
||||||
|
* key and we have a selection
|
||||||
|
* then follow the link.
|
||||||
|
*/
|
||||||
|
if (selected.hasClass('has-click-event') || selected.hasClass('ajax')) {
|
||||||
|
selected.trigger('click');
|
||||||
|
} else {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If nothing is selected
|
||||||
|
* there's nothing to do.
|
||||||
|
*/
|
||||||
|
if (!selected.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If control or the meta key is
|
||||||
|
* being held open a new window.
|
||||||
|
*/
|
||||||
|
if (e.ctrlKey || e.metaKey) {
|
||||||
|
window.open(selected.attr('href'), "_blank");
|
||||||
|
} else {
|
||||||
|
window.location = selected.attr('href');
|
||||||
|
}
|
||||||
|
|
||||||
|
input.val('');
|
||||||
|
input.blur();
|
||||||
|
form.removeClass('open');
|
||||||
|
|
||||||
|
modal.find('.modal-content').append('<div class="modal-loading text-center"><div class="active spinner-border spinner-border text-secondary m-5"></div></div>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture up and down arrows.
|
||||||
|
*/
|
||||||
|
if (e.which == 38 || e.which == 40) {
|
||||||
|
|
||||||
|
// store current positions in variables
|
||||||
|
var start = input[0].selectionStart,
|
||||||
|
end = input[0].selectionEnd;
|
||||||
|
|
||||||
|
// restore from variables...
|
||||||
|
input[0].setSelectionRange(start, end);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture the escape key.
|
||||||
|
*/
|
||||||
|
if (e.which == 27) {
|
||||||
|
|
||||||
|
form.removeClass('open');
|
||||||
|
|
||||||
|
items
|
||||||
|
.show()
|
||||||
|
.removeClass('active');
|
||||||
|
|
||||||
|
input.val('').blur();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
input.on('keyup', function (e) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the keyup was a an arrow
|
||||||
|
* up or down then skip this step.
|
||||||
|
*/
|
||||||
|
if (e.which == 38 || e.which == 40) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = $(this).val();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the list by the items to
|
||||||
|
* show only those containing value.
|
||||||
|
*/
|
||||||
|
items.each(function () {
|
||||||
|
if ($(this).text().toLowerCase().indexOf(value.toLowerCase()) >= 0) {
|
||||||
|
$(this).show();
|
||||||
|
} else {
|
||||||
|
$(this).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we don't have a selected item
|
||||||
|
* then choose the first visible option.
|
||||||
|
*/
|
||||||
|
if (!selected || !selected.is(':visible')) {
|
||||||
|
selected = items.filter(':visible').first();
|
||||||
|
selected.addClass('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -17,8 +17,9 @@
|
|||||||
{{ asset_add("theme.js", "visiosoft.theme.base::js/script.js") }}
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/script.js") }}
|
||||||
|
|
||||||
{# Theme Scripts #}
|
{# Theme Scripts #}
|
||||||
{#{{ asset_add("theme.js", "visiosoft.theme.base::js/plugins/*") }}#}
|
|
||||||
{{ asset_add("theme.js", "visiosoft.theme.base::js/theme/initialize.js") }}
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/theme/initialize.js") }}
|
||||||
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/theme/search.js") }}
|
||||||
|
{{ asset_add("theme.js", "visiosoft.theme.base::js/theme/modal.js") }}
|
||||||
|
|
||||||
{{ asset_script("theme.js") }}
|
{{ asset_script("theme.js") }}
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,8 @@ return [
|
|||||||
'options' => [
|
'options' => [
|
||||||
'slug' => 'slug',
|
'slug' => 'slug',
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'order' => 'order'
|
'order' => 'order',
|
||||||
|
'name' => 'name',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\City;
|
<?php namespace Visiosoft\LocationModule\City;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Model\Location\LocationCitiesEntryTranslationsModel;
|
||||||
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||||
|
|
||||||
@ -13,18 +14,38 @@ class CityRepository extends EntryRepository implements CityRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LocationCitiesEntryTranslationsModel
|
||||||
|
*/
|
||||||
|
private $citiesEntryTranslationsModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CityRepository instance.
|
* Create a new CityRepository instance.
|
||||||
*
|
*
|
||||||
* @param CityModel $model
|
* @param CityModel $model
|
||||||
*/
|
*/
|
||||||
public function __construct(CityModel $model)
|
public function __construct(CityModel $model, LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
|
$this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findById($id)
|
public function findById($id)
|
||||||
{
|
{
|
||||||
return $this->model->orderBy('created_at', 'DESC')->where('location_cities.id', $id)->first();
|
return $this->model->orderBy('created_at', 'DESC')->where('location_cities.id', $id)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc')
|
||||||
|
{
|
||||||
|
return $this->citiesEntryTranslationsModel->newQuery()
|
||||||
|
->select('entry_id as id', 'name')
|
||||||
|
->whereIn('locale', [
|
||||||
|
Request()->session()->get('_locale'),
|
||||||
|
setting_value('streams::default_locale'),
|
||||||
|
'en'
|
||||||
|
])
|
||||||
|
->whereIn('entry_id', $entryIDs)
|
||||||
|
->orderBy($orderBy, $direction)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
|||||||
interface CityRepositoryInterface extends EntryRepositoryInterface
|
interface CityRepositoryInterface extends EntryRepositoryInterface
|
||||||
{
|
{
|
||||||
public function findById($id);
|
public function findById($id);
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,6 @@ interface CountryRepositoryInterface extends EntryRepositoryInterface
|
|||||||
public function findById($id);
|
public function findById($id);
|
||||||
|
|
||||||
public function viewAll();
|
public function viewAll();
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\Country;
|
<?php namespace Visiosoft\LocationModule\Country;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Model\Location\LocationCountriesEntryTranslationsModel;
|
||||||
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||||
|
|
||||||
@ -13,14 +14,23 @@ class CountryRepository extends EntryRepository implements CountryRepositoryInte
|
|||||||
*/
|
*/
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LocationCountriesEntryTranslationsModel
|
||||||
|
*/
|
||||||
|
private $countriesEntryTranslationsModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CountryRepository instance.
|
* Create a new CountryRepository instance.
|
||||||
*
|
*
|
||||||
* @param CountryModel $model
|
* @param CountryModel $model
|
||||||
*/
|
*/
|
||||||
public function __construct(CountryModel $model)
|
public function __construct(
|
||||||
|
CountryModel $model,
|
||||||
|
LocationCountriesEntryTranslationsModel $countriesEntryTranslationsModel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
|
$this->countriesEntryTranslationsModel = $countriesEntryTranslationsModel;
|
||||||
}
|
}
|
||||||
public function findById($id)
|
public function findById($id)
|
||||||
{
|
{
|
||||||
@ -30,4 +40,18 @@ class CountryRepository extends EntryRepository implements CountryRepositoryInte
|
|||||||
public function viewAll(){
|
public function viewAll(){
|
||||||
return $this->model->get();
|
return $this->model->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc')
|
||||||
|
{
|
||||||
|
return $this->countriesEntryTranslationsModel->newQuery()
|
||||||
|
->select('entry_id as id', 'name')
|
||||||
|
->whereIn('locale', [
|
||||||
|
Request()->session()->get('_locale'),
|
||||||
|
setting_value('streams::default_locale'),
|
||||||
|
'en'
|
||||||
|
])
|
||||||
|
->whereIn('entry_id', $entryIDs)
|
||||||
|
->orderBy($orderBy, $direction)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
|||||||
|
|
||||||
interface DistrictRepositoryInterface extends EntryRepositoryInterface
|
interface DistrictRepositoryInterface extends EntryRepositoryInterface
|
||||||
{
|
{
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\District;
|
<?php namespace Visiosoft\LocationModule\District;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Model\Location\LocationDistrictsEntryTranslationsModel;
|
||||||
use Visiosoft\LocationModule\District\Contract\DistrictRepositoryInterface;
|
use Visiosoft\LocationModule\District\Contract\DistrictRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||||
|
|
||||||
@ -13,13 +14,36 @@ class DistrictRepository extends EntryRepository implements DistrictRepositoryIn
|
|||||||
*/
|
*/
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LocationDistrictsEntryTranslationsModel
|
||||||
|
*/
|
||||||
|
private $districtsEntryTranslationsModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new DistrictRepository instance.
|
* Create a new DistrictRepository instance.
|
||||||
*
|
*
|
||||||
* @param DistrictModel $model
|
* @param DistrictModel $model
|
||||||
*/
|
*/
|
||||||
public function __construct(DistrictModel $model)
|
public function __construct(
|
||||||
|
DistrictModel $model,
|
||||||
|
LocationDistrictsEntryTranslationsModel $districtsEntryTranslationsModel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
|
$this->districtsEntryTranslationsModel = $districtsEntryTranslationsModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc')
|
||||||
|
{
|
||||||
|
return $this->districtsEntryTranslationsModel->newQuery()
|
||||||
|
->select('entry_id as id', 'name')
|
||||||
|
->whereIn('locale', [
|
||||||
|
Request()->session()->get('_locale'),
|
||||||
|
setting_value('streams::default_locale'),
|
||||||
|
'en'
|
||||||
|
])
|
||||||
|
->whereIn('entry_id', $entryIDs)
|
||||||
|
->orderBy($orderBy, $direction)
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,131 +1,95 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\Http\Controller;
|
<?php namespace Visiosoft\LocationModule\Http\Controller;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||||
use Visiosoft\LocationModule\City\CityModel;
|
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
||||||
use Visiosoft\LocationModule\Country\CountryModel;
|
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
||||||
use Visiosoft\LocationModule\District\DistrictModel;
|
use Visiosoft\LocationModule\District\Contract\DistrictRepositoryInterface;
|
||||||
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
|
use Visiosoft\LocationModule\Neighborhood\Contract\NeighborhoodRepositoryInterface;
|
||||||
use Visiosoft\LocationModule\Village\VillageModel;
|
use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class AjaxController extends PublicController
|
class AjaxController extends PublicController
|
||||||
{
|
{
|
||||||
/**
|
private $cityRepository;
|
||||||
* @var CountryModel
|
private $countryRepository;
|
||||||
*/
|
private $districtRepository;
|
||||||
private $country_model;
|
private $neighborhoodRepository;
|
||||||
/**
|
private $villageRepository;
|
||||||
* @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(
|
public function __construct(
|
||||||
CountryModel $countryModel,
|
CityRepositoryInterface $cityRepository,
|
||||||
CityModel $cityModel,
|
CountryRepositoryInterface $countryRepository,
|
||||||
DistrictModel $districtModel,
|
DistrictRepositoryInterface $districtRepository,
|
||||||
NeighborhoodModel $neighborhoodModel,
|
NeighborhoodRepositoryInterface $neighborhoodRepository,
|
||||||
VillageModel $villageModel)
|
VillageRepositoryInterface $villageRepository
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->country_model = $countryModel;
|
|
||||||
$this->city_model = $cityModel;
|
|
||||||
$this->district_model = $districtModel;
|
|
||||||
$this->neighborhood_model = $neighborhoodModel;
|
|
||||||
$this->village_model = $villageModel;
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->cityRepository = $cityRepository;
|
||||||
|
$this->countryRepository = $countryRepository;
|
||||||
|
$this->districtRepository = $districtRepository;
|
||||||
|
$this->neighborhoodRepository = $neighborhoodRepository;
|
||||||
|
$this->villageRepository = $villageRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCountries()
|
public function getCountries()
|
||||||
{
|
{
|
||||||
if ($this->request->id)
|
if ($this->request->id)
|
||||||
return $this->country_model->find($this->request->id);
|
return $this->countryRepository->getModel()->find($this->request->id);
|
||||||
else {
|
else {
|
||||||
$query = $this->country_model;
|
$query = $this->countryRepository->getModel();
|
||||||
return $this->queryOrder($query);
|
return $this->queryOrder($query, $this->countryRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCities()
|
public function getCities()
|
||||||
{
|
{
|
||||||
if ($this->request->id) {
|
if ($this->request->id) {
|
||||||
$id = explode(',', $this->request->id);
|
$id = explode(',', $this->request->id);
|
||||||
$query = $this->city_model->whereIn('parent_country_id', $id);
|
$query = $this->cityRepository->getModel()->whereIn('parent_country_id', $id);
|
||||||
|
|
||||||
return $this->queryOrder($query);
|
return $this->queryOrder($query, $this->cityRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getDistricts()
|
public function getDistricts()
|
||||||
{
|
{
|
||||||
if ($this->request->id) {
|
if ($this->request->id) {
|
||||||
$id = explode(',', $this->request->id);
|
$id = explode(',', $this->request->id);
|
||||||
|
|
||||||
$query = $this->district_model->whereIn('parent_city_id', $id);
|
$query = $this->districtRepository->getModel()->whereIn('parent_city_id', $id);
|
||||||
|
|
||||||
return $this->queryOrder($query);
|
return $this->queryOrder($query, $this->districtRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getNeighborhoods()
|
public function getNeighborhoods()
|
||||||
{
|
{
|
||||||
if ($this->request->id) {
|
if ($this->request->id) {
|
||||||
$id = explode(',', $this->request->id);
|
$id = explode(',', $this->request->id);
|
||||||
|
|
||||||
$query = $this->neighborhood_model->whereIn('parent_district_id', $id);
|
$query = $this->neighborhoodRepository->getModel()->whereIn('parent_district_id', $id);
|
||||||
|
|
||||||
return $this->queryOrder($query);
|
return $this->queryOrder($query, $this->neighborhoodRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getVillage()
|
public function getVillage()
|
||||||
{
|
{
|
||||||
if ($this->request->id) {
|
if ($this->request->id) {
|
||||||
$id = explode(',', $this->request->id);
|
$id = explode(',', $this->request->id);
|
||||||
|
|
||||||
$query = $this->village_model->whereIn('parent_neighborhood_id', $id);
|
$query = $this->villageRepository->getModel()->whereIn('parent_neighborhood_id', $id);
|
||||||
|
|
||||||
return $this->queryOrder($query);
|
return $this->queryOrder($query, $this->villageRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCity()
|
public function getCity()
|
||||||
{
|
{
|
||||||
if ($this->request->name) {
|
if ($this->request->name) {
|
||||||
$slug = Str::slug($this->request->name, '_');
|
$slug = Str::slug($this->request->name, '_');
|
||||||
if ($city = $this->city_model->newQuery()->where('slug', 'LIKE', $slug . '%')->first()) {
|
if ($city = $this->cityRepository->getModel()->newQuery()->where('slug', 'LIKE', $slug . '%')->first()) {
|
||||||
return ['success' => true, 'city' => $city];
|
return ['success' => true, 'city' => $city];
|
||||||
} else {
|
} else {
|
||||||
return ['success' => false];
|
return ['success' => false];
|
||||||
@ -133,11 +97,19 @@ class AjaxController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function queryOrder($query)
|
public function queryOrder($query, $repository)
|
||||||
{
|
{
|
||||||
$sorting_type = setting_value('visiosoft.module.location::sorting_type');
|
$sorting_type = setting_value('visiosoft.module.location::sorting_type');
|
||||||
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
|
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
|
||||||
|
|
||||||
|
if ($repository->getModel()->isTranslatedAttribute($sorting_column)) {
|
||||||
|
return $repository->getByEntryIDsAndOrderByTransCol(
|
||||||
|
$query->pluck('id')->all(),
|
||||||
|
$sorting_column,
|
||||||
|
$sorting_type
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $query->orderBy($sorting_column, $sorting_type)->get();
|
return $query->orderBy($sorting_column, $sorting_type)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
|||||||
|
|
||||||
interface NeighborhoodRepositoryInterface extends EntryRepositoryInterface
|
interface NeighborhoodRepositoryInterface extends EntryRepositoryInterface
|
||||||
{
|
{
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\Neighborhood;
|
<?php namespace Visiosoft\LocationModule\Neighborhood;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Model\Location\LocationNeighborhoodsEntryTranslationsModel;
|
||||||
use Visiosoft\LocationModule\Neighborhood\Contract\NeighborhoodRepositoryInterface;
|
use Visiosoft\LocationModule\Neighborhood\Contract\NeighborhoodRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||||
|
|
||||||
@ -13,13 +14,36 @@ class NeighborhoodRepository extends EntryRepository implements NeighborhoodRepo
|
|||||||
*/
|
*/
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LocationNeighborhoodsEntryTranslationsModel
|
||||||
|
*/
|
||||||
|
private $neighborhoodsEntryTranslationsModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new NeighborhoodRepository instance.
|
* Create a new NeighborhoodRepository instance.
|
||||||
*
|
*
|
||||||
* @param NeighborhoodModel $model
|
* @param NeighborhoodModel $model
|
||||||
*/
|
*/
|
||||||
public function __construct(NeighborhoodModel $model)
|
public function __construct(
|
||||||
|
NeighborhoodModel $model,
|
||||||
|
LocationNeighborhoodsEntryTranslationsModel $neighborhoodsEntryTranslationsModel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
|
$this->neighborhoodsEntryTranslationsModel = $neighborhoodsEntryTranslationsModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc')
|
||||||
|
{
|
||||||
|
return $this->neighborhoodsEntryTranslationsModel->newQuery()
|
||||||
|
->select('entry_id as id', 'name')
|
||||||
|
->whereIn('locale', [
|
||||||
|
Request()->session()->get('_locale'),
|
||||||
|
setting_value('streams::default_locale'),
|
||||||
|
'en'
|
||||||
|
])
|
||||||
|
->whereIn('entry_id', $entryIDs)
|
||||||
|
->orderBy($orderBy, $direction)
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
|||||||
|
|
||||||
interface VillageRepositoryInterface extends EntryRepositoryInterface
|
interface VillageRepositoryInterface extends EntryRepositoryInterface
|
||||||
{
|
{
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\Village;
|
<?php namespace Visiosoft\LocationModule\Village;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Model\Location\LocationVillageEntryTranslationsModel;
|
||||||
use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
|
use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||||
|
|
||||||
@ -13,13 +14,36 @@ class VillageRepository extends EntryRepository implements VillageRepositoryInte
|
|||||||
*/
|
*/
|
||||||
protected $model;
|
protected $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LocationVillageEntryTranslationsModel
|
||||||
|
*/
|
||||||
|
private $villageEntryTranslationsModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new VillageRepository instance.
|
* Create a new VillageRepository instance.
|
||||||
*
|
*
|
||||||
* @param VillageModel $model
|
* @param VillageModel $model
|
||||||
*/
|
*/
|
||||||
public function __construct(VillageModel $model)
|
public function __construct(
|
||||||
|
VillageModel $model,
|
||||||
|
LocationVillageEntryTranslationsModel $villageEntryTranslationsModel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
|
$this->villageEntryTranslationsModel = $villageEntryTranslationsModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc')
|
||||||
|
{
|
||||||
|
return $this->villageEntryTranslationsModel->newQuery()
|
||||||
|
->select('entry_id as id', 'name')
|
||||||
|
->whereIn('locale', [
|
||||||
|
Request()->session()->get('_locale'),
|
||||||
|
setting_value('streams::default_locale'),
|
||||||
|
'en'
|
||||||
|
])
|
||||||
|
->whereIn('entry_id', $entryIDs)
|
||||||
|
->orderBy($orderBy, $direction)
|
||||||
|
->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,18 +3,19 @@ var records_per_page = ads_per_page;
|
|||||||
var ads_type = "";
|
var ads_type = "";
|
||||||
|
|
||||||
var objJson = [];
|
var objJson = [];
|
||||||
|
let totalAdvs = 0
|
||||||
|
|
||||||
function prevPage() {
|
function prevPage() {
|
||||||
if (current_page > 1) {
|
if (current_page > 1) {
|
||||||
current_page--;
|
current_page--;
|
||||||
changePage(current_page);
|
getMyAdvs(ads_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextPage(event) {
|
function nextPage(event) {
|
||||||
if (current_page < numPages()) {
|
if (current_page < numPages()) {
|
||||||
current_page++;
|
current_page++;
|
||||||
changePage(current_page);
|
getMyAdvs(ads_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,17 +31,21 @@ function changePage(page) {
|
|||||||
|
|
||||||
listing_table.html("");
|
listing_table.html("");
|
||||||
|
|
||||||
if (objJson.length == 0) {
|
if (objJson.length === 0) {
|
||||||
listing_table.html('<div class="alert alert-warning" role="alert">' +
|
listing_table.html(`
|
||||||
no_ads_message +
|
<div class="alert alert-warning" role="alert">
|
||||||
'</div>');
|
${no_ads_message}
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
for (var i = (page - 1) * records_per_page; i < (page * records_per_page) && i < objJson.length; i++) {
|
for (var i = 0; i < objJson.length; i++) {
|
||||||
listing_table.append(addAdsRow(objJson[i].id, objJson[i].detail_url, objJson[i].cover_photo, objJson[i].name,
|
listing_table.append(addAdsRow(objJson[i].id, objJson[i].detail_url, objJson[i].cover_photo, objJson[i].name,
|
||||||
objJson[i].formatted_price, objJson[i].city_name, objJson[i].country_name, objJson[i].cat1_name,
|
objJson[i].formatted_price, objJson[i].city_name, objJson[i].country_name, objJson[i].cat1_name,
|
||||||
objJson[i].cat2_name, objJson[i].status));
|
objJson[i].cat2_name, objJson[i].status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDropdownBlock()
|
||||||
|
|
||||||
page_span.html(page + "/" + numPages());
|
page_span.html(page + "/" + numPages());
|
||||||
|
|
||||||
if (numPages() === 1) {
|
if (numPages() === 1) {
|
||||||
@ -63,7 +68,7 @@ function changePage(page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function numPages() {
|
function numPages() {
|
||||||
return Math.ceil(objJson.length / records_per_page);
|
return Math.ceil(totalAdvs / records_per_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
function crud(params, url, type, callback) {
|
function crud(params, url, type, callback) {
|
||||||
@ -78,15 +83,16 @@ function crud(params, url, type, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMyAdvs(type) {
|
function getMyAdvs(type) {
|
||||||
crud({'type': type}, '/ajax/getAdvs', 'GET', function (callback) {
|
crud({'type': type, 'paginate': true, 'page': current_page}, '/ajax/getAdvs', 'GET', function (callback) {
|
||||||
ads_type = type;
|
ads_type = type;
|
||||||
current_page = 1;
|
objJson = callback.content.data;
|
||||||
objJson = callback.content;
|
totalAdvs = callback.content.total
|
||||||
changePage(1);
|
changePage(current_page);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.profile-advs-tab a').on('click', function () {
|
$('.profile-advs-tab a').on('click', function () {
|
||||||
|
current_page = 1
|
||||||
getMyAdvs($(this).attr('data-type'))
|
getMyAdvs($(this).attr('data-type'))
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,7 +134,7 @@ function addAdsRow(id, href, image, name, formatted_price, city, country, cat1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dropdownRow(id, type) {
|
function dropdownRow(id, type) {
|
||||||
var dropdown = "<div class='dropdown'>\n" +
|
var dropdown = "<div class='dropdown my-ads-dropdown' data-id='" + id + "'>\n" +
|
||||||
" <button class='dropdown-toggle btn btn-outline-dark' type='button' id='dropdownMenuButton' data-toggle='dropdown'>\n" +
|
" <button class='dropdown-toggle btn btn-outline-dark' type='button' id='dropdownMenuButton' data-toggle='dropdown'>\n" +
|
||||||
"<i class=\"fas fa-ellipsis-v\"></i>" +
|
"<i class=\"fas fa-ellipsis-v\"></i>" +
|
||||||
" </button>\n" +
|
" </button>\n" +
|
||||||
@ -160,7 +166,16 @@ function dropdownRow(id, type) {
|
|||||||
extend_ad +
|
extend_ad +
|
||||||
"</a>\n";
|
"</a>\n";
|
||||||
|
|
||||||
dropdown += getBlock('profile/dropdown-ad', {'id': id}) + "</div></div>";
|
dropdown += "</div></div>";
|
||||||
return dropdown;
|
|
||||||
|
|
||||||
}
|
return dropdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dropdownBlock = getBlock('profile/dropdown-ad', {'id': ':id'})
|
||||||
|
function addDropdownBlock () {
|
||||||
|
const dropdowns = $('.my-ads-dropdown')
|
||||||
|
for (let i = 0; i < dropdowns.length; i++) {
|
||||||
|
const currentDropdown = $(dropdowns[i])
|
||||||
|
$('.dropdown-menu', currentDropdown).append(dropdownBlock.replace(':id', currentDropdown.data('id')))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -64,9 +64,6 @@ $(function () {
|
|||||||
var response = JSON.parse(file.xhr.response);
|
var response = JSON.parse(file.xhr.response);
|
||||||
|
|
||||||
uploaded.push(response.id);
|
uploaded.push(response.id);
|
||||||
$('[data-provides="visiosoft.field_type.singlefile"]').val(response.id)
|
|
||||||
$('#file-modal').modal('hide');
|
|
||||||
$('#profile-detail').submit();
|
|
||||||
|
|
||||||
file.previewElement.querySelector('[data-dz-uploadprogress]').setAttribute('class', 'progress progress-success');
|
file.previewElement.querySelector('[data-dz-uploadprogress]').setAttribute('class', 'progress progress-success');
|
||||||
|
|
||||||
@ -83,4 +80,12 @@ $(function () {
|
|||||||
|
|
||||||
alert(message.error ? message.error : message);
|
alert(message.error ? message.error : message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// When all files are processed.
|
||||||
|
dropzone.on('queuecomplete', function () {
|
||||||
|
|
||||||
|
uploader.find('.uploaded .modal-body').html(element.data('loading') + '...');
|
||||||
|
|
||||||
|
uploader.find('.uploaded').load(REQUEST_ROOT_PATH + '/streams/singlefile-field_type/recent?uploaded=' + uploaded.join(','));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user