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/Http/Controller/AjaxController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php index 97c6447ff..3f82cc8b6 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php @@ -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']) ->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/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 5c1db1afd..288349272 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); @@ -484,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(); 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/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', ], ], ], diff --git a/addons/default/visiosoft/location-module/src/City/CityRepository.php b/addons/default/visiosoft/location-module/src/City/CityRepository.php index 02350097f..26c711983 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, $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(); + } } 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..2e8993d9d 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, $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 0ac30691e..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,131 +1,95 @@ country_model = $countryModel; - $this->city_model = $cityModel; - $this->district_model = $districtModel; - $this->neighborhood_model = $neighborhoodModel; - $this->village_model = $villageModel; parent::__construct(); + $this->cityRepository = $cityRepository; + $this->countryRepository = $countryRepository; + $this->districtRepository = $districtRepository; + $this->neighborhoodRepository = $neighborhoodRepository; + $this->villageRepository = $villageRepository; } - /** - * @return mixed - */ 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); } } - /** - * @return mixed - */ public function getCities() { 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); - return $this->queryOrder($query); + return $this->queryOrder($query, $this->cityRepository); } } - /** - * @return mixed - */ public function getDistricts() { 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); } } - /** - * @return mixed - */ public function getNeighborhoods() { 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); } } - /** - * @return mixed - */ public function getVillage() { 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); } } - /** - * @return mixed - */ public function getCity() { 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]; @@ -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_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(); } } \ No newline at end of file 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(); } } 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 98689ab42..180a3d527 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,17 +31,21 @@ 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].formatted_price, objJson[i].city_name, objJson[i].country_name, objJson[i].cat1_name, objJson[i].cat2_name, objJson[i].status)); } + addDropdownBlock() + page_span.html(page + "/" + numPages()); if (numPages() === 1) { @@ -63,7 +68,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 +83,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 +134,7 @@ function addAdsRow(id, href, image, name, formatted_price, city, country, cat1, } function dropdownRow(id, type) { - var dropdown = ""; - return dropdown; + dropdown += ""; -} \ No newline at end of file + 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'))) + } +} 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(',')); + }); });