new
parent
a1ebd69efc
commit
64a831f2be
@ -1,61 +1,61 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
// document.addEventListener('DOMContentLoaded', function () {
|
||||||
// Initialize TomSelect for Projects
|
// // Initialize TomSelect for Projects
|
||||||
new TomSelect('#projects', {
|
// new TomSelect('#projects', {
|
||||||
create: false, // Disable creating new options
|
// create: false, // Disable creating new options
|
||||||
sortField: 'text',
|
// sortField: 'text',
|
||||||
onChange: function(values) {
|
// onChange: function(values) {
|
||||||
updateTasks(); // Update tasks on value change
|
// updateTasks(); // Update tasks on value change
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
// Initialize TomSelect for Staff
|
// // Initialize TomSelect for Staff
|
||||||
new TomSelect('#staff', {
|
// new TomSelect('#staff', {
|
||||||
create: false,
|
// create: false,
|
||||||
sortField: 'text',
|
// sortField: 'text',
|
||||||
onChange: function(values) {
|
// onChange: function(values) {
|
||||||
updateTasks(); // Update tasks on value change
|
// updateTasks(); // Update tasks on value change
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
// Update tasks based on filters
|
// // Update tasks based on filters
|
||||||
function updateTasks() {
|
// function updateTasks() {
|
||||||
const projectIds = Array.from(document.getElementById('projects').selectedOptions).map(option => option.value);
|
// const projectIds = Array.from(document.getElementById('projects').selectedOptions).map(option => option.value);
|
||||||
const staffIds = Array.from(document.getElementById('staff').selectedOptions).map(option => option.value);
|
// const staffIds = Array.from(document.getElementById('staff').selectedOptions).map(option => option.value);
|
||||||
const startDate = document.getElementById('start-date').value;
|
// const startDate = document.getElementById('start-date').value;
|
||||||
const endDate = document.getElementById('end-date').value;
|
// const endDate = document.getElementById('end-date').value;
|
||||||
|
//
|
||||||
// Construct the query parameters without brackets around the projectIds
|
// // Construct the query parameters without brackets around the projectIds
|
||||||
let queryParams = `?projects=${projectIds.join(',')}&staff=${staffIds.join(',')}&start_date=${startDate}&end_date=${endDate}`;
|
// let queryParams = `?projects=${projectIds.join(',')}&staff=${staffIds.join(',')}&start_date=${startDate}&end_date=${endDate}`;
|
||||||
|
//
|
||||||
// Perform AJAX request
|
// // Perform AJAX request
|
||||||
fetch(`/projects-dashboard/${queryParams}`, {
|
// fetch(`/projects-dashboard/${queryParams}`, {
|
||||||
method: 'GET',
|
// method: 'GET',
|
||||||
headers: {
|
// headers: {
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
// 'X-Requested-With': 'XMLHttpRequest',
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
.then(response => response.json())
|
// .then(response => response.json())
|
||||||
.then(data => {
|
// .then(data => {
|
||||||
// Update table body with new data
|
// // Update table body with new data
|
||||||
const tbody = document.getElementById('status-table-body');
|
// const tbody = document.getElementById('status-table-body');
|
||||||
tbody.innerHTML = ''; // Clear the existing table rows
|
// tbody.innerHTML = ''; // Clear the existing table rows
|
||||||
data.tasks_data.forEach(task => {
|
// data.tasks_data.forEach(task => {
|
||||||
const tr = document.createElement('tr');
|
// const tr = document.createElement('tr');
|
||||||
tr.innerHTML = `
|
// tr.innerHTML = `
|
||||||
<td>${task.project_name}</td>
|
// <td>${task.project_name}</td>
|
||||||
<td>${task.status}</td>
|
// <td>${task.status}</td>
|
||||||
<td>${task.start_date}</td>
|
// <td>${task.start_date}</td>
|
||||||
<td>${task.staff}</td>
|
// <td>${task.staff}</td>
|
||||||
`;
|
// `;
|
||||||
tbody.appendChild(tr);
|
// tbody.appendChild(tr);
|
||||||
});
|
// });
|
||||||
})
|
// })
|
||||||
.catch(error => {
|
// .catch(error => {
|
||||||
console.error('Error updating tasks:', error);
|
// console.error('Error updating tasks:', error);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Trigger update when date range changes
|
// // Trigger update when date range changes
|
||||||
document.getElementById('start-date').addEventListener('change', updateTasks);
|
// document.getElementById('start-date').addEventListener('change', updateTasks);
|
||||||
document.getElementById('end-date').addEventListener('change', updateTasks);
|
// document.getElementById('end-date').addEventListener('change', updateTasks);
|
||||||
});
|
// });
|
||||||
|
Loading…
Reference in New Issue