Update
This commit is contained in:
@@ -61,6 +61,7 @@ class HomeworkPage extends HomeworkElement {
|
|||||||
this.sourceLanguage.setAttribute("id", sourceLanguageTextId)
|
this.sourceLanguage.setAttribute("id", sourceLanguageTextId)
|
||||||
this.targetLanguage.setAttribute("id", targetLanguageTextId)
|
this.targetLanguage.setAttribute("id", targetLanguageTextId)
|
||||||
this.content = this.querySelector('#content')
|
this.content = this.querySelector('#content')
|
||||||
|
this.content.addEventListener("delete", this.deleteTask.bind(this))
|
||||||
this.newButton = this.querySelector('#new')
|
this.newButton = this.querySelector('#new')
|
||||||
this.newButton.addEventListener("click", this.newVocabulary.bind(this))
|
this.newButton.addEventListener("click", this.newVocabulary.bind(this))
|
||||||
this.saveButton = this.querySelector('#save')
|
this.saveButton = this.querySelector('#save')
|
||||||
@@ -72,14 +73,14 @@ class HomeworkPage extends HomeworkElement {
|
|||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
console.log("Page of type " + this.type + " added to session")
|
console.log("Page of type " + this.type + " added to session")
|
||||||
if(this.type == HomeworkTypes.VOCABULARY_ENGLISH) {
|
if(this.type == HomeworkTypes.VOCABULARY_ENGLISH) {
|
||||||
const row = new HomeworkVocabularyTask()
|
const row = new HomeworkVocabularyTask(crypto.randomUUID())
|
||||||
this.content.append(row)
|
this.content.append(row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newVocabulary() {
|
newVocabulary() {
|
||||||
if(this.type == HomeworkTypes.VOCABULARY_ENGLISH) {
|
if(this.type == HomeworkTypes.VOCABULARY_ENGLISH) {
|
||||||
const row = new HomeworkVocabularyTask()
|
const row = new HomeworkVocabularyTask(crypto.randomUUID())
|
||||||
this.content.append(row)
|
this.content.append(row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,5 +92,18 @@ class HomeworkPage extends HomeworkElement {
|
|||||||
trainVocabulary() {
|
trainVocabulary() {
|
||||||
console.log("Train!!")
|
console.log("Train!!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteTask(event) {
|
||||||
|
const tasks = this.content.querySelectorAll("homework-vocabulary-task")
|
||||||
|
if(tasks.length > 1) {
|
||||||
|
tasks.forEach((task) => {
|
||||||
|
if(event.detail.id == task.getId()) {
|
||||||
|
alert(task.getId())
|
||||||
|
task.remove()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
customElements.define('homework-page', HomeworkPage)
|
customElements.define('homework-page', HomeworkPage)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
class HomeworkVocabularyTask extends HomeworkElement {
|
class HomeworkVocabularyTask extends HomeworkElement {
|
||||||
constructor () {
|
constructor (id) {
|
||||||
super()
|
super()
|
||||||
this.innerHTML =
|
this.innerHTML =
|
||||||
`
|
`
|
||||||
@@ -9,6 +9,7 @@ class HomeworkVocabularyTask extends HomeworkElement {
|
|||||||
<img src="/images/check-circle.svg" class="disabled">
|
<img src="/images/check-circle.svg" class="disabled">
|
||||||
<img src="/images/times-circle.svg" class="disabled">
|
<img src="/images/times-circle.svg" class="disabled">
|
||||||
`
|
`
|
||||||
|
this.id = id
|
||||||
this.setAttribute("result", "unknown")
|
this.setAttribute("result", "unknown")
|
||||||
this.setAttribute("state", "edit")
|
this.setAttribute("state", "edit")
|
||||||
this.deleteButton = this.querySelector('img#delete')
|
this.deleteButton = this.querySelector('img#delete')
|
||||||
@@ -21,6 +22,11 @@ class HomeworkVocabularyTask extends HomeworkElement {
|
|||||||
|
|
||||||
deleteTask() {
|
deleteTask() {
|
||||||
console.log("Delete line")
|
console.log("Delete line")
|
||||||
|
this.dispatchEvent(new CustomEvent("delete", {detail:{id: this.id}, bubbles: true, cancelable: true}))
|
||||||
|
}
|
||||||
|
|
||||||
|
getId() {
|
||||||
|
return this.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customElements.define('homework-vocabulary-task', HomeworkVocabularyTask)
|
customElements.define('homework-vocabulary-task', HomeworkVocabularyTask)
|
||||||
Reference in New Issue
Block a user