Commit eec35420 authored by Milan Iliev's avatar Milan Iliev

MainView

parent dfa03faf
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
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
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))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment