Skip to content

Commit

Permalink
put Title and Description input into local variables. Enable Done but…
Browse files Browse the repository at this point in the history
…ton when Title has been entered.
  • Loading branch information
AndyHubert committed Jul 22, 2024
1 parent 351d2e9 commit e7bfc27
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions sarah/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,37 @@ const displayCurrentTask = () => {
}

const editTask = () => {
let titleText = ""
let descriptionText = ""
document.querySelector(`#screen-main`).classList.add(`hide`)
document.querySelector(`#screen-edit-task`).classList.remove(`hide`) //display edit form
console.log(document.querySelector(`#edit-title`).input)
if(document.querySelector(`#edit-title`).input === undefined){
console.log("No title")
document.querySelector(`#edit-done`).disabled = true
document.querySelector(`#edit-done`).disabled = true //disable DONE button if no title
}
/*
if new task, all fields should be empty
create new task object
if editing task, fields should have data from id = whatever the id of the task was where edit was clicked
hide done button until title filled in
Allow to edit title
unhide done button as soon as title filled in
Allow to edit description
when Done selected ->
1)save data to task
2)if new, push new task to front of rotation...or give it an id that will put it where you want it???
return to displayCurrentTask with currentTask id = either new task or previous current task
3) if editing a task, return to displayCurrentTask viewing the task edited (whether it's the current task or not)
*/
document.addEventListener(`click`, (titleText, descriptionText ) => {
titleText = document.querySelector(`#edit-title`).value
if(titleText !== ""){
document.querySelector(`#edit-done`).disabled = false //enable DONE button once Title input
}
descriptionText = document.querySelector(`#edit-description`).value
console.log("Title:", titleText)
console.log("Description:", descriptionText)
})

/*
if new task, all fields should be empty
create new task object
if editing task, fields should have data from id = whatever the id of the task was where edit was clicked
Allow to edit title
unhide done button as soon as title filled in
Allow to edit description
when Done selected ->
1)save data to task
2)if new, push new task to front of rotation...or give it an id that will put it where you want it???
return to displayCurrentTask with currentTask id = either new task or previous current task
3) if editing a task, return to displayCurrentTask viewing the task edited (whether it's the current task or not)
*/
}

displayCurrentTask()
Expand Down

0 comments on commit e7bfc27

Please sign in to comment.