UI fixes for application list

This commit is contained in:
Pinga 2023-12-19 13:16:24 +02:00
parent 9c02df7048
commit 015ea1b0c0

View file

@ -17,6 +17,8 @@
var actionButtons = '';
// Common action button for all statuses
actionButtons += `<a class="btn btn-green btn-icon" href="application/approve/${cell.getRow().getData().name}" title="Approve Application"><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="M5 12l5 5l10 -10" /></svg></a> `;
actionButtons += `<a class="btn btn-warning btn-icon" href="application/reject/${cell.getRow().getData().name}" title="Reject Application"><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="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" /><path d="M5.7 5.7l12.6 12.6" /></svg></a> `;
actionButtons += `<a class="btn btn-info btn-icon" href="application/update/${cell.getRow().getData().name}" title="Update Application"><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><path d="M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"></path><path d="M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"></path><path d="M16 5l3 3"></path></svg></a> `;
actionButtons += `<a class="btn btn-danger btn-icon" href="application/delete/${cell.getRow().getData().name}" title="Delete Application"><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><path d="M4 7h16"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12"></path><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path><path d="M10 12l4 4m0 -4l-4 4"></path></svg></a>`;
@ -36,6 +38,21 @@
return createBadge(statusArray, 'info');
}
function statusFormatter(cell) {
var statusArray = cell.getValue();
var rowData = cell.getRow().getData(); // Get the entire row data
// Function to create a badge
function createBadge(text, badgeClass) {
return `<span class="badge bg-${badgeClass}-lt">${text}</span>`;
}
// Check if statusArray is empty or not
if (statusArray && Array.isArray(statusArray) && statusArray.length > 0) {
return statusArray.map(item => createBadge(item.status, 'lime')).join(' ');
}
}
var searchTerm = ""; // global variable to hold the search term
function updateSearchTerm(term) {
@ -49,10 +66,11 @@
paginationSize: 10,
ajaxURL: "/api/records/application",
ajaxParams: {
join: "contact"
join: "contact",
join: "application_status"
},
ajaxURLGenerator: function(url, config, params) {
var queryParts = ["join=contact"];
var queryParts = ["join=contact", "join=application_status"];
// Handle search term
if (searchTerm) {
@ -90,10 +108,11 @@
resizableColumns:false,
columns:[
{formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0},
{title:"Name", field:"name", width:200, headerSort:false, formatter: domainLinkFormatter, responsive:0},
{title:"Applicant", width:200, field:"registrant.identifier", headerSort:false, responsive:2},
{title:"Name", field:"name", width:250, headerSort:false, formatter: domainLinkFormatter, responsive:0},
{title:"Applicant", width:150, field:"registrant.identifier", headerSort:false, responsive:2},
{title:"Creation Date", width:250, minWidth:150, field:"crdate", headerSort:false, responsive:2},
{title:"Phase", width:250, minWidth:150, field:"phase_type", formatter: phaseFormatter, headerSort:false, responsive:2},
{title:"Phase", width:150, minWidth:100, field:"phase_type", formatter: phaseFormatter, headerSort:false, responsive:2},
{title:"Status", width:200, field:"application_status", formatter: statusFormatter, headerSort:false, download:false, responsive:2},
{title: "Actions", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }},
],
placeholder:function(){