mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-26 12:28:28 +02:00
143 lines
No EOL
6.1 KiB
Twig
143 lines
No EOL
6.1 KiB
Twig
<script src="/assets/js/tabulator.min.js" defer></script>
|
|
<script src="/assets/js/tabler.min.js" defer></script>
|
|
<script src="/assets/js/xlsx.full.min.js" defer></script>
|
|
<script src="/assets/js/jspdf.umd.min.js" defer></script>
|
|
<script src="/assets/js/jspdf.plugin.autotable.min.js" defer></script>
|
|
<script>
|
|
var table;
|
|
document.addEventListener("DOMContentLoaded", function(){
|
|
|
|
function ticketLinkFormatter(cell){
|
|
var value = cell.getValue();
|
|
return `<a href="/ticket/${cell.getRow().getData().id}" style="font-weight:bold;">${value}</a>`;
|
|
}
|
|
|
|
function actionsFormatter(cell, formatterParams, onRendered) {
|
|
return `
|
|
<a class="btn btn-outline-primary btn-icon" href="/ticket/${cell.getRow().getData().id}" title="{{ __('View Ticket') }}"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" /><path d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" /></svg></a>
|
|
`;
|
|
}
|
|
|
|
function statusFormatter(cell) {
|
|
var status = cell.getValue();
|
|
|
|
// Function to create a badge with color based on status
|
|
function createBadge(text, badgeClass) {
|
|
return `<span class="status status-${badgeClass}">${text}</span>`;
|
|
}
|
|
|
|
switch (status) {
|
|
case 'Open':
|
|
return createBadge("{{ __('Open') }}", 'success');
|
|
case 'In Progress':
|
|
return createBadge("{{ __('In Progress') }}", 'warning');
|
|
case 'Resolved':
|
|
return createBadge("{{ __('Resolved') }}", 'info');
|
|
case 'Closed':
|
|
return createBadge("{{ __('Closed') }}", 'cyan');
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function priorityFormatter(cell) {
|
|
var priority = cell.getValue();
|
|
|
|
// Function to create an outline badge with color based on priority
|
|
function createBadge(text, badgeClass) {
|
|
return `<span class="status status-${badgeClass}">${text}</span>`;
|
|
}
|
|
|
|
switch (priority) {
|
|
case 'Low':
|
|
return createBadge("{{ __('Low') }}", 'teal');
|
|
case 'Medium':
|
|
return createBadge("{{ __('Medium') }}", 'blue');
|
|
case 'High':
|
|
return createBadge("{{ __('High') }}", 'orange');
|
|
case 'Critical':
|
|
return createBadge("{{ __('Critical') }}", 'red');
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function catFormatter(cell) {
|
|
var category = cell.getValue();
|
|
|
|
// Function to create an outline badge with color based on category
|
|
function createBadge(text, badgeClass) {
|
|
return `<span class="status status-${badgeClass}">${text}</span>`;
|
|
}
|
|
|
|
return createBadge(category, 'indigo');
|
|
}
|
|
|
|
table = new Tabulator("#supportTable", {
|
|
ajaxURL:"/api/records/support_tickets?join=ticket_categories", // Set the URL for your JSON data
|
|
ajaxConfig:"GET",
|
|
pagination:"local",
|
|
paginationSize: 10,
|
|
paginationSizeSelector:[10, 25, 50, 100],
|
|
clipboard:true,
|
|
clipboardPasteAction:"replace",
|
|
ajaxResponse:function(url, params, response){
|
|
return response.records;
|
|
},
|
|
layout:"fitColumns",
|
|
responsiveLayout: "collapse",
|
|
responsiveLayoutCollapseStartOpen:false,
|
|
resizableColumns:false,
|
|
initialSort:[
|
|
{column:"date_created", dir:"desc"},
|
|
],
|
|
placeholder: "{{ __('No Data') }}",
|
|
columns:[
|
|
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
|
|
{title:"{{ __('Subject') }}", field:"subject", minWidth:220, resizable:false, headerSort:true, formatter: ticketLinkFormatter, responsive:0},
|
|
{title:"{{ __('Category') }}", field:"category_id.name", minWidth:80, formatter: catFormatter, resizable:false, headerSort:true, responsive:2},
|
|
{title:"{{ __('Status') }}", field:"status", resizable:false, headerSort:true, width:200, minWidth:80, formatter: statusFormatter, responsive:2},
|
|
{title:"{{ __('Priority') }}", field:"priority", resizable:false, headerSort:true, width:200, minWidth:80, formatter: priorityFormatter, responsive:2},
|
|
{title:"{{ __('Creation Date') }}", field:"date_created", resizable:false, headerSort:true, width:250, minWidth:100, responsive:2},
|
|
{title: "{{ __('Actions') }}", formatter: actionsFormatter, resizable:false, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }},
|
|
]
|
|
});
|
|
var searchInput = document.getElementById("search-input");
|
|
searchInput.addEventListener("input", function () {
|
|
var term = searchInput.value.toLowerCase();
|
|
|
|
if (term) { // Only apply the filter when there's a term to search for
|
|
table.setFilter(function (data) {
|
|
// Check if any of the fields contain the search term
|
|
return (
|
|
String(data.subject).toLowerCase().includes(term) ||
|
|
String(data.status).toLowerCase().includes(term) ||
|
|
String(data.priority).toLowerCase().includes(term) ||
|
|
String(data.category_id.name).toLowerCase().includes(term)
|
|
);
|
|
});
|
|
} else {
|
|
table.clearFilter(); // Clear the filter when the search box is emptied
|
|
}
|
|
});
|
|
});
|
|
|
|
function downloadCSV() {
|
|
table.download("csv", "support.csv");
|
|
}
|
|
|
|
function downloadJSON() {
|
|
table.download("json", "support.json");
|
|
}
|
|
|
|
function downloadXLSX() {
|
|
table.download("xlsx", "support.xlsx", {sheetName:"My Support Tickets"});
|
|
}
|
|
|
|
function downloadPDF() {
|
|
table.download("pdf", "support.pdf", {
|
|
orientation:"portrait",
|
|
title:"My Support Tickets"
|
|
});
|
|
}
|
|
</script> |