Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
app-todo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Geovanny E. Vera Pazmino
app-todo
Commits
eec35420
Commit
eec35420
authored
Apr 10, 2020
by
Milan Iliev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MainView
parent
dfa03faf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
20 deletions
+35
-20
main.js
web/main.js
+4
-1
main_view.js
web/main_view.js
+26
-0
controller.js
web/tasks/controller.js
+5
-19
No files found.
web/main.js
View file @
eec35420
import
MainView
from
"../main_view.js"
import
TaskController
from
"./tasks/controller.js"
let
task_controller
=
new
TaskController
()
let
main_view
=
new
MainView
()
let
task_controller
=
new
TaskController
(
main_view
)
task_controller
.
refresh
()
\ No newline at end of file
web/main_view.js
0 → 100644
View file @
eec35420
import
Task
from
"./tasks/task.js"
import
TaskView
from
"./tasks/view.js"
import
DetailTaskView
from
"./tasks/detail_view.js"
class
MainView
{
constructor
(){
this
.
task_views
=
[]
this
.
list_element
=
document
.
querySelector
(
"task-list"
)
this
.
detail_view
=
new
DetailTaskView
(
document
.
querySelector
(
"task-detail"
))
this
.
addButton
=
document
.
querySelector
(
'#add_button'
)
this
.
addButton
.
addEventListener
(
"click"
,
()
=>
{
this
.
addTask
(
new
Task
({
done
:
false
,
description
:
"New Task"
}))
})
}
addTaskView
(
task
){
let
view
=
new
TaskView
(
task
)
view
.
element
.
addEventListener
(
"click"
,
()
=>
this
.
detail_view
.
task
=
task
)
this
.
list_element
.
appendChild
(
view
.
element
)
this
.
task_views
.
push
(
view
)
}
}
export
default
MainView
\ No newline at end of file
web/tasks/controller.js
View file @
eec35420
import
Task
from
"./task.js"
import
TaskView
from
"./view.js"
import
DetailTaskView
from
"./detail_view.js"
import
Task
from
"./task.js"
class
TaskController
{
constructor
(){
this
.
tasks
=
[]
this
.
task_views
=
[]
this
.
list_element
=
document
.
querySelector
(
"task-list"
)
this
.
detail_view
=
new
DetailTaskView
(
document
.
querySelector
(
"task-detail"
))
this
.
addButton
=
document
.
querySelector
(
'#add_button'
)
this
.
addButton
.
addEventListener
(
"click"
,
()
=>
{
this
.
addTask
(
new
Task
({
done
:
false
,
description
:
"New Task"
}))
})
constructor
(
main_view
){
this
.
tasks
=
[]
this
.
view
=
main_view
}
addTask
(
task
){
let
view
=
new
TaskView
(
task
)
view
.
element
.
addEventListener
(
"click"
,
()
=>
this
.
detail_view
.
task
=
task
)
this
.
list_element
.
appendChild
(
view
.
element
)
this
.
task_views
.
push
(
view
)
this
.
view
.
addTaskView
(
task
)
task
.
addEventListener
(
"change"
,
()
=>
this
.
save
(
task
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment