| 3 | |
| 4 | class Talk { |
| 5 | constructor(talk, dispatch) { |
| 6 | this.comments = elt("div"); |
| 7 | this.dom = elt( |
| 8 | "section", {className: "talk"}, |
| 9 | elt("h2", null, talk.title, " ", elt("button", { |
| 10 | type: "button", |
| 11 | onclick: () => dispatch({type: "deleteTalk", |
| 12 | talk: talk.title}) |
| 13 | }, "Delete")), |
| 14 | elt("div", null, "by ", |
| 15 | elt("strong", null, talk.presenter)), |
| 16 | elt("p", null, talk.summary), |
| 17 | this.comments, |
| 18 | elt("form", { |
| 19 | onsubmit(event) { |
| 20 | event.preventDefault(); |
| 21 | let form = event.target; |
| 22 | dispatch({type: "newComment", |
| 23 | talk: talk.title, |
| 24 | message: form.elements.comment.value}); |
| 25 | form.reset(); |
| 26 | } |
| 27 | }, elt("input", {type: "text", name: "comment"}), " ", |
| 28 | elt("button", {type: "submit"}, "Add comment"))); |
| 29 | this.syncState(talk); |
| 30 | } |
| 31 | |
| 32 | syncState(talk) { |
| 33 | this.talk = talk; |