Box_edit za pomoci objektu opravy místo id

This commit is contained in:
Jonas Havelka 2025-01-21 08:10:13 +01:00
parent 4121de260e
commit d818ce251b
2 changed files with 6 additions and 7 deletions

View file

@ -99,13 +99,13 @@ function toggle_visibility(oprava){
}
// show comment form, when 'edit' or 'comment' button pressed
function box_edit(oid, action)
function box_edit(op, action)
{
var divpointer = document.getElementById(oid + '-pointer');
var divpointer = document.getElementById(op.id + '-pointer');
var text;
if (action == 'update') {
var text_el = document.getElementById(oid + '-text');
var text_el = document.getElementById(op.id + '-text');
text = text_el.textContent;
} else {
@ -114,9 +114,7 @@ function box_edit(oid, action)
var dx = parseInt(divpointer.style.left);
var dy = parseInt(divpointer.style.top);
var divbox = document.getElementById(oid);
id = oid.substring(2);
return show_form(divbox.img_id, dx, dy, id, text, action);
return show_form(op.img_id, dx, dy, op.dataset.opid, text, action);
}
// show comment form when 'update-comment' button pressed

View file

@ -10,6 +10,7 @@
class='box'
data-opravastatus="{{o.status}}"
data-opravazobrazit="true"
data-opid="{{o.id}}"
onmouseover='box_onmouseover(this)'
onmouseout='box_onmouseout(this)'
>
@ -48,7 +49,7 @@
<button type='button' value="notcomment" title='Korekturu nelze komentovat, protože už je uzavřená'>
<img src="{% static "korektury/imgs/comment-gr.png" %}"/>
</button>
<button type='button' value="comment" onclick='box_edit("op{{o.id}}", "comment");' title='Komentovat'>
<button type='button' value="comment" onclick='box_edit(this.parentElement.parentElement.parentElement.parentElement, "comment");' title='Komentovat'>
<img src="{% static "korektury/imgs/comment.png" %}"/>
</button>