-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add remove feature #2
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a298519
Slight change on js file
Micky373 d1bf0b1
Made the add element feature and local storage
Micky373 7fb4556
FInish the add and remove milestone project
Micky373 0e7bee9
FInilize the add and remove milestone
Micky373 5531fb0
Minor adjustment on the checkbox
Micky373 da6ae77
Minor adjustment on the input element
Micky373 2d0339f
Fix CR's issues
Micky373 bd8963c
Made amendment based on the CR's issue
Micky373 e6c8ec6
Modify the mobile version
Micky373 2b2c2a2
Make the input click event
Micky373 8fd0fb5
Fix linter errors
Micky373 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
import './styles.css'; | ||
import showActivity from './modules/show_activity.js'; | ||
import addTask from './modules/add_task.js'; | ||
import { addToLocalStorage } from './modules/local_storage.js'; | ||
|
||
// Populating the html element | ||
|
||
const taskContainer = document.querySelector('.task_container'); | ||
let template = ''; | ||
let tick = ''; | ||
let display = ''; | ||
const taskLists = [ | ||
{ | ||
description: 'Wash the dishes', | ||
completed: false, | ||
index: 0, | ||
}, | ||
{ | ||
description: 'Complete To do list project', | ||
completed: false, | ||
index: 1, | ||
}, | ||
]; | ||
let taskLists = []; | ||
|
||
for (let i = 0; i < taskLists.length; i += 1) { | ||
if (taskLists[i].completed === false) { | ||
tick = 'none'; | ||
display = ''; | ||
} else { | ||
tick = ''; | ||
display = 'none'; | ||
// Add task | ||
|
||
const activity = document.querySelector('#add_task'); | ||
|
||
activity.addEventListener('keypress', (e) => { | ||
if (e.key === 'Enter') { | ||
if (e.target.value === '') return; | ||
addTask(); | ||
window.location.reload(); | ||
e.target.value = ''; | ||
} | ||
template += ` | ||
<div class="task" id="${taskLists[i].index}"> | ||
<div class="check_box ${tick}"></div> | ||
<input type = "checkbox" class="checking ${display}"> | ||
<div>${taskLists[i].description}</div> | ||
</div > `; | ||
} | ||
}); | ||
|
||
taskContainer.innerHTML = template; | ||
window.onload = () => { | ||
if (localStorage.getItem('data') === null) { | ||
showActivity(taskLists); | ||
} else { | ||
const localActivities = JSON.parse(localStorage.getItem('data')); | ||
for (let i = 0; i < localActivities.length; i += 1) { | ||
localActivities[i].index = i + 1; | ||
} | ||
showActivity(localActivities); | ||
taskLists = localActivities; | ||
for (let i = 0; i < taskLists.length; i += 1) { | ||
taskLists[i].index = i + 1; | ||
} | ||
addToLocalStorage(taskLists); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Task, { addToLocalStorage } from './local_storage.js'; | ||
|
||
import showActivity from './show_activity.js'; | ||
|
||
const taskLists = JSON.parse(localStorage.getItem('data')); | ||
|
||
const addTask = () => { | ||
const activity = document.querySelector('#add_task').value; | ||
if (activity !== null) { | ||
const tasks = new Task(activity, false, ((taskLists.length) + 1)); | ||
taskLists.push(tasks); | ||
showActivity([tasks]); | ||
addToLocalStorage(taskLists); | ||
} | ||
}; | ||
|
||
export default addTask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function addToLocalStorage(data) { | ||
localStorage.setItem('data', JSON.stringify(data)); | ||
} | ||
|
||
export default class Task { | ||
constructor(description, completed, index) { | ||
this.description = description; | ||
this.completed = completed; | ||
this.index = index; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { addToLocalStorage } from './local_storage.js'; | ||
|
||
let taskLists = JSON.parse(localStorage.getItem('data')); | ||
|
||
const removeTask = (ref) => { | ||
const result = taskLists.filter((value) => value.index !== Number(ref)); | ||
taskLists = result; | ||
for (let i = 0; i < taskLists.length; i += 1) { | ||
taskLists[i].index = i + 1; | ||
} | ||
addToLocalStorage(taskLists); | ||
}; | ||
|
||
export default removeTask; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Micky373, I'm your new reviewer.
In this new commit, it is now possible to add tasks, but it is impossible to delete them because the delete buttons are not generated now, and therefore, missing. I can confirm this was not happening before the original review.
I can help. I'll be waiting on slack for the next 30 minutes, otherwise, I'll have to request changes.
I already contacted you on Slack, please respond. It's now 6:54 am for me.
Note: The student responded on Slack, we are working out the issue.