Commit 63f10951 authored by Raphaël Jakse's avatar Raphaël Jakse

feat: addTodo, setTodo on elements

parent d77541d9
......@@ -53,7 +53,7 @@ class Label extends ProjectTrackingElem {}
class Elem extends ProjectTrackingElem {
constructor (info) {
super(info.text)
for (const member of ['project', 'labels', 'todo', 'difficulty', 'link', 'done']) {
for (const member of ['project', 'labels', 'difficulty', 'link', 'done']) {
this[member] = info[member]
}
......@@ -67,6 +67,21 @@ class Elem extends ProjectTrackingElem {
: [nobody]
)
this.blockedByMe = info.blocks || []
this.blockedBy = info.blockedBy || []
this.notes = info.notes || []
if (info.note) {
this.notes.push(note)
}
this.todo = info.todo ? (
Array.isArray(info.todo)
? info.todo
: [info.todo]
) : []
if (this.persons[0] === nobody) {
console.warn('Element', info.text, 'has nobody')
}
......@@ -76,15 +91,6 @@ class Elem extends ProjectTrackingElem {
for (const person of this.persons) {
person.addElem(this)
}
this.blockedByMe = info.blocks || []
this.blockedBy = info.blockedBy || []
this.notes = info.notes || []
if (info.note) {
this.notes.push(note)
}
}
blocks (blocked) {
......@@ -100,6 +106,14 @@ class Elem extends ProjectTrackingElem {
this.notes.push(note)
}
addTodo (note) {
this.todo.push(note)
}
setTodo (note) {
this.todo = [note]
}
render (asLi = false) {
const div = document.createElement(asLi ? 'li' : 'div')
div.className = 'project-tracking-elem' + (this.done ? ' project-tracking-elem-done' : '')
......@@ -137,14 +151,14 @@ class Elem extends ProjectTrackingElem {
}
div.appendChild(title)
if (this.todo || this.difficulty || this.notes.length) {
if (this.todo.length || this.difficulty || this.notes.length) {
const details = document.createElement('div')
details.className = 'project-tracking-elem-details'
if (this.todo) {
if (this.todo.length) {
const todo = document.createElement('p')
todo.className = 'project-tracking-elem-todo'
todo.textContent = 'À faire : ' + this.todo
todo.textContent = 'À faire : ' + this.todo.join(', ')
details.appendChild(todo)
}
......
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