Heera/public/assets/js/pages/listjs.init.js

1 line
10 KiB
JavaScript
Raw Normal View History

2024-05-16 03:46:08 +00:00
var customerList,checkAll=document.getElementById("checkAll"),perPage=(checkAll&&(checkAll.onclick=function(){var e=document.querySelectorAll('.form-check-all input[type="checkbox"]');1==checkAll.checked?Array.from(e).forEach(function(e){e.checked=!0,e.closest("tr").classList.add("table-active")}):Array.from(e).forEach(function(e){e.checked=!1,e.closest("tr").classList.remove("table-active")})}),8),editlist=!1,options={valueNames:["id","customer_name","email","date","phone","status"],page:perPage,pagination:!0,plugins:[ListPagination({left:2,right:2})]};document.getElementById("customerList")&&(customerList=new List("customerList",options).on("updated",function(e){0==e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="block":document.getElementsByClassName("noresult")[0].style.display="none";var t=1==e.i,a=e.i>e.matchingItems.length-e.page;document.querySelector(".pagination-prev.disabled")&&document.querySelector(".pagination-prev.disabled").classList.remove("disabled"),document.querySelector(".pagination-next.disabled")&&document.querySelector(".pagination-next.disabled").classList.remove("disabled"),t&&document.querySelector(".pagination-prev").classList.add("disabled"),a&&document.querySelector(".pagination-next").classList.add("disabled"),e.matchingItems.length<=perPage?document.querySelector(".pagination-wrap").style.display="none":document.querySelector(".pagination-wrap").style.display="flex",e.matchingItems.length==perPage&&document.querySelector(".pagination.listjs-pagination").firstElementChild.children[0].click(),0<e.matchingItems.length?document.getElementsByClassName("noresult")[0].style.display="none":document.getElementsByClassName("noresult")[0].style.display="block"}));const xhttp=new XMLHttpRequest;xhttp.onload=function(){var e=JSON.parse(this.responseText);Array.from(e).forEach(e=>{customerList.add({id:'<a href="javascript:void(0);" class="fw-medium link-primary">#VZ'+e.id+"</a>",customer_name:e.customer_name,email:e.email,date:e.date,phone:e.phone,status:isStatus(e.status)}),customerList.sort("id",{order:"desc"}),refreshCallbacks()}),customerList.remove("id",'<a href="javascript:void(0);" class="fw-medium link-primary">#VZ2101</a>')},xhttp.open("GET","assets/json/table-customer-list.json"),xhttp.send();var isValue=(isCount=(new DOMParser).parseFromString(customerList.items.slice(-1)[0]._values.id,"text/html")).body.firstElementChild.innerHTML,idField=document.getElementById("id-field"),customerNameField=document.getElementById("customername-field"),emailField=document.getElementById("email-field"),dateField=document.getElementById("date-field"),phoneField=document.getElementById("phone-field"),statusField=document.getElementById("status-field"),addBtn=document.getElementById("add-btn"),editBtn=document.getElementById("edit-btn"),removeBtns=document.getElementsByClassName("remove-item-btn"),editBtns=document.getElementsByClassName("edit-item-btn");function filterContact(e){var t=e;customerList.filter(function(e){e=(matchData=(new DOMParser).parseFromString(e.values().status,"text/html")).body.firstElementChild.innerHTML;return"All"==e||"All"==t||e==t}),customerList.update()}function updateList(){var a=document.querySelector("input[name=status]:checked").value;data=userList.filter(function(e){var t=!1;return"All"==a?t=!0:(t=e.values().sts==a,console.log(t,"statusFilter")),t}),userList.update()}refreshCallbacks(),document.getElementById("showModal")&&(document.getElementById("showModal").addEventListener("show.bs.modal",function(e){e.relatedTarget.classList.contains("edit-item-btn")?(document.getElementById("exampleModalLabel").innerHTML="Edit Customer",document.getElementById("showModal").querySelector(".modal-footer").style.display="block",document.getElementById("add-btn").innerHTML="Update"):e.relatedTarget.classList.contains("add-btn")?(document.getElementById("exampleModalLabel").innerHTML="Add Customer",document.getElementById("showModal").querySelector(".modal-footer").style.display="block",document.getElementById("add-btn").innerHTML="Add Customer"):(document.g