master_template/public/assets/js/pages/tasks-list.init.js

1 line
15 KiB
JavaScript
Raw Normal View History

2024-06-10 12:21:58 +00:00
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;a<e.length;a++)e[a].checked=this.checked,e[a].checked?e[a].closest("tr").classList.add("table-active"):e[a].closest("tr").classList.remove("table-active");document.getElementById("remove-actions").style.display=0<t?"none":"block"}),8),editlist=!1,options={valueNames:["id","project_name","tasks_name","client_name","assignedto","due_date","status","priority"],page:perPage,pagination:!0,plugins:[ListPagination({left:2,right:2})]},tasksList=new List("tasksList",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(function(e){var t=e.assignedto,a='<div class="avatar-group flex-nowrap">';Array.from(t.slice(0,3)).forEach(function(e){a+='<a href="javascript: void(0);" class="avatar-group-item" data-img="'+e.assigneeImg+'" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="'+e.assigneeName+'"> <img src="'+e.assigneeImg+'" alt="" class="rounded-circle avatar-xxs" /> </a>'}),3<t.length&&(t=t.length-3,a+='<a href="javascript: void(0);" class="avatar-group-item" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="'+t+' More"> <div class="avatar-xxs"> <div class="avatar-title rounded-circle">'+t+"+</div> </div> </a>"),a+="</div>",tasksList.add({id:'<a href="apps-tasks-details.html" class="fw-medium link-primary">#VLZ'+e.id+"</a>",project_name:'<a href="apps-projects-overview.html" class="fw-medium link-primary">'+e.project_name+"</a>",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",'<a href="apps-tasks-details.html" class="fw-medium link-primary">#VLZ501</a>')},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"]')