mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-10 07:16:06 -06:00
#2647 emlak24 yapılacaklar && make profile ads work with laravel pagination
This commit is contained in:
parent
503add2963
commit
280fe79286
@ -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'])
|
$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');
|
||||||
|
|||||||
@ -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,12 +31,14 @@ 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].price + " " + objJson[i].currency,
|
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));
|
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() {
|
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 +81,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 +132,7 @@ function addAdsRow(id, href, image, name, price, city, country, cat1, cat2, stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 +164,12 @@ function dropdownRow(id, type) {
|
|||||||
extend_ad +
|
extend_ad +
|
||||||
"</a>\n";
|
"</a>\n";
|
||||||
|
|
||||||
dropdown += getBlock('profile/dropdown-ad', {'id': id}) + "</div></div>";
|
dropdown += "</div></div>";
|
||||||
|
|
||||||
|
getBlock('profile/dropdown-ad', {'id': id}, function (r) {
|
||||||
|
$(`.my-ads-dropdown[data-id=${id}] .dropdown-menu`).append(r.html)
|
||||||
|
})
|
||||||
|
|
||||||
return dropdown;
|
return dropdown;
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user