Skip to content

Commit

Permalink
sun code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fawzi-iit committed Dec 3, 2023
1 parent 7b9a06a commit b609fbc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
25 changes: 14 additions & 11 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let currentProjectId = null;

document.addEventListener('DOMContentLoaded', function() {
loadProjects();
hideCreateTaskForm();

// Event listener for the 'Project Dashboard' link
const dashboardLink = document.getElementById('dashboardLink');
Expand All @@ -12,20 +13,12 @@ document.addEventListener('DOMContentLoaded', function() {
hideCreateTaskForm();
});

// Event listener for the 'Create Project' link
const createProjectLink = document.getElementById('createProjectLink');
createProjectLink.addEventListener('click', function(event) {
event.preventDefault();
showCreateProjectForm();
});


/* Event listener for the 'Create Task' link
// Event listener for the 'Create Task' link
const createTaskLink = document.getElementById('createTaskLink');
createTaskLink.addEventListener('click', function(event) {
event.preventDefault();
showCreateTaskForm();
}); */
});

document.querySelectorAll('.task-priority, .task-status, .task-progress').forEach(element => {
element.addEventListener('change', (event) => {
Expand Down Expand Up @@ -62,6 +55,15 @@ document.addEventListener('DOMContentLoaded', function() {
});
});

// Add event listener for the 'Show Create Task' button
const showCreateTaskButton = document.getElementById('showCreateTaskButton');
if (showCreateTaskButton) {
showCreateTaskButton.addEventListener('click', function(event) {
event.preventDefault();
showCreateTaskForm();
});
}

function createProject() {
const name = document.getElementById('newProjectName').value;
const description = document.getElementById('newProjectDescription').value;
Expand All @@ -82,7 +84,7 @@ function createTask() {
const title = document.getElementById('newTaskTitle').value;
const description = document.getElementById('newTaskDescription').value;
const projectId = document.getElementById('projectIdField').value;

// Log the data being sent to the server
console.log("Creating task with the following data:");
console.log("Title:", title);
Expand All @@ -102,6 +104,7 @@ function createTask() {
})
.then(task => {
fetchTasksForProject(projectId);
hideCreateTaskForm(); // Hide the form after task creation
})
.catch(error => console.error('Error:', error));
}
Expand Down
4 changes: 4 additions & 0 deletions views/createTask.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ extends layout

block content
h1 Create New Task
// Button to show the create task form
button#showCreateTaskButton Show Create Task Form
// The Create Task Form, initially hidden
div#createTaskForm.hidden
form(action="/tasks" method="post")
// Include projectId as a hidden field if it exists
if projectId
Expand Down

0 comments on commit b609fbc

Please sign in to comment.