Compare commits
No commits in common. "ec5f6af6f94c7ab42a7600a0d3fc1cfee1478034" and "c125d7a62b87de73fa7295b69b2c9462a4bfd93d" have entirely different histories.
ec5f6af6f9
...
c125d7a62b
6 changed files with 19 additions and 59 deletions
|
@ -101,11 +101,9 @@ def opravy_a_komentare_view(request, pdf_id: int, **kwargs):
|
||||||
|
|
||||||
if komentar_id != -1:
|
if komentar_id != -1:
|
||||||
komentar = get_object_or_404(Komentar, id=komentar_id)
|
komentar = get_object_or_404(Komentar, id=komentar_id)
|
||||||
if komentar.text != text:
|
komentar.text = text
|
||||||
komentar.text = text
|
komentar.autor = autor
|
||||||
komentar.autor = autor
|
komentar.save()
|
||||||
komentar.save()
|
|
||||||
oprava = komentar.oprava
|
|
||||||
else:
|
else:
|
||||||
if oprava_id != -1:
|
if oprava_id != -1:
|
||||||
oprava = get_object_or_404(Oprava, id=oprava_id)
|
oprava = get_object_or_404(Oprava, id=oprava_id)
|
||||||
|
@ -118,16 +116,13 @@ def opravy_a_komentare_view(request, pdf_id: int, **kwargs):
|
||||||
y=y,
|
y=y,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tagy_raw = q.get('tagy')
|
||||||
|
if tagy_raw != "":
|
||||||
|
tagy = list(map(int, tagy_raw.split(",")))
|
||||||
|
oprava.tagy.add(*KorekturaTag.objects.filter(id__in=tagy))
|
||||||
Komentar.objects.create(oprava=oprava, autor=autor, text=text)
|
Komentar.objects.create(oprava=oprava, autor=autor, text=text)
|
||||||
send_email_notification_komentar(oprava, autor, request)
|
send_email_notification_komentar(oprava, autor, request)
|
||||||
|
|
||||||
tagy_raw = q.get('tagy')
|
|
||||||
if tagy_raw is not None:
|
|
||||||
oprava.tagy.clear()
|
|
||||||
if tagy_raw != "":
|
|
||||||
tagy = list(map(int, tagy_raw.split(",")))
|
|
||||||
oprava.tagy.add(*KorekturaTag.objects.filter(id__in=tagy))
|
|
||||||
|
|
||||||
|
|
||||||
opravy = Oprava.objects.filter(pdf=pdf_id).all()
|
opravy = Oprava.objects.filter(pdf=pdf_id).all()
|
||||||
# Serializovat list je prý security vulnerability, tedy je přidán slovník pro bezpečnost
|
# Serializovat list je prý security vulnerability, tedy je přidán slovník pro bezpečnost
|
||||||
|
|
|
@ -20,11 +20,6 @@ body {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#sbal-korektury, #rozbal-korektury {
|
|
||||||
float: right;
|
|
||||||
margin-left: 4pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
img{background:white;}
|
img{background:white;}
|
||||||
|
|
||||||
/* Barvy korektur */
|
/* Barvy korektur */
|
||||||
|
|
|
@ -5,12 +5,11 @@
|
||||||
<br/>
|
<br/>
|
||||||
<textarea id="commform-text" cols=40 rows=10 name="txt"></textarea>
|
<textarea id="commform-text" cols=40 rows=10 name="txt"></textarea>
|
||||||
<br/>
|
<br/>
|
||||||
<div id="commform-tagy-info">Úprava tagů celé korektury:</div>
|
<span id="commform-tagy">
|
||||||
<div id="commform-tagy">
|
|
||||||
{% for tag in tagy %}
|
{% for tag in tagy %}
|
||||||
<button type="button" class="korektury-tag" value="{{tag.id}}" data-selected="false" style="background: {{ tag.barva }}; border-color: {{ tag.barva }};">{{tag.nazev}}</button>
|
<button type="button" class="korektury-tag" value="{{tag.id}}" data-selected="false" style="background: {{ tag.barva }}; border-color: {{ tag.barva }};">{{tag.nazev}}</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -21,7 +20,6 @@
|
||||||
this.submit_button = document.getElementById('commform-submit');
|
this.submit_button = document.getElementById('commform-submit');
|
||||||
const close_button = document.getElementById('commform-close');
|
const close_button = document.getElementById('commform-close');
|
||||||
this.tagy = document.getElementById('commform-tagy');
|
this.tagy = document.getElementById('commform-tagy');
|
||||||
this.tagy_info = document.getElementById('commform-tagy-info');
|
|
||||||
|
|
||||||
|
|
||||||
// ctrl-enter submits form
|
// ctrl-enter submits form
|
||||||
|
@ -73,16 +71,8 @@
|
||||||
this.text.value = text;
|
this.text.value = text;
|
||||||
|
|
||||||
// show form
|
// show form
|
||||||
if (oprava_id === -1 && komentar_id === -1) {
|
if (oprava_id === -1 && komentar_id === -1) this.tagy.style.display = 'unset'; else this.tagy.style.display = 'none';
|
||||||
if (this.reset_tags_every_open) this.reset_tags();
|
if (this.reset_tags_every_open) this.reset_tags();
|
||||||
this.tagy_info.style.display = 'none';
|
|
||||||
} else {
|
|
||||||
const oprava = opravy[oprava_id];
|
|
||||||
this.tagy_info.style.display = 'unset';
|
|
||||||
for (const tag of this.tagy.getElementsByTagName("button"))
|
|
||||||
tag.dataset.selected = String(oprava.tagy.has(parseInt(tag.value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
this._show(img_id, x, y);
|
this._show(img_id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,12 +84,13 @@
|
||||||
data.append('img_id', this.imgID);
|
data.append('img_id', this.imgID);
|
||||||
data.append('oprava_id', this.oprava_id);
|
data.append('oprava_id', this.oprava_id);
|
||||||
data.append('komentar_id', this.komentar_id);
|
data.append('komentar_id', this.komentar_id);
|
||||||
|
if (this.oprava_id === -1 && this.komentar_id === -1) {
|
||||||
const tagy = [];
|
const tagy = [];
|
||||||
for (const tag of this.tagy.getElementsByTagName("button")) {
|
for (const tag of this.tagy.getElementsByTagName("button")) {
|
||||||
if (tag.dataset.selected !== "false") tagy.push(tag.value);
|
if (tag.dataset.selected !== "false") tagy.push(tag.value);
|
||||||
|
}
|
||||||
|
data.append('tagy', String(tagy));
|
||||||
}
|
}
|
||||||
data.append('tagy', String(tagy));
|
|
||||||
|
|
||||||
data.append('text', this.text.value);
|
data.append('text', this.text.value);
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
|
|
||||||
// show comment form when 'update-comment' button pressed
|
// show comment form when 'update-comment' button pressed
|
||||||
#update_comment() {
|
#update_comment() {
|
||||||
return commform.show(this.oprava.img_id, this.oprava.x, this.oprava.y, this.#text.textContent, this.oprava.id, this.id);
|
return commform.show(this.oprava.img_id, this.oprava.x, this.oprava.y, this.#text.textContent, -1, this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
#delete_comment() {
|
#delete_comment() {
|
||||||
|
|
|
@ -72,7 +72,6 @@
|
||||||
#komentare; #tagy;
|
#komentare; #tagy;
|
||||||
htmlElement; pointer;
|
htmlElement; pointer;
|
||||||
id; x; y; img_id; status; zobrazit = true; {# oprava_data; #}
|
id; x; y; img_id; status; zobrazit = true; {# oprava_data; #}
|
||||||
tagy;
|
|
||||||
|
|
||||||
constructor(oprava_data) {
|
constructor(oprava_data) {
|
||||||
this.htmlElement = preoprava.cloneNode(true);
|
this.htmlElement = preoprava.cloneNode(true);
|
||||||
|
@ -110,9 +109,7 @@
|
||||||
{# this.oprava_data = oprava_data; #}
|
{# this.oprava_data = oprava_data; #}
|
||||||
this.set_status(oprava_data['status']);
|
this.set_status(oprava_data['status']);
|
||||||
this.#tagy.innerHTML = "";
|
this.#tagy.innerHTML = "";
|
||||||
this.tagy = new Set();
|
|
||||||
for (const tag of oprava_data["tagy"]) {
|
for (const tag of oprava_data["tagy"]) {
|
||||||
this.tagy.add(tag["id"]);
|
|
||||||
const span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
span.innerHTML = tag["nazev"];
|
span.innerHTML = tag["nazev"];
|
||||||
span.classList.add("korektury-tag");
|
span.classList.add("korektury-tag");
|
||||||
|
@ -134,12 +131,9 @@
|
||||||
|
|
||||||
|
|
||||||
// hide or show text of correction
|
// hide or show text of correction
|
||||||
toggle_visibility() {
|
#toggle_visibility(){
|
||||||
this.zobrazit = !this.zobrazit;
|
this.zobrazit = !this.zobrazit;
|
||||||
this.htmlElement.dataset.opravazobrazit = String(this.zobrazit);
|
this.htmlElement.dataset.opravazobrazit = String(this.zobrazit);
|
||||||
}
|
|
||||||
#toggle_visibility(){
|
|
||||||
this.toggle_visibility();
|
|
||||||
place_comments()
|
place_comments()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,6 @@ Zobrazit:
|
||||||
onchange="toggle_corrections('k_zaneseni')" checked>
|
onchange="toggle_corrections('k_zaneseni')" checked>
|
||||||
<label for="k_zaneseni_checkbox">K zanesení (<span id="k_zaneseni_pocet">↺</span>)</label>
|
<label for="k_zaneseni_checkbox">K zanesení (<span id="k_zaneseni_pocet">↺</span>)</label>
|
||||||
|
|
||||||
|
|
||||||
<button type="button" id="sbal-korektury">Sbal korektury</button>
|
|
||||||
<button type="button" id="rozbal-korektury">Rozbal korektury</button>
|
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -69,15 +65,4 @@ Zobrazit:
|
||||||
}
|
}
|
||||||
for (let [stav, pocet] of Object.entries(pocty_stavu)) spany_s_pocty_stavu[stav].innerText = pocet;
|
for (let [stav, pocet] of Object.entries(pocty_stavu)) spany_s_pocty_stavu[stav].innerText = pocet;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("sbal-korektury").addEventListener("click", () => {
|
|
||||||
for (const oprava of Object.values(opravy))
|
|
||||||
if (oprava.zobrazit) oprava.toggle_visibility();
|
|
||||||
place_comments();
|
|
||||||
})
|
|
||||||
document.getElementById("rozbal-korektury").addEventListener("click", () => {
|
|
||||||
for (const oprava of Object.values(opravy))
|
|
||||||
if (!oprava.zobrazit) oprava.toggle_visibility();
|
|
||||||
place_comments();
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue