Delete task is functional

This commit is contained in:
P-A
2026-02-07 13:32:49 +01:00
parent 0f28082e46
commit e19fb86808

View File

@@ -1,73 +1,73 @@
class HomeworkPage extends HomeworkElement { class HomeworkPage extends HomeworkElement {
constructor (type) { constructor (type) {
super() super()
this.innerHTML = this.innerHTML =
` `
<div id="page-header"> <div id="page-header">
<h2 id="text005" class="text"></h2> <h2 id="text005" class="text"></h2>
<div id="buttons"> <div id="buttons">
<div id="new" class="button"> <div id="new" class="button">
<span id="text035" class="button-text text"></span> <span id="text035" class="button-text text"></span>
</div> </div>
<div id="save" class="button"> <div id="save" class="button">
<span id="text037" class="button-text text"></span> <span id="text037" class="button-text text"></span>
</div> </div>
<div id="train" class="button"> <div id="train" class="button">
<span id="text036" class="button-text text"></span> <span id="text036" class="button-text text"></span>
</div>
</div> </div>
</div> </div>
<div id="sub-headers"> </div>
<p class="text source-language"></p> <div id="sub-headers">
<p class="text target-language"></p> <p class="text source-language"></p>
</div> <p class="text target-language"></p>
<div id="content"> </div>
</div> <div id="content">
` </div>
let languageTextId = "" `
let sourceLanguageTextId = "text030" let languageTextId = ""
let targetLanguageTextId = "" let sourceLanguageTextId = "text030"
switch(type) { let targetLanguageTextId = ""
case HomeworkTypes.VOCABULARY_ENGLISH: switch(type) {
console.log("English vocabulary") case HomeworkTypes.VOCABULARY_ENGLISH:
languageTextId = "text005" console.log("English vocabulary")
targetLanguageTextId = "text031" languageTextId = "text005"
break targetLanguageTextId = "text031"
case HomeworkTypes.VOCABULARY_FRENCH: break
console.log("French vocabulary") case HomeworkTypes.VOCABULARY_FRENCH:
languageTextId = "text025" console.log("French vocabulary")
targetLanguageTextId = "text032" languageTextId = "text025"
break targetLanguageTextId = "text032"
case HomeworkTypes.VOCABULARY_GERMAN: break
console.log("German vocabulary") case HomeworkTypes.VOCABULARY_GERMAN:
languageTextId = "text024" console.log("German vocabulary")
targetLanguageTextId = "text034" languageTextId = "text024"
break targetLanguageTextId = "text034"
case HomeworkTypes.VOCABULARY_SPANISH: break
console.log("Spanish vocabulary") case HomeworkTypes.VOCABULARY_SPANISH:
languageTextId = "text026" console.log("Spanish vocabulary")
targetLanguageTextId = "text033" languageTextId = "text026"
break targetLanguageTextId = "text033"
default: break
console.log("Math") default:
languageTextId = "text004" console.log("Math")
} languageTextId = "text004"
this.type = type }
this.headingText = this.querySelector('h2') this.type = type
this.headingText.setAttribute("id", languageTextId) this.headingText = this.querySelector('h2')
this.languageHeaders = this.querySelectorAll('#sub-headers > p') this.headingText.setAttribute("id", languageTextId)
this.sourceLanguage = this.languageHeaders[0] this.languageHeaders = this.querySelectorAll('#sub-headers > p')
this.targetLanguage = this.languageHeaders[1] this.sourceLanguage = this.languageHeaders[0]
this.sourceLanguage.setAttribute("id", sourceLanguageTextId) this.targetLanguage = this.languageHeaders[1]
this.targetLanguage.setAttribute("id", targetLanguageTextId) this.sourceLanguage.setAttribute("id", sourceLanguageTextId)
this.content = this.querySelector('#content') this.targetLanguage.setAttribute("id", targetLanguageTextId)
this.content.addEventListener("delete", this.deleteTask.bind(this)) this.content = this.querySelector('#content')
this.newButton = this.querySelector('#new') this.content.addEventListener("delete", this.deleteTask.bind(this))
this.newButton.addEventListener("click", this.newVocabulary.bind(this)) this.newButton = this.querySelector('#new')
this.saveButton = this.querySelector('#save') this.newButton.addEventListener("click", this.newVocabulary.bind(this))
this.saveButton.addEventListener("click", this.saveVocabularies.bind(this)) this.saveButton = this.querySelector('#save')
this.trainButton = this.querySelector('#train') this.saveButton.addEventListener("click", this.saveVocabularies.bind(this))
this.trainButton.addEventListener("click", this.trainVocabulary.bind(this)) this.trainButton = this.querySelector('#train')
this.trainButton.addEventListener("click", this.trainVocabulary.bind(this))
} }
connectedCallback() { connectedCallback() {
@@ -86,7 +86,7 @@ class HomeworkPage extends HomeworkElement {
} }
saveVocabularies() { saveVocabularies() {
console.log("Saving page content") console.log("Saving page content")
} }
trainVocabulary() { trainVocabulary() {
@@ -98,7 +98,7 @@ class HomeworkPage extends HomeworkElement {
if(tasks.length > 1) { if(tasks.length > 1) {
tasks.forEach((task) => { tasks.forEach((task) => {
if(event.detail.id == task.getId()) { if(event.detail.id == task.getId()) {
alert(task.getId()) console.log("Removing task '" + task.getId() + "'")
task.remove() task.remove()
} }
}) })