Added products pagination and added getting product category on update
This commit is contained in:
parent
0cb7e9ce5f
commit
5b976d88a7
|
|
@ -18,23 +18,23 @@ layout = "seller-master"
|
|||
<div class="intro-y col-span-12 overflow-auto 2xl:overflow-visible">
|
||||
<table class="table table-report -mt-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<tr>
|
||||
|
||||
<th class="whitespace-nowrap">{{'order.no'|_}}</th>
|
||||
<th class="whitespace-nowrap">{{'customer.name'|_}}</th>
|
||||
<th class="text-center whitespace-nowrap">{{'order.status'}}</th>
|
||||
<th class="text-center whitespace-nowrap">{{'order.shipping.desc'}}</th>
|
||||
<th class="text-center whitespace-nowrap">
|
||||
<div class="pr-16">{{'order.total.transaction'|_}}</div>
|
||||
</th>
|
||||
<th class="text-center whitespace-nowrap">
|
||||
{{'order.qty'|_}}
|
||||
</th>
|
||||
<th class="text-center whitespace-nowrap">
|
||||
{{'order.date'|_}}
|
||||
</th>
|
||||
<th class="whitespace-nowrap">{{'order.no'|_}}</th>
|
||||
<th class="whitespace-nowrap">{{'customer.name'|_}}</th>
|
||||
<th class="text-center whitespace-nowrap">{{'order.status'}}</th>
|
||||
<th class="text-center whitespace-nowrap">{{'order.shipping.desc'}}</th>
|
||||
<th class="text-center whitespace-nowrap">
|
||||
<div class="pr-16">{{'order.total.transaction'|_}}</div>
|
||||
</th>
|
||||
<th class="text-center whitespace-nowrap">
|
||||
{{'order.qty'|_}}
|
||||
</th>
|
||||
<th class="text-center whitespace-nowrap">
|
||||
{{'order.date'|_}}
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="seller_order">
|
||||
|
||||
|
|
|
|||
|
|
@ -26,39 +26,22 @@ layout = "seller-master"
|
|||
{% partial "seller/loader" loader_id="loader_seller" %}
|
||||
|
||||
<!-- END: Users Layout -->
|
||||
<!-- BEGIN: Pagination -->
|
||||
<!-- <div class="intro-y col-span-12 flex flex-wrap sm:flex-row sm:flex-nowrap items-center">
|
||||
<nav class="w-full sm:w-auto sm:mr-auto">
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#"> <i class="w-4 h-4" data-lucide="chevrons-left"></i> </a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#"> <i class="w-4 h-4" data-lucide="chevron-left"></i> </a>
|
||||
</li>
|
||||
<li class="page-item"> <a class="page-link" href="#">...</a> </li>
|
||||
<li class="page-item"> <a class="page-link" href="#">1</a> </li>
|
||||
<li class="page-item active"> <a class="page-link" href="#">2</a> </li>
|
||||
<li class="page-item"> <a class="page-link" href="#">3</a> </li>
|
||||
<li class="page-item"> <a class="page-link" href="#">...</a> </li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#"> <i class="w-4 h-4" data-lucide="chevron-right"></i> </a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#"> <i class="w-4 h-4" data-lucide="chevrons-right"></i> </a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<select class="w-20 form-select box mt-3 sm:mt-0">
|
||||
<option>10</option>
|
||||
<option>25</option>
|
||||
<option>35</option>
|
||||
<option>50</option>
|
||||
</select>
|
||||
</div> -->
|
||||
<!-- END: Pagination -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% partial "sellerApi/getProducts" id="seller" limit="6" %}
|
||||
{% partial "sellerApi/getProducts" id="seller" limit="12" %}
|
||||
|
||||
<div class="grid grid-cols-12 gap-6 mt-5">
|
||||
<!-- BEGIN: Pagination -->
|
||||
<div class="intro-y col-span-12 flex flex-wrap sm:flex-row sm:flex-nowrap items-center">
|
||||
<nav class="w-full sm:w-auto sm:mr-auto">
|
||||
<ul class="pagination" id="pagination_numbers">
|
||||
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<!-- END: Pagination -->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -140,7 +140,6 @@
|
|||
<script>
|
||||
|
||||
getProduct();
|
||||
vendorCats();
|
||||
|
||||
function vendorCats() {
|
||||
|
||||
|
|
@ -153,12 +152,15 @@
|
|||
// $('#loader').hide();
|
||||
// $('#deatil_screen').show();
|
||||
|
||||
var vendorCats = data.data.categories;
|
||||
let vendorCats = data.data.categories;
|
||||
|
||||
for (var cat of vendorCats) {
|
||||
$('#product_categories').append(`
|
||||
<option value="`+cat.id+`">`+ cat.name +`</option>
|
||||
`);
|
||||
for (let cat of vendorCats) {
|
||||
if(cat.id != $('#product_categories').find(":selected").val())
|
||||
{
|
||||
$('#product_categories').append(`
|
||||
<option value="`+cat.id+`">`+ cat.name +`</option>
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -185,7 +187,9 @@
|
|||
// $('#loader').hide();
|
||||
// $('#deatil_screen').show();
|
||||
|
||||
var product = data.data;
|
||||
let product = data.data;
|
||||
|
||||
console.log(product);
|
||||
|
||||
// $("input[name='images[files][]']").val(product.images[0].original_image_url);
|
||||
// $("select[name='status']").val(product.status);
|
||||
|
|
@ -212,6 +216,11 @@
|
|||
$("input[name='special_price']").val(Number(product.special_price));
|
||||
$("input[name='qty']").val(product.qty);
|
||||
|
||||
let category = product.categories[0];
|
||||
$('#product_categories').append(`
|
||||
<option selected value="`+category.id+`">`+ category.name +`</option>
|
||||
`);
|
||||
vendorCats();
|
||||
|
||||
product.images.forEach(image => {
|
||||
let mockFile = { name: image.original_image_url, size: 12345 };
|
||||
|
|
@ -276,9 +285,9 @@
|
|||
$('#imageUploadForm').on('submit', (function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var productName = $("input[name='name']").val();
|
||||
var urlKey = convertToSlug(productName);
|
||||
var fd = new FormData(this);
|
||||
let productName = $("input[name='name']").val();
|
||||
let urlKey = convertToSlug(productName);
|
||||
let fd = new FormData(this);
|
||||
|
||||
fd.append('product_id', $("input[name='product_id']").val());
|
||||
fd.append('user', $("input[name='user']").val());
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
day = '' + d.getDate(),
|
||||
year = d.getFullYear();
|
||||
|
||||
hour = d.getHours();
|
||||
minute = d.getMinutes();
|
||||
hour = d.getHours();
|
||||
minute = d.getMinutes();
|
||||
|
||||
if (month.length < 2)
|
||||
month = '0' + month;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
{% put scripts %}
|
||||
|
||||
<script>
|
||||
getProducts(`{{limit}}`);
|
||||
getProducts(`{{limit}}`, 1);
|
||||
// console.log("qqq");
|
||||
function getProducts(limit) {
|
||||
|
||||
function getProducts(limit, page) {
|
||||
$(document).ready(function () {
|
||||
$.ajax({
|
||||
url: `https://nurgul.com.tm/app/api/seller/products/{{user.seller_id}}?limit=`+limit,
|
||||
url: `https://nurgul.com.tm/app/api/seller/products/{{user.seller_id}}?limit=`+limit + `&page=` + page,
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
beforeSend: function () {
|
||||
$('#products_{{id}}').hide();
|
||||
$('#products_{{id}}').html("");
|
||||
$('#pagination_numbers').html("");
|
||||
$('#loader_{{id}}').show();
|
||||
},
|
||||
success: function (data, textStatus, xhr) {
|
||||
|
|
@ -42,6 +42,34 @@
|
|||
// console.log(product.hasOwnProperty('special_price'));
|
||||
$('#products_{{id}}').append(`{% partial "seller/prod-card" featured="`+ prodFeatured +`" price="`+product.formatted_price+`" qty="`+product.qty+`" status="`+product.status+`" id="`+product.id+`" new="`+product.new+`" name="`+product.name+`" price="`+product.formatted_price+`" img="`+prodImg+`" %}`);
|
||||
}
|
||||
|
||||
var pagination = data.meta;
|
||||
|
||||
$('#pagination_numbers').append(
|
||||
(pagination.current_page != 1 ?
|
||||
`<li class="page-item"><a class="page-link" href="javascript:;" onClick="getProducts(` + `'{{limit}}'` + `,` + pagination.links[1].label + `)"><</a></li>`
|
||||
:
|
||||
`<li class="page-item"><a class="page-link" href="javascript:;"><</a></li>`
|
||||
)
|
||||
);
|
||||
// for (var paginate of pagination.links) {
|
||||
for (var i = 0; i < pagination.links.length; i++) {
|
||||
if (i != 0 && i != pagination.links.length-1) {
|
||||
console.log(pagination.links[i])
|
||||
$('#pagination_numbers').append(
|
||||
`<li` + (pagination.links[i].active ? ` class="page-item active" ` : ` class="page-item"`) + `><a class="page-link" href="javascript:;" onClick="getProducts(` + `'{{limit}}'` + `,` + pagination.links[i].label + `)">` + pagination.links[i].label + `</a></li>`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$('#pagination_numbers').append(
|
||||
(pagination.current_page != pagination.last_page ?
|
||||
`<li class="page-item"><a class="page-link" href="javascript:;" onClick="getProducts(` + `'{{limit}}'` + `,` + (pagination.current_page + 1) + `)"> > </a></li>`
|
||||
:
|
||||
`<li class="page-item"><a class="page-link" href="javascript:;"> > </a></li>`
|
||||
)
|
||||
);
|
||||
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.log('Error in Operation');
|
||||
|
|
|
|||
Loading…
Reference in New Issue