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" 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() 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 Task from "./task.js"
import TaskView from "./view.js"
import DetailTaskView from "./detail_view.js"
class TaskController { class TaskController {
constructor(){ constructor(main_view){
this.tasks = [] this.tasks = []
this.task_views = [] this.view = main_view
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"}))
})
} }
addTask(task){ addTask(task){
let view = new TaskView(task) this.view.addTaskView(task)
view.element.addEventListener("click", () => this.detail_view.task = task )
this.list_element.appendChild(view.element)
this.task_views.push(view)
task.addEventListener("change", () => this.save(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