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
548e89e4
Commit
548e89e4
authored
Apr 07, 2020
by
Milan Iliev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Task and TaskView into modules
parent
8ec3eb88
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
59 deletions
+63
-59
main.js
web/main.js
+2
-59
task.js
web/tasks/task.js
+30
-0
view.js
web/tasks/view.js
+31
-0
No files found.
web/main.js
View file @
548e89e4
class
Task
extends
EventTarget
{
constructor
(
data
){
super
()
this
.
data
=
data
}
get
id
(){
return
this
.
data
.
id
}
get
done
(){
return
this
.
data
.
done
}
set
done
(
new_value
){
this
.
data
.
done
=
new_value
this
.
dispatchEvent
(
new
CustomEvent
(
"change"
))
}
get
description
(){
return
this
.
data
.
description
}
set
description
(
new_value
){
this
.
data
.
description
=
new_value
this
.
dispatchEvent
(
new
CustomEvent
(
"change"
))
}
}
import
Task
from
"./tasks/task.js"
import
TaskView
from
"./tasks/view.js"
class
TaskController
{
constructor
(){
...
...
@@ -65,36 +38,6 @@ let task_views = []
let
list
=
document
.
querySelector
(
"task-list"
)
class
TaskView
{
static
template
=
`
<input type="checkbox" name="done"/>
<task-description> -- </task-description>
`
constructor
(
task
){
this
.
task
=
task
this
.
element
=
document
.
createElement
(
"task-summary"
)
this
.
element
.
innerHTML
=
this
.
constructor
.
template
this
.
fields
=
{
done
:
this
.
element
.
querySelector
(
"[name=done]"
),
}
this
.
update
()
this
.
task
.
addEventListener
(
"change"
,
()
=>
this
.
update
())
this
.
fields
.
done
.
addEventListener
(
"change"
,
()
=>
{
this
.
task
.
done
=
this
.
fields
.
done
.
checked
})
}
update
()
{
this
.
fields
.
done
.
checked
=
this
.
task
.
done
this
.
element
.
querySelector
(
"task-description"
).
innerText
=
this
.
task
.
description
}
}
class
DetailTaskView
{
constructor
(
element
){
this
.
element
=
element
...
...
web/tasks/task.js
0 → 100644
View file @
548e89e4
class
Task
extends
EventTarget
{
constructor
(
data
){
super
()
this
.
data
=
data
}
get
id
(){
return
this
.
data
.
id
}
get
done
(){
return
this
.
data
.
done
}
set
done
(
new_value
){
this
.
data
.
done
=
new_value
this
.
dispatchEvent
(
new
CustomEvent
(
"change"
))
}
get
description
(){
return
this
.
data
.
description
}
set
description
(
new_value
){
this
.
data
.
description
=
new_value
this
.
dispatchEvent
(
new
CustomEvent
(
"change"
))
}
}
export
default
Task
\ No newline at end of file
web/tasks/view.js
0 → 100644
View file @
548e89e4
class
TaskView
{
static
template
=
`
<input type="checkbox" name="done"/>
<task-description> -- </task-description>
`
constructor
(
task
){
this
.
task
=
task
this
.
element
=
document
.
createElement
(
"task-summary"
)
this
.
element
.
innerHTML
=
this
.
constructor
.
template
this
.
fields
=
{
done
:
this
.
element
.
querySelector
(
"[name=done]"
),
}
this
.
update
()
this
.
task
.
addEventListener
(
"change"
,
()
=>
this
.
update
())
this
.
fields
.
done
.
addEventListener
(
"change"
,
()
=>
{
this
.
task
.
done
=
this
.
fields
.
done
.
checked
})
}
update
()
{
this
.
fields
.
done
.
checked
=
this
.
task
.
done
this
.
element
.
querySelector
(
"task-description"
).
innerText
=
this
.
task
.
description
}
}
export
default
TaskView
\ No newline at end of file
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