You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.5 KiB
JavaScript

$(document).ready(function () {
// Function to fetch related tasks based on epic ID
function fetchRelatedTasks(epicId) {
$.ajax({
type: "GET",
url: "/get_tasks/" + epicId + "/",
success: function (data) {
// console.log("Ajax call success. Data received:", data);
$("#epicRelatedTasksContainer").html(data);
},
error: function (xhr, status, error) {
console.log("Ajax call failed. Error details:");
console.log("XHR Object:", xhr);
console.log("Status:", status);
console.log("Error:", error);
}
});
}
$("select#epicSelect").change(function () {
// Get the selected option's value
var selectedEpicId = $(this).val();
if (selectedEpicId) {
// Fetch related tasks based on the selected epic
fetchRelatedTasks(selectedEpicId);
}
});
// TO FETCH THE LATEST EPIC BY DEFAULT
var projectId = $("#projectId").text().trim();
function fetchLatestEpicTasks(projectId) {
$.ajax({
type: "GET",
url: "/get_latest_epic/" + projectId + "/",
success: function (data) {
var latestEpicId = data.latest_epic ? data.latest_epic.id : null;
if (latestEpicId) {
// Fetch related tasks based on the latest epic
fetchRelatedTasks(latestEpicId);
} else {
// console.log("No latest epic found.");
}
$("#epicRelatedTasksContainer").html(data);
},
error: function (xhr, status, error) {
console.log("Ajax call failed. Error details:");
console.log("XHR Object:", xhr);
console.log("Status:", status);
console.log("Error:", error);
}
});
}
fetchLatestEpicTasks(projectId);
$('#epicSelect').change(function () {
var selectedEpic = $(this).find(':selected');
var startDate = selectedEpic.data('start-date');
var endDate = selectedEpic.data('end-date');
if (startDate && endDate) {
$('#epicDetails').removeClass('hidden');
$('#epicDetails span#startDate').text(startDate);
$('#epicDetails span#endDate').text(endDate);
} else {
$('#epicDetails').addClass('hidden');
}
});
});