From 8f02472331ec794445b2143f20a47faf3cd854c7 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Fri, 13 Nov 2020 13:36:35 +0300 Subject: [PATCH 01/13] =?UTF-8?q?#2647=20emlak24=20yap=C4=B1lacaklar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Http/Controller/AjaxController.php | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php index 0ac30691e..89f057d97 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php @@ -1,6 +1,7 @@ country_model = $countryModel; $this->city_model = $cityModel; @@ -48,6 +55,7 @@ class AjaxController extends PublicController $this->neighborhood_model = $neighborhoodModel; $this->village_model = $villageModel; parent::__construct(); + $this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel; } /** @@ -72,6 +80,21 @@ class AjaxController extends PublicController $id = explode(',', $this->request->id); $query = $this->city_model->whereIn('parent_country_id', $id); + if (request()->order_by && $this->city_model->isTranslatedAttribute(request()->order_by)) { + 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', $query->pluck('id')->all()) + ->orderBy(request()->order_by) + ->get(); + } elseif ($orderBy = request()->order_by) { + return $this->queryOrder($query, $orderBy); + } + return $this->queryOrder($query); } } @@ -133,10 +156,10 @@ class AjaxController extends PublicController } } - public function queryOrder($query) + public function queryOrder($query, $orderBy = null) { $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = setting_value('visiosoft.module.location::sorting_column'); + $sorting_column = $orderBy ?: setting_value('visiosoft.module.location::sorting_column'); return $query->orderBy($sorting_column, $sorting_type)->get(); } From 4a25e7834ad5f79777a2b63e470b306976a843b6 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Fri, 13 Nov 2020 13:44:28 +0300 Subject: [PATCH 02/13] =?UTF-8?q?#2647=20emlak24=20yap=C4=B1lacaklar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/City/CityRepository.php | 23 ++++++- .../City/Contract/CityRepositoryInterface.php | 2 + .../src/Http/Controller/AjaxController.php | 62 +++---------------- 3 files changed, 34 insertions(+), 53 deletions(-) diff --git a/addons/default/visiosoft/location-module/src/City/CityRepository.php b/addons/default/visiosoft/location-module/src/City/CityRepository.php index 02350097f..9a1fd8147 100644 --- a/addons/default/visiosoft/location-module/src/City/CityRepository.php +++ b/addons/default/visiosoft/location-module/src/City/CityRepository.php @@ -1,5 +1,6 @@ model = $model; + $this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel; } public function findById($id) { return $this->model->orderBy('created_at', 'DESC')->where('location_cities.id', $id)->first(); } + + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy) + { + 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) + ->get(); + } } diff --git a/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php b/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php index 78f8e25c6..7b4f3520d 100644 --- a/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php @@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface CityRepositoryInterface extends EntryRepositoryInterface { public function findById($id); + + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy); } diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php index 89f057d97..ceedd10b7 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php @@ -3,6 +3,7 @@ use Anomaly\Streams\Platform\Http\Controller\PublicController; use Anomaly\Streams\Platform\Model\Location\LocationCitiesEntryTranslationsModel; use Visiosoft\LocationModule\City\CityModel; +use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface; use Visiosoft\LocationModule\Country\CountryModel; use Visiosoft\LocationModule\District\DistrictModel; use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel; @@ -11,56 +12,34 @@ use Illuminate\Support\Str; 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; - /** - * @var LocationCitiesEntryTranslationsModel - */ private $citiesEntryTranslationsModel; + private $cityRepository; - /** - * AjaxController constructor. - * @param CountryModel $countryModel - */ public function __construct( CountryModel $countryModel, CityModel $cityModel, DistrictModel $districtModel, NeighborhoodModel $neighborhoodModel, VillageModel $villageModel, - LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel + LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel, + CityRepositoryInterface $cityRepository ) { + parent::__construct(); $this->country_model = $countryModel; $this->city_model = $cityModel; $this->district_model = $districtModel; $this->neighborhood_model = $neighborhoodModel; $this->village_model = $villageModel; - parent::__construct(); $this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel; + $this->cityRepository = $cityRepository; } - /** - * @return mixed - */ public function getCountries() { if ($this->request->id) @@ -71,9 +50,6 @@ class AjaxController extends PublicController } } - /** - * @return mixed - */ public function getCities() { if ($this->request->id) { @@ -81,16 +57,10 @@ class AjaxController extends PublicController $query = $this->city_model->whereIn('parent_country_id', $id); if (request()->order_by && $this->city_model->isTranslatedAttribute(request()->order_by)) { - 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', $query->pluck('id')->all()) - ->orderBy(request()->order_by) - ->get(); + return $this->cityRepository->getByEntryIDsAndOrderByTransCol( + $query->pluck('id')->all(), + request()->order_by + ); } elseif ($orderBy = request()->order_by) { return $this->queryOrder($query, $orderBy); } @@ -99,9 +69,6 @@ class AjaxController extends PublicController } } - /** - * @return mixed - */ public function getDistricts() { if ($this->request->id) { @@ -113,9 +80,6 @@ class AjaxController extends PublicController } } - /** - * @return mixed - */ public function getNeighborhoods() { if ($this->request->id) { @@ -127,9 +91,6 @@ class AjaxController extends PublicController } } - /** - * @return mixed - */ public function getVillage() { if ($this->request->id) { @@ -141,9 +102,6 @@ class AjaxController extends PublicController } } - /** - * @return mixed - */ public function getCity() { if ($this->request->name) { From 4cb3254dc61d2c44d055319e67b3cf67a648e32f Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 10:15:07 +0300 Subject: [PATCH 03/13] #2622 ad list filter by user error --- .../advs-module/src/Http/Controller/advsController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 5c1db1afd..f46783a6e 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -436,9 +436,10 @@ class AdvsController extends PublicController $user = null; if (\request()->user) { - $user = $this->userRepository->find(\request()->user); - $showTitle = false; - $metaTitle = $user->name() . ' ' . trans('visiosoft.module.advs::field.ads'); + if ($user = $this->userRepository->find(\request()->user)) { + $showTitle = false; + $metaTitle = $user->name() . ' ' . trans('visiosoft.module.advs::field.ads'); + } } $this->template->set('showTitle', $showTitle); From db956ca7e004748c2cb12738a0584bfd023e6ba8 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 10:41:40 +0300 Subject: [PATCH 04/13] changes --- .../location-module/resources/config/settings/settings.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/default/visiosoft/location-module/resources/config/settings/settings.php b/addons/default/visiosoft/location-module/resources/config/settings/settings.php index cc295bd84..e3c06b3c8 100644 --- a/addons/default/visiosoft/location-module/resources/config/settings/settings.php +++ b/addons/default/visiosoft/location-module/resources/config/settings/settings.php @@ -94,7 +94,8 @@ return [ 'options' => [ 'slug' => 'slug', 'id' => 'id', - 'order' => 'order' + 'order' => 'order', + 'name' => 'name', ], ], ], From cb407b380b669358f75de5f0c844c3b769cfbaa8 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 11:07:07 +0300 Subject: [PATCH 05/13] store --- .../src/City/CityRepository.php | 4 +- .../City/Contract/CityRepositoryInterface.php | 2 +- .../Contract/CountryRepositoryInterface.php | 2 + .../src/Country/CountryRepository.php | 26 +++++- .../Contract/DistrictRepositoryInterface.php | 2 +- .../src/District/DistrictRepository.php | 26 +++++- .../src/Http/Controller/AjaxController.php | 87 +++++++++---------- .../NeighborhoodRepositoryInterface.php | 2 +- .../Neighborhood/NeighborhoodRepository.php | 26 +++++- .../Contract/VillageRepositoryInterface.php | 2 +- .../src/Village/VillageRepository.php | 26 +++++- 11 files changed, 147 insertions(+), 58 deletions(-) diff --git a/addons/default/visiosoft/location-module/src/City/CityRepository.php b/addons/default/visiosoft/location-module/src/City/CityRepository.php index 9a1fd8147..26c711983 100644 --- a/addons/default/visiosoft/location-module/src/City/CityRepository.php +++ b/addons/default/visiosoft/location-module/src/City/CityRepository.php @@ -35,7 +35,7 @@ class CityRepository extends EntryRepository implements CityRepositoryInterface return $this->model->orderBy('created_at', 'DESC')->where('location_cities.id', $id)->first(); } - public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy) + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc') { return $this->citiesEntryTranslationsModel->newQuery() ->select('entry_id as id', 'name') @@ -45,7 +45,7 @@ class CityRepository extends EntryRepository implements CityRepositoryInterface 'en' ]) ->whereIn('entry_id', $entryIDs) - ->orderBy($orderBy) + ->orderBy($orderBy, $direction) ->get(); } } diff --git a/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php b/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php index 7b4f3520d..2e8993d9d 100644 --- a/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php @@ -6,5 +6,5 @@ interface CityRepositoryInterface extends EntryRepositoryInterface { public function findById($id); - public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy); + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); } diff --git a/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php b/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php index 6bdc2fed1..b4659e6ac 100644 --- a/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php @@ -7,4 +7,6 @@ interface CountryRepositoryInterface extends EntryRepositoryInterface public function findById($id); public function viewAll(); + + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); } diff --git a/addons/default/visiosoft/location-module/src/Country/CountryRepository.php b/addons/default/visiosoft/location-module/src/Country/CountryRepository.php index dd1f6d455..a8a25a6e2 100644 --- a/addons/default/visiosoft/location-module/src/Country/CountryRepository.php +++ b/addons/default/visiosoft/location-module/src/Country/CountryRepository.php @@ -1,5 +1,6 @@ model = $model; + $this->countriesEntryTranslationsModel = $countriesEntryTranslationsModel; } public function findById($id) { @@ -30,4 +40,18 @@ class CountryRepository extends EntryRepository implements CountryRepositoryInte public function viewAll(){ 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(); + } } diff --git a/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php b/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php index 40f36e204..465cb1a16 100644 --- a/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php @@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface DistrictRepositoryInterface extends EntryRepositoryInterface { - + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); } diff --git a/addons/default/visiosoft/location-module/src/District/DistrictRepository.php b/addons/default/visiosoft/location-module/src/District/DistrictRepository.php index e84861e8d..3790d78f9 100644 --- a/addons/default/visiosoft/location-module/src/District/DistrictRepository.php +++ b/addons/default/visiosoft/location-module/src/District/DistrictRepository.php @@ -1,5 +1,6 @@ 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(); } } diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php index ceedd10b7..09f26662d 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/AjaxController.php @@ -1,52 +1,44 @@ country_model = $countryModel; - $this->city_model = $cityModel; - $this->district_model = $districtModel; - $this->neighborhood_model = $neighborhoodModel; - $this->village_model = $villageModel; - $this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel; $this->cityRepository = $cityRepository; + $this->countryRepository = $countryRepository; + $this->districtRepository = $districtRepository; + $this->neighborhoodRepository = $neighborhoodRepository; + $this->villageRepository = $villageRepository; } public function getCountries() { if ($this->request->id) - return $this->country_model->find($this->request->id); + return $this->countryRepository->getModel()->find($this->request->id); else { - $query = $this->country_model; - return $this->queryOrder($query); + $query = $this->countryRepository->getModel(); + return $this->queryOrder($query, $this->countryRepository); } } @@ -54,18 +46,9 @@ class AjaxController extends PublicController { if ($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); - if (request()->order_by && $this->city_model->isTranslatedAttribute(request()->order_by)) { - return $this->cityRepository->getByEntryIDsAndOrderByTransCol( - $query->pluck('id')->all(), - request()->order_by - ); - } elseif ($orderBy = request()->order_by) { - return $this->queryOrder($query, $orderBy); - } - - return $this->queryOrder($query); + return $this->queryOrder($query, $this->cityRepository); } } @@ -74,9 +57,9 @@ class AjaxController extends PublicController if ($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); } } @@ -85,9 +68,9 @@ class AjaxController extends PublicController if ($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); } } @@ -96,9 +79,9 @@ class AjaxController extends PublicController if ($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); } } @@ -106,7 +89,7 @@ class AjaxController extends PublicController { if ($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]; } else { return ['success' => false]; @@ -114,10 +97,18 @@ class AjaxController extends PublicController } } - public function queryOrder($query, $orderBy = null) + public function queryOrder($query, $repository) { $sorting_type = setting_value('visiosoft.module.location::sorting_type'); - $sorting_column = $orderBy ?: 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(); } diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php b/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php index f5f46fc69..f1dceaf15 100644 --- a/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php @@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface NeighborhoodRepositoryInterface extends EntryRepositoryInterface { - + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); } diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php b/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php index c4d91bcba..75023993e 100644 --- a/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php +++ b/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php @@ -1,5 +1,6 @@ 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(); } } diff --git a/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php b/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php index 3b386057f..65f259fdf 100644 --- a/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php @@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface VillageRepositoryInterface extends EntryRepositoryInterface { - + public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); } diff --git a/addons/default/visiosoft/location-module/src/Village/VillageRepository.php b/addons/default/visiosoft/location-module/src/Village/VillageRepository.php index 15dc0fc1a..4f7d64d9b 100644 --- a/addons/default/visiosoft/location-module/src/Village/VillageRepository.php +++ b/addons/default/visiosoft/location-module/src/Village/VillageRepository.php @@ -1,5 +1,6 @@ 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(); } } From 503add2963ea5113bd4593872b5cf887682dffc7 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 11:36:28 +0300 Subject: [PATCH 06/13] #2609 ad detail error when store not installed --- addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php b/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php index 1f0aaa106..38b99bb8f 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php @@ -62,7 +62,7 @@ class AdvPresenter extends EntryPresenter public function isCorporate() { $user_id = $this->getObject()->created_by; - if ($user_id->register_type != null) { + if ($user_id && $user_id->register_type != null) { return $user_id->register_type; } else { return 1; From b9f1d8ce6015341e71a248d1292abda7a2d854ec Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 11:55:03 +0300 Subject: [PATCH 07/13] #2615 oc.com - SEO - Multiple title tags --- .../resources/views/partials/metatags.twig | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig b/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig index 017843463..1fa36d1ca 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig @@ -12,13 +12,15 @@ {% set additionalMeta = template.get('additional_meta') %} {{ additionalMeta ? additionalMeta|raw }} - - {% set title = trans(template.meta_title) %} - {% set showTitle = template.showTitle is same as(false) ? false : true %} - {% if showTitle %} - {% set title = setting_value('streams::name', config_get('streams::distribution.name'))~" | "~trans(template.meta_title) %} - {% endif %} - {{ title|slice(0,60) }} - +{% if not hideTitle %} + + {% set title = trans(template.meta_title) %} + {% set showTitle = template.showTitle is same as(false) ? false : true %} + {% if showTitle %} + {% set title = setting_value('streams::name', config_get('streams::distribution.name'))~" | "~trans(template.meta_title) %} + {% endif %} + {{ title|slice(0,60) }} + +{% endif %} {% include "visiosoft.theme.base::partials/ogdata" %} From 28eea42c6598c87bcd679d9e92849f74e9669c05 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 12:00:38 +0300 Subject: [PATCH 08/13] #2615 oc.com - SEO - Multiple title tags --- .../resources/views/partials/metatags.twig | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig b/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig index 1fa36d1ca..017843463 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/metatags.twig @@ -12,15 +12,13 @@ {% set additionalMeta = template.get('additional_meta') %} {{ additionalMeta ? additionalMeta|raw }} -{% if not hideTitle %} - - {% set title = trans(template.meta_title) %} - {% set showTitle = template.showTitle is same as(false) ? false : true %} - {% if showTitle %} - {% set title = setting_value('streams::name', config_get('streams::distribution.name'))~" | "~trans(template.meta_title) %} - {% endif %} - {{ title|slice(0,60) }} - -{% endif %} + + {% set title = trans(template.meta_title) %} + {% set showTitle = template.showTitle is same as(false) ? false : true %} + {% if showTitle %} + {% set title = setting_value('streams::name', config_get('streams::distribution.name'))~" | "~trans(template.meta_title) %} + {% endif %} + {{ title|slice(0,60) }} + {% include "visiosoft.theme.base::partials/ogdata" %} From 280fe7928606934dc946daa523b28a40b106e565 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 12:39:28 +0300 Subject: [PATCH 09/13] =?UTF-8?q?#2647=20emlak24=20yap=C4=B1lacaklar=20&&?= =?UTF-8?q?=20make=20profile=20ads=20work=20with=20laravel=20pagination?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Http/Controller/AjaxController.php | 7 +++- .../profile-module/resources/assets/js/ads.js | 37 ++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php index 7f88318b2..f9525094c 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php @@ -76,7 +76,12 @@ class AjaxController extends PublicController } $my_advs = $my_advs->select(['id', 'cover_photo', 'slug', 'price', 'currency', 'city', 'country_id', 'cat1', 'cat2', 'status']) ->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) { $my_advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list'); diff --git a/addons/default/visiosoft/profile-module/resources/assets/js/ads.js b/addons/default/visiosoft/profile-module/resources/assets/js/ads.js index c6b8b7454..435617e4a 100644 --- a/addons/default/visiosoft/profile-module/resources/assets/js/ads.js +++ b/addons/default/visiosoft/profile-module/resources/assets/js/ads.js @@ -3,18 +3,19 @@ var records_per_page = ads_per_page; var ads_type = ""; var objJson = []; +let totalAdvs = 0 function prevPage() { if (current_page > 1) { current_page--; - changePage(current_page); + getMyAdvs(ads_type) } } function nextPage(event) { if (current_page < numPages()) { current_page++; - changePage(current_page); + getMyAdvs(ads_type) } } @@ -30,12 +31,14 @@ function changePage(page) { listing_table.html(""); - if (objJson.length == 0) { - listing_table.html(''); + if (objJson.length === 0) { + listing_table.html(` + + `); } - 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, objJson[i].price + " " + objJson[i].currency, objJson[i].city_name, objJson[i].country_name, objJson[i].cat1_name, objJson[i].cat2_name, objJson[i].status)); @@ -63,7 +66,7 @@ function changePage(page) { } function numPages() { - return Math.ceil(objJson.length / records_per_page); + return Math.ceil(totalAdvs / records_per_page); } function crud(params, url, type, callback) { @@ -78,15 +81,16 @@ function crud(params, url, type, callback) { } 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; - current_page = 1; - objJson = callback.content; - changePage(1); + objJson = callback.content.data; + totalAdvs = callback.content.total + changePage(current_page); }) } $('.profile-advs-tab a').on('click', function () { + current_page = 1 getMyAdvs($(this).attr('data-type')) }); @@ -128,7 +132,7 @@ function addAdsRow(id, href, image, name, price, city, country, cat1, cat2, stat } function dropdownRow(id, type) { - var dropdown = ""; + dropdown += ""; + + getBlock('profile/dropdown-ad', {'id': id}, function (r) { + $(`.my-ads-dropdown[data-id=${id}] .dropdown-menu`).append(r.html) + }) + return dropdown; } \ No newline at end of file From 7deba2ab1acf693459b853f7613c4d548bfc7984 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Sat, 14 Nov 2020 13:05:14 +0300 Subject: [PATCH 10/13] #2663 [advs-module] Too many requests on profile ads page --- .../profile-module/resources/assets/js/ads.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/addons/default/visiosoft/profile-module/resources/assets/js/ads.js b/addons/default/visiosoft/profile-module/resources/assets/js/ads.js index 4eb5a77f9..59549d48c 100644 --- a/addons/default/visiosoft/profile-module/resources/assets/js/ads.js +++ b/addons/default/visiosoft/profile-module/resources/assets/js/ads.js @@ -44,6 +44,8 @@ function changePage(page) { objJson[i].cat2_name, objJson[i].status)); } + addDropdownBlock() + page_span.html(page + "/" + numPages()); if (numPages() === 1) { @@ -166,10 +168,15 @@ function dropdownRow(id, type) { dropdown += ""; - getBlock('profile/dropdown-ad', {'id': id}, function (r) { - $(`.my-ads-dropdown[data-id=${id}] .dropdown-menu`).append(r.html) - }) - return dropdown; +} -} \ No newline at end of file +const dropdownBlock = getBlock('profile/dropdown-ad', {'id': ':id'}) +function addDropdownBlock () { + const dropdowns = $('.my-ads-dropdown') + for (let i = 0; i < dropdowns.length; i++) { + console.log() + const currentDropdown = $(dropdowns[i]) + $('.dropdown-menu', currentDropdown).append(dropdownBlock.replace(':id', currentDropdown.data('id'))) + } +} From 50f371896b1cc9101545fdc06649f4639658c482 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Mon, 16 Nov 2020 10:31:16 +0300 Subject: [PATCH 11/13] #2609 ad detail error when store not installed --- .../visiosoft/advs-module/resources/lang/en/message.php | 1 + .../default/visiosoft/advs-module/src/Adv/AdvPresenter.php | 2 +- .../advs-module/src/Http/Controller/advsController.php | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/message.php b/addons/default/visiosoft/advs-module/resources/lang/en/message.php index 8fb05b55f..2ee555855 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/message.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/message.php @@ -26,4 +26,5 @@ return [ 'replicated_success' => 'The ad has been replicated successfully!', 'ad_doesnt_exist' => "This ad doesn't exist!", 'select_location_error' => "Please select a location on the map!", + 'this_ad_is_not_valid_anymore' => "This ad is not valid anymore!", ]; diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php b/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php index 38b99bb8f..1f0aaa106 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvPresenter.php @@ -62,7 +62,7 @@ class AdvPresenter extends EntryPresenter public function isCorporate() { $user_id = $this->getObject()->created_by; - if ($user_id && $user_id->register_type != null) { + if ($user_id->register_type != null) { return $user_id->register_type; } else { return 1; diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index f46783a6e..288349272 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -485,6 +485,11 @@ class AdvsController extends PublicController $adv = $this->adv_repository->getListItemAdv($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')) { $complaints = ComplaintsComplainTypesEntryModel::all(); From 6bd912f87c2faf94dad517adeb110d7da168581e Mon Sep 17 00:00:00 2001 From: Diatrex Date: Mon, 16 Nov 2020 12:24:40 +0300 Subject: [PATCH 12/13] remove log --- .../default/visiosoft/profile-module/resources/assets/js/ads.js | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/default/visiosoft/profile-module/resources/assets/js/ads.js b/addons/default/visiosoft/profile-module/resources/assets/js/ads.js index 59549d48c..180a3d527 100644 --- a/addons/default/visiosoft/profile-module/resources/assets/js/ads.js +++ b/addons/default/visiosoft/profile-module/resources/assets/js/ads.js @@ -175,7 +175,6 @@ const dropdownBlock = getBlock('profile/dropdown-ad', {'id': ':id'}) function addDropdownBlock () { const dropdowns = $('.my-ads-dropdown') for (let i = 0; i < dropdowns.length; i++) { - console.log() const currentDropdown = $(dropdowns[i]) $('.dropdown-menu', currentDropdown).append(dropdownBlock.replace(':id', currentDropdown.data('id'))) } From 5842bf70433d908ab44e4ccc4debb34499cef882 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Mon, 16 Nov 2020 13:58:32 +0300 Subject: [PATCH 13/13] fix file single_file upload --- .../base-theme/resources/js/theme/modal.js | 85 ++++++++ .../base-theme/resources/js/theme/search.js | 191 ++++++++++++++++++ .../resources/views/partials/assets.twig | 3 +- .../resources/js/upload.js | 11 +- 4 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 addons/default/visiosoft/base-theme/resources/js/theme/modal.js create mode 100644 addons/default/visiosoft/base-theme/resources/js/theme/search.js diff --git a/addons/default/visiosoft/base-theme/resources/js/theme/modal.js b/addons/default/visiosoft/base-theme/resources/js/theme/modal.js new file mode 100644 index 000000000..2a478e37e --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/js/theme/modal.js @@ -0,0 +1,85 @@ +let initModal = function () { + + let modal = $('.modal.remote:not([data-initialized])'); + + let loading = ''; + + // 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); +}); diff --git a/addons/default/visiosoft/base-theme/resources/js/theme/search.js b/addons/default/visiosoft/base-theme/resources/js/theme/search.js new file mode 100644 index 000000000..d73818e9e --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/js/theme/search.js @@ -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(''); + } + } + } + + /** + * 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'); + } + }); +}); diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/assets.twig b/addons/default/visiosoft/base-theme/resources/views/partials/assets.twig index 48582c6d5..efae4833f 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/assets.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/assets.twig @@ -17,8 +17,9 @@ {{ asset_add("theme.js", "visiosoft.theme.base::js/script.js") }} {# 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/search.js") }} +{{ asset_add("theme.js", "visiosoft.theme.base::js/theme/modal.js") }} {{ asset_script("theme.js") }} diff --git a/addons/default/visiosoft/singlefile-field_type/resources/js/upload.js b/addons/default/visiosoft/singlefile-field_type/resources/js/upload.js index 5aaa7684f..f4e39538c 100644 --- a/addons/default/visiosoft/singlefile-field_type/resources/js/upload.js +++ b/addons/default/visiosoft/singlefile-field_type/resources/js/upload.js @@ -64,9 +64,6 @@ $(function () { var response = JSON.parse(file.xhr.response); 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'); @@ -83,4 +80,12 @@ $(function () { 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(',')); + }); });