var checkAll=document.getElementById("checkAll"),perPage=(checkAll&&(checkAll.onclick=function(){for(var e=document.querySelectorAll('.form-check-all input[type="checkbox"]'),t=document.querySelectorAll('.form-check-all input[type="checkbox"]:checked').length,a=0;ae.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';Array.from(t.slice(0,3)).forEach(function(e){a+=' '}),3
'+t+"+
"),a+="",tasksList.add({id:'#VLZ'+e.id+"",project_name:''+e.project_name+"",tasks_name:e.tasks_name,client_name:e.client_name,assignedto:a,due_date:e.due_date,status:isStatus(e.status),priority:isPriority(e.priority)}),tasksList.sort("id",{order:"desc"}),refreshCallbacks(),tooltipElm()}),tasksList.remove("id",'#VLZ501')},xhttp.open("GET","assets/json/tasks-list.json"),xhttp.send();var isValue=(isCount=(new DOMParser).parseFromString(tasksList.items.slice(-1)[0]._values.id,"text/html")).body.firstElementChild.innerHTML,idField=document.getElementById("tasksId"),projectNameField=document.getElementById("projectName-field"),tasksTitleField=document.getElementById("tasksTitle-field"),clientNameField=document.getElementById("clientName-field"),assignedtoNameField="Demo Assign",dateDueField=document.getElementById("duedate-field"),priorityField=document.getElementById("priority-field"),statusField=document.getElementById("ticket-status"),addBtn=document.getElementById("add-btn"),editBtn=document.getElementById("edit-btn"),removeBtns=document.getElementsByClassName("remove-item-btn"),editBtns=document.getElementsByClassName("edit-item-btn");function tooltipElm(){[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map(e=>new bootstrap.Tooltip(e))}function filterOrder(e){var t=e;tasksList.filter(function(e){e=(matchData=(new DOMParser).parseFromString(e.values().status,"text/html")).body.firstElementChild.innerHTML;return"All"==e||"All"==t||e==t}),tasksList.update()}function updateList(){var t=document.querySelector("input[name=status]:checked").value;data=userList.filter(function(e){return"All"==t||e.values().sts==t}),userList.update()}refreshCallbacks(),document.getElementById("showModal").addEventListener("show.bs.modal",function(e){e.relatedTarget.classList.contains("edit-item-btn")?(document.getElementById("exampleModalLabel").innerHTML="Edit Task",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 Task",document.getElementById("showModal").querySelector(".modal-footer").style.display="block",document.getElementById("add-btn").innerHTML="Add Task"):(document.getElementById("exampleModalLabel").innerHTML="List Task",document.getElementById("showModal").querySelector(".modal-footer").style.display="none")}),document.getElementById("showModal").addEventListener("hidden.bs.modal",function(){clearFields()}),document.querySelector("#tasksList").addEventListener("click",function(){ischeckboxcheck()});var table=document.getElementById("tasksTable"),tr=table.getElementsByTagName("tr"),trlist=table.querySelectorAll(".list tr"),count=11,forms=document.querySelectorAll(".tablelist-form"),example=(Array.prototype.slice.call(forms).forEach(function(a){a.addEventListener("submit",function(e){var t;a.checkValidity()?(e.preventDefault(),""===projectNameField.value||""===tasksTitleField.value||""===clientNameField.value||""===dateDueField.value||""===priorityField.value||""===statusField.value||editlist?""!==projectNameField.value&&""!==tasksTitleField.value&&""!==clientNameField.value&&""!==dateDueField.value&&""!==priorityField.value&&""!==statusField.value&&editlist&&(t=tasksList.get({id:idField.value}),Array.from(t).forEach(function(e){(isid=(new DOMParser).parseFromString(e._values.id,"text/html")).body.firstElementChild.innerHTML==itemId&&e.values({id:''+idField.value+"",project_name:''+projectNameField.value+"",tasks_name:tasksTitleField.value,client_name:clientNameField.value,assignedto:assignToUsers(),due_date:fomateDate(dateDueField.value),status:isStatus(statusField.value),priority:isPriority(priorityField.value)})}),document.getElementById("close-modal").click(),clearFields(),Swal.fire({position:"center",icon:"success",title:"Task updated Successfully!",showConfirmButton:!1,timer:2e3,showCloseButton:!0})):(tasksList.add({id:'#VLZ'+count+"",project_name:''+projectNameField.value+"",tasks_name:tasksTitleField.value,client_name:clientNameField.value,assignedto:assignToUsers(),due_date:fomateDate(dateDueField.value),status:isStatus(statusField.value),priority:isPriority(priorityField.value)}),tasksList.sort("id",{order:"desc"}),document.getElementById("close-modal").click(),clearFields(),refreshCallbacks(),count++,Swal.fire({position:"center",icon:"success",title:"Task inserted successfully!",showConfirmButton:!1,timer:2e3,showCloseButton:!0}))):(e.preventDefault(),e.stopPropagation())},!1)}),new Choices(priorityField,{searchEnabled:!1})),statusVal=new Choices(statusField,{searchEnabled:!1});function SearchData(){var i=document.getElementById("idStatus").value,l=document.getElementById("demo-datepicker").value,n=l.split(" to ")[0],r=l.split(" to ")[1];tasksList.filter(function(e){var t=(matchData=(new DOMParser).parseFromString(e.values().status,"text/html")).body.firstElementChild.innerHTML,a=!1,s=!1,a="all"==t||"all"==i||t==i,s=new Date(e.values().due_date.slice(0,12))>=new Date(n)&&new Date(e.values().due_date.slice(0,12))<=new Date(r);return a&&s||(a&&""==l?a:s&&""==l?s:void 0)}),tasksList.update()}function ischeckboxcheck(){Array.from(document.getElementsByName("chk_child")).forEach(function(a){a.addEventListener("change",function(e){1==a.checked?e.target.closest("tr").classList.add("table-active"):e.target.closest("tr").classList.remove("table-active");var t=document.querySelectorAll('[name="chk_child"]:checked').length;e.target.closest("tr").classList.contains("table-active"),document.getElementById("remove-actions").style.display=0'+e+"";case"Inprogress":return''+e+"";case"Completed":return''+e+"";case"New":return''+e+""}}function isPriority(e){switch(e){case"High":return''+e+"";case"Low":return''+e+"";case"Medium":return''+e+""}}function fomateDate(e){var e=new Date(e),t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()];return e.getDate()+" "+t+", "+e.getFullYear()}function assignToUsers(){var s=[],e=document.querySelectorAll('input[name="assignedTo[]"]:checked'),e=(Array.from(e).forEach(function(e){var e=e.parentElement,t=e.querySelector(".avatar-xxs").getAttribute("src"),e=e.querySelector(".flex-grow-1").innerHTML,a={};a.assigneeName=e,a.assigneeImg=t,s.push(a)}),s),t='
';return Array.from(e.slice(0,3)).forEach(function(e){t+=' '}),3
'+e+"+
"),t+="
"}function deleteMultiple(){ids_array=[];var e,t=document.getElementsByName("chk_child");for(i=0;i${ids_array[i]}`);document.getElementById("remove-actions").style.display="none",document.getElementById("checkAll").checked=!1,Swal.fire({title:"Deleted!",text:"Your data has been deleted.",icon:"success",confirmButtonClass:"btn btn-info w-xs mt-2",buttonsStyling:!1})}}),document.getElementById("checkAll").checked=!1):Swal.fire({title:"Please select at least one checkbox",confirmButtonClass:"btn btn-info",buttonsStyling:!1,showCloseButton:!0})}document.querySelector(".pagination-next").addEventListener("click",function(){document.querySelector(".pagination.listjs-pagination")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active").nextElementSibling.children[0].click()}),document.querySelector(".pagination-prev").addEventListener("click",function(){document.querySelector(".pagination.listjs-pagination")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active")&&document.querySelector(".pagination.listjs-pagination").querySelector(".active").previousSibling.children[0].click()});