close #1448 Fixed: Missing pagination for app reviews
This commit is contained in:
parent
a69ea5b3c5
commit
771df1047a
@ -269,11 +269,9 @@ class Item extends Controller
|
|||||||
|
|
||||||
public function reviews($alias, Request $request)
|
public function reviews($alias, Request $request)
|
||||||
{
|
{
|
||||||
$page = $request['page'];
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'query' => [
|
'query' => [
|
||||||
'page' => ($page) ? $page : 1,
|
'page' => $request->get('page', 1),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -284,7 +282,7 @@ class Item extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'error' => false,
|
'error' => false,
|
||||||
'data' => null,
|
'data' => $reviews,
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'html' => $html,
|
'html' => $html,
|
||||||
]);
|
]);
|
||||||
|
@ -77,8 +77,10 @@ trait Modules
|
|||||||
|
|
||||||
public function getModuleReviews($alias, $data = [])
|
public function getModuleReviews($alias, $data = [])
|
||||||
{
|
{
|
||||||
|
$page = isset($data['query']['page']) ? $data['query']['page'] : 1;
|
||||||
|
|
||||||
// Get data from cache
|
// Get data from cache
|
||||||
$reviews = Cache::get('apps.' . $alias . '.reviews');
|
$reviews = Cache::get('apps.' . $alias . '.reviews'. $page);
|
||||||
|
|
||||||
if (!empty($reviews)) {
|
if (!empty($reviews)) {
|
||||||
return $reviews;
|
return $reviews;
|
||||||
@ -86,7 +88,7 @@ trait Modules
|
|||||||
|
|
||||||
$reviews = static::getResponseData('GET', 'apps/' . $alias . '/reviews', $data);
|
$reviews = static::getResponseData('GET', 'apps/' . $alias . '/reviews', $data);
|
||||||
|
|
||||||
Cache::put('apps.' . $alias . '.reviews', $reviews, Date::now()->addHour());
|
Cache::put('apps.' . $alias . '.reviews' . $page, $reviews, Date::now()->addHour());
|
||||||
|
|
||||||
return $reviews;
|
return $reviews;
|
||||||
}
|
}
|
||||||
|
9
public/css/custom.css
vendored
9
public/css/custom.css
vendored
@ -438,14 +438,6 @@ tbody .row {
|
|||||||
/*--------Shadow None Focus Finish--------*/
|
/*--------Shadow None Focus Finish--------*/
|
||||||
/*--------Settings Index Page Finish--------*/
|
/*--------Settings Index Page Finish--------*/
|
||||||
|
|
||||||
/*--------Pagination Alignment--------*/
|
|
||||||
.page-item .page-link,
|
|
||||||
.page-item span {
|
|
||||||
align-items: unset;
|
|
||||||
padding-top: 7px;
|
|
||||||
}
|
|
||||||
/*--------Pagination Alignment Finish--------*/
|
|
||||||
|
|
||||||
/*--------Avatar Size--------*/
|
/*--------Avatar Size--------*/
|
||||||
.avatar-size {
|
.avatar-size {
|
||||||
width: 128px;
|
width: 128px;
|
||||||
@ -543,7 +535,6 @@ table .align-items-center td span.badge {
|
|||||||
/*--------App Comment--------*/
|
/*--------App Comment--------*/
|
||||||
.media-comment-text {
|
.media-comment-text {
|
||||||
border-top-left-radius: 0.4375rem;
|
border-top-left-radius: 0.4375rem;
|
||||||
background-color: #ebebf0;
|
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
/*--------App Comment Finish--------*/
|
/*--------App Comment Finish--------*/
|
||||||
|
24
resources/assets/js/views/modules/item.js
vendored
24
resources/assets/js/views/modules/item.js
vendored
@ -32,12 +32,19 @@ const app = new Vue({
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.onGetReviews('', 1);
|
this.onReviews(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
reviews: '',
|
reviews: {
|
||||||
|
status: false,
|
||||||
|
html: '',
|
||||||
|
pagination: {
|
||||||
|
current_page: 1,
|
||||||
|
last_page: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
faq: false,
|
faq: false,
|
||||||
installation: {
|
installation: {
|
||||||
show: false,
|
show: false,
|
||||||
@ -65,14 +72,19 @@ const app = new Vue({
|
|||||||
location = path;
|
location = path;
|
||||||
},
|
},
|
||||||
|
|
||||||
async onGetReviews(path, page) {
|
async onReviews(page) {
|
||||||
let reviews_promise = Promise.resolve(axios.post(url + '/apps/' + app_slug + '/reviews', {
|
let reviews_promise = Promise.resolve(window.axios.post(url + '/apps/' + app_slug + '/reviews', {
|
||||||
patth: path,
|
|
||||||
page: page
|
page: page
|
||||||
}));
|
}));
|
||||||
|
|
||||||
reviews_promise.then(response => {
|
reviews_promise.then(response => {
|
||||||
this.reviews = response.data.html;
|
if (response.data.success) {
|
||||||
|
this.reviews.status= true;
|
||||||
|
this.reviews.html = response.data.html;
|
||||||
|
|
||||||
|
this.reviews.pagination.current_page = page;
|
||||||
|
this.reviews.pagination.last_page = response.data.data.last_page;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
});
|
});
|
||||||
|
@ -108,17 +108,72 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div class="tab-pane fade" id="review">
|
<div class="tab-pane fade" id="review">
|
||||||
<div id="reviews" class="clearfix" v-html="reviews">
|
@php
|
||||||
@if(!$module->reviews)
|
$reviews = $module->app_reviews;
|
||||||
<div class="text-center">
|
@endphp
|
||||||
<strong>
|
|
||||||
{{ trans('modules.reviews.na') }}
|
<div id="reviews" class="clearfix" v-if="reviews.status" v-html="reviews.html"></div>
|
||||||
</strong>
|
|
||||||
</div>
|
<div id="reviews" class="clearfix" v-else>
|
||||||
@endif
|
@include('partials.modules.reviews')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-footer mx--4 mt-4 mb--4">
|
@php
|
||||||
|
$review_first_item = count($reviews->data) > 0 ? ($reviews->current_page - 1) * $reviews->per_page + 1 : null;
|
||||||
|
$review_last_item = count($reviews->data) > 0 ? $review_first_item + count($reviews->data) - 1 : null;
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@if (!empty($review_first_item))
|
||||||
|
@stack('pagination_start')
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<span class="table-text d-lg-block">
|
||||||
|
{{ trans('pagination.showing', ['first' => $review_first_item, 'last' => $review_last_item, 'total' => $reviews->total, 'type' => strtolower(trans('modules.tab.reviews'))]) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<ul class="pagination float-right">
|
||||||
|
{{-- Previous Page Link --}}
|
||||||
|
<li class="page-item disabled" v-if="reviews.pagination.current_page == 1">
|
||||||
|
<span class="page-link">«</span>
|
||||||
|
</li>
|
||||||
|
<li class="page-item" v-else>
|
||||||
|
<button type="button" class="page-link" @click="onReviews(reviews.pagination.current_page - 1)" rel="prev">«</button>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{{-- Pagination Elements --}}
|
||||||
|
@for ($page = 1; $page <= $reviews->last_page; $page++)
|
||||||
|
<li class="page-item" :class="[{'active': reviews.pagination.current_page == {{ $page }}}]" v-if="reviews.pagination.current_page == {{ $page }}">
|
||||||
|
<span class="page-link">{{ $page }}</span>
|
||||||
|
</li>
|
||||||
|
<li class="page-item" v-else>
|
||||||
|
<button type="button" class="page-link" @click="onReviews({{ $page }})" data-page="{{ $page }}">{{ $page }}</button>
|
||||||
|
</li>
|
||||||
|
@endfor
|
||||||
|
|
||||||
|
{{-- Next Page Link --}}
|
||||||
|
<li class="page-item" v-if="reviews.pagination.last_page != reviews.pagination.current_page">
|
||||||
|
<button type="button" class="page-link" @click="onReviews(reviews.pagination.current_page + 1)" rel="next">»</button>
|
||||||
|
</li>
|
||||||
|
<li class="page-item disabled" v-else>
|
||||||
|
<span class="page-link">»</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@stack('pagination_end')
|
||||||
|
@else
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<small>{{ trans('general.no_records') }}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="card-footer mx--4 mb--4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 text-right">
|
<div class="col-md-12 text-right">
|
||||||
@if (!empty($module->review_action))
|
@if (!empty($module->review_action))
|
||||||
|
@ -5,77 +5,38 @@
|
|||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<div class="media-comment-text">
|
<div class="media-comment-text">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<h5 class="mt-0">{{ $review->author }}</h5>
|
<h5 class="mb-0">{{ $review->author }}</h5>
|
||||||
<h5 class="text-right ml-auto">@date($review->created_at)</h5>
|
|
||||||
</div>
|
</div>
|
||||||
<p class="text-sm lh-160">{!! nl2br($review->text) !!}</p>
|
|
||||||
<div class="icon-actions">
|
<div class="d-flex">
|
||||||
<a href="#" class="like active">
|
<p class="h6 text-muted mb-0">@date($review->created_at)</p>
|
||||||
<span class="text-yellow">
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex">
|
||||||
|
<span class="text-yellow position-absolute top-3 right-3">
|
||||||
|
@if ($review->rating)
|
||||||
@for($i = 1; $i <= $review->rating; $i++)
|
@for($i = 1; $i <= $review->rating; $i++)
|
||||||
<i class="fa fa-star"></i>
|
<i class="fa fa-star"></i>
|
||||||
@endfor
|
@endfor
|
||||||
@for($i = $review->rating; $i < 5; $i++)
|
@if ($review->rating < 5)
|
||||||
<i class="fa fa-star-o"></i>
|
@for($i = $review->rating; $i > 1; $i--)
|
||||||
|
<i class="far fa-star"></i>
|
||||||
|
@endfor
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
@for($i = 1; $i <= 5; $i++)
|
||||||
|
<i class="far fa-star"></i>
|
||||||
@endfor
|
@endfor
|
||||||
</span>
|
@endif
|
||||||
</a>
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex">
|
||||||
|
<p class="mt-2 mb-0 text-sm lh-160">{!! nl2br($review->text) !!}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
@php
|
|
||||||
$review_first_item = count($reviews->data) > 0 ? ($reviews->current_page - 1) * $reviews->per_page + 1 : null;
|
|
||||||
$review_last_item = count($reviews->data) > 0 ? $review_first_item + count($reviews->data) - 1 : null;
|
|
||||||
@endphp
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if (!empty($review_first_item))
|
|
||||||
@stack('pagination_start')
|
|
||||||
|
|
||||||
<div class="row d-none">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<span class="table-text d-none d-lg-block">
|
|
||||||
{{ trans('pagination.showing', ['first' => $review_first_item, 'last' => $review_last_item, 'total' => $reviews->total, 'type' => strtolower(trans('modules.tab.reviews'))]) }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6">
|
|
||||||
<ul class="pagination float-right">
|
|
||||||
{{-- Previous Page Link --}}
|
|
||||||
@if ($reviews->current_page <= 1)
|
|
||||||
<li class="page-item disabled"><span class="page-link">«</span></li>
|
|
||||||
@else
|
|
||||||
<li><a class="page-link" href="{{ url(request()->path()) }}?page={{ $reviews->current_page - 1 }}" rel="prev">«</a></li>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
{{-- Pagination Elements --}}
|
|
||||||
@for ($page = 1; $page <= $reviews->last_page; $page++)
|
|
||||||
@if ($page == $reviews->current_page)
|
|
||||||
<li class="page-item active"><span class="page-link">{{ $page }}</span></li>
|
|
||||||
@else
|
|
||||||
<li class="page-item"><a class="page-link" href="{{ url(request()->path()) }}?page={{ $page }}" data-page="{{ $page }}">{{ $page }}</a></li>
|
|
||||||
@endif
|
|
||||||
@endfor
|
|
||||||
|
|
||||||
{{-- Next Page Link --}}
|
|
||||||
@if ($reviews->current_page != 1)
|
|
||||||
<li class="page-item"><a class="page-link" href="{{ url(request()->path()) }}?page={{ $reviews->current_page + 1 }}" rel="next">»</a></li>
|
|
||||||
@else
|
|
||||||
<li class="page-item disabled"><span class="page-link">»</span></li>
|
|
||||||
@endif
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@stack('pagination_end')
|
|
||||||
@else
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<small>{{ trans('general.no_records') }}</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
Loading…
x
Reference in New Issue
Block a user