Lepší mazání korektur a komentářů
This commit is contained in:
parent
cb8f0aab18
commit
c1eb44e599
2 changed files with 17 additions and 2 deletions
|
@ -91,11 +91,16 @@
|
||||||
fetch('{% url "korektury_api_komentar_smaz" %}', {method: 'POST', body: data})
|
fetch('{% url "korektury_api_komentar_smaz" %}', {method: 'POST', body: data})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
||||||
this.htmlElement.remove();
|
this.smaz_pouze_na_strance();
|
||||||
place_comments();
|
place_comments();
|
||||||
})
|
})
|
||||||
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smaz_pouze_na_strance() {
|
||||||
|
delete komentare[this.id];
|
||||||
|
this.htmlElement.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -163,11 +163,21 @@
|
||||||
fetch('{% url "korektury_api_oprava_smaz" %}', {method: 'POST', body: data})
|
fetch('{% url "korektury_api_oprava_smaz" %}', {method: 'POST', body: data})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
||||||
comments[this.img_id].splice(comments[this.img_id].indexOf(this), 1);
|
this.#smaz_pouze_na_strance()
|
||||||
|
updatuj_pocty_stavu();
|
||||||
|
updatuj_pocty_zasluh();
|
||||||
place_comments();
|
place_comments();
|
||||||
})
|
})
|
||||||
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#smaz_pouze_na_strance() {
|
||||||
|
comments[this.img_id].splice(comments[this.img_id].indexOf(this), 1);
|
||||||
|
delete opravy[this.id];
|
||||||
|
for (const komentar of Object.values(komentare)) if (komentar.oprava === this) komentar.smaz_pouze_na_strance();
|
||||||
|
this.htmlElement.remove();
|
||||||
|
this.pointer.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue