Compare commits
8 commits
dd86fc1fcb
...
d2e199e509
Author | SHA1 | Date | |
---|---|---|---|
d2e199e509 | |||
9b0fe3d32f | |||
af41ca5784 | |||
ad2d1e676c | |||
00e0ed0a50 | |||
5563eb681c | |||
3b74772949 | |||
ee69bf4c4f |
12 changed files with 177 additions and 178 deletions
|
@ -4,4 +4,5 @@ from . import views
|
|||
|
||||
urlpatterns = [
|
||||
path('korektury/api/<int:pdf_id>/stav', org_required(views.korektury_stav_view), name='korektury_api_pdf_stav'),
|
||||
path('korektury/api/oprava/stav', org_required(views.oprava_stav_view), name='korektury_api_oprava_stav'),
|
||||
]
|
||||
|
|
|
@ -18,3 +18,17 @@ def korektury_stav_view(request, pdf_id: int, **kwargs):
|
|||
pdf.status = status
|
||||
pdf.save()
|
||||
return JsonResponse({'status': pdf.status})
|
||||
|
||||
|
||||
def oprava_stav_view(request, **kwargs):
|
||||
q = request.POST
|
||||
op_id_str = q.get('id')
|
||||
assert op_id_str is not None
|
||||
op_id = int(op_id_str)
|
||||
op = get_object_or_404(Oprava, id=op_id)
|
||||
status = q.get('action')
|
||||
if status is not None:
|
||||
assert status in Oprava.STATUS.values
|
||||
op.status = status
|
||||
op.save()
|
||||
return JsonResponse({'status': op.status})
|
||||
|
|
|
@ -20,17 +20,35 @@ body[data-status="zastarale"] {
|
|||
img{background:white;}
|
||||
|
||||
/* Barvy korektur */
|
||||
.k_oprave {
|
||||
[data-opravastatus="k_oprave"] {
|
||||
--rgb: 255, 0, 0;
|
||||
|
||||
[value="k_oprave"] { display: none }
|
||||
[value="notcomment"] { display: none }
|
||||
}
|
||||
.opraveno {
|
||||
[data-opravastatus="opraveno"] {
|
||||
--rgb: 0, 0, 255;
|
||||
|
||||
[value="opraveno"] { display: none }
|
||||
[value="comment"] { display: none }
|
||||
}
|
||||
.neni_chyba {
|
||||
[data-opravastatus="neni_chyba"] {
|
||||
--rgb: 128, 128, 128;
|
||||
|
||||
[value="neni_chyba"] { display: none }
|
||||
[value="comment"] { display: none }
|
||||
}
|
||||
.k_zaneseni {
|
||||
[data-opravastatus="k_zaneseni"] {
|
||||
--rgb: 0, 255, 0;
|
||||
|
||||
[value="k_zaneseni"] { display: none }
|
||||
[value="notcomment"] { display: none }
|
||||
}
|
||||
|
||||
[data-opravazobrazit="false"] {
|
||||
.corr-body { display: none; }
|
||||
.corr-buttons { display: none; }
|
||||
.toggle-button { transform: rotate(180deg); }
|
||||
}
|
||||
|
||||
.pointer-hi,
|
||||
|
|
|
@ -22,7 +22,6 @@ function place_comments_one_div(img_id, comments)
|
|||
}
|
||||
|
||||
});
|
||||
//console.log("w:" + w);
|
||||
for (c in comments_sorted) {
|
||||
var id = comments_sorted[c][0];
|
||||
var x = comments_sorted[c][1];
|
||||
|
@ -53,13 +52,8 @@ function place_comments_one_div(img_id, comments)
|
|||
|
||||
var bott = el.offsetTop + el.offsetHeight;
|
||||
bott_max = ( bott_max > bott ) ? bott_max : bott;
|
||||
|
||||
//console.log( "par.w:" + par.style.width);
|
||||
|
||||
}
|
||||
if( par.offsetHeight < bott_max ) {
|
||||
//par.style.height = bott_max;
|
||||
//alert("preteklo to:"+ par.offsetHeight +",mx:" + bott_max );
|
||||
par.style.height = bott_max;
|
||||
|
||||
}
|
||||
|
@ -71,33 +65,6 @@ function place_comments() {
|
|||
}
|
||||
}
|
||||
|
||||
// ctrl-enter submits form
|
||||
function textarea_onkey(ev)
|
||||
{
|
||||
//console.log("ev:" + ev.keyCode + "," + ev.ctrlKey);
|
||||
if( (ev.keyCode == 13 || ev.keyCode == 10 ) && ev.ctrlKey ) {
|
||||
var form = document.getElementById('commform');
|
||||
if( form ) {
|
||||
save_scroll(form);
|
||||
//form.action ='';
|
||||
form.submit();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//hide comment form
|
||||
function close_commform() {
|
||||
var formdiv = document.getElementById('commform-div');
|
||||
if( formdiv == null ) {
|
||||
alert("form null");
|
||||
return true;
|
||||
}
|
||||
formdiv.style.display = 'none';
|
||||
return false;
|
||||
}
|
||||
|
||||
// show comment form, when clicked to image
|
||||
function img_click(element, ev) {
|
||||
var body_class = document.body.className;
|
||||
|
@ -129,19 +96,8 @@ function img_click(element, ev) {
|
|||
return show_form(img_id, dx, dy, '', '', '', '');
|
||||
}
|
||||
// hide or show text of correction
|
||||
function toggle_visibility(oid){
|
||||
var buttondiv = document.getElementById(oid+'-buttons')
|
||||
var text = document.getElementById(oid+'-body');
|
||||
var toggleimg = document.getElementById(oid+'-toggleimg');
|
||||
if (text.style.display == 'none'){
|
||||
text.style.display = 'block';
|
||||
buttondiv.style.display = 'inline-block';
|
||||
toggleimg.style.transform = "";
|
||||
}else {
|
||||
text.style.display = 'none';
|
||||
buttondiv.style.display = 'none';
|
||||
toggleimg.style.transform = "rotate(180deg)";
|
||||
}
|
||||
function toggle_visibility(oprava){
|
||||
oprava.dataset.opravazobrazit = oprava.dataset.opravazobrazit !== 'true';
|
||||
for (var i=0;i<comments.length-1;i++){
|
||||
place_comments_one_div(comments[i][0], comments[i][1])
|
||||
}
|
||||
|
@ -155,7 +111,7 @@ function box_edit(oid, action)
|
|||
var text;
|
||||
if (action == 'update') {
|
||||
var text_el = document.getElementById(oid + '-text');
|
||||
text = text_el.textContent; // FIXME původně tu bylo innerHTML.unescapeHTML()
|
||||
text = text_el.textContent;
|
||||
|
||||
} else {
|
||||
text = '';
|
||||
|
@ -164,7 +120,6 @@ function box_edit(oid, action)
|
|||
var dx = parseInt(divpointer.style.left);
|
||||
var dy = parseInt(divpointer.style.top);
|
||||
var divbox = document.getElementById(oid);
|
||||
//alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo );
|
||||
id = oid.substring(2);
|
||||
return show_form(divbox.img_id, dx, dy, id, text, action);
|
||||
}
|
||||
|
@ -177,55 +132,13 @@ function update_comment(oid,ktid)
|
|||
var dy = parseInt(divpointer.style.top);
|
||||
|
||||
var divbox = document.getElementById(oid);
|
||||
var text = document.getElementById(ktid).textContent; // FIXME původně tu bylo innerHTML.unescapeHTML()
|
||||
var text = document.getElementById(ktid).textContent;
|
||||
|
||||
return show_form(divbox.img_id, dx, dy, ktid.substring(2), text, 'update-comment');
|
||||
}
|
||||
|
||||
//fill up comment form and show him
|
||||
function show_form(img_id, dx, dy, id, text, action) {
|
||||
var form = document.getElementById('commform');
|
||||
var formdiv = document.getElementById('commform-div');
|
||||
var textarea = document.getElementById('commform-text');
|
||||
var inputX = document.getElementById('commform-x');
|
||||
var inputY = document.getElementById('commform-y');
|
||||
var inputImgId = document.getElementById('commform-img-id');
|
||||
var inputId = document.getElementById('commform-id');
|
||||
var inputAction = document.getElementById('commform-action');
|
||||
var img = document.getElementById(img_id);
|
||||
|
||||
if( formdiv == null || textarea == null ) {
|
||||
alert("form null");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//form.action = "#" + img_id;
|
||||
|
||||
// set hidden values
|
||||
inputX.value = dx;
|
||||
inputY.value = dy;
|
||||
inputImgId.value = img_id;
|
||||
inputId.value = id;
|
||||
inputAction.value = action;
|
||||
textarea.value = text;
|
||||
|
||||
//textarea.value = "dxy:"+ dx + "x" + dy + "\n" + 'id:' + img_id;
|
||||
|
||||
// show form
|
||||
formdiv.style.display = 'block';
|
||||
formdiv.style.left = dx;
|
||||
formdiv.style.top = dy;
|
||||
|
||||
img.parentNode.appendChild(formdiv);
|
||||
|
||||
textarea.focus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function box_onmouseover(box)
|
||||
{
|
||||
var id = box.id;
|
||||
var pointer = document.getElementById(box.id + '-pointer');
|
||||
pointer.classList.remove('pointer');
|
||||
pointer.classList.add('pointer-hi');
|
||||
|
@ -233,54 +146,8 @@ function box_onmouseover(box)
|
|||
|
||||
function box_onmouseout(box)
|
||||
{
|
||||
var id = box.id;
|
||||
var pointer = document.getElementById(box.id + '-pointer');
|
||||
pointer.classList.remove('pointer-hi');
|
||||
pointer.classList.add('pointer');
|
||||
}
|
||||
|
||||
function save_scroll(form)
|
||||
{
|
||||
//alert('save_scroll:' + document.body.scrollTop);
|
||||
form.scroll.value = document.body.scrollTop;
|
||||
//alert('save_scroll:' + form.scroll.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
function toggle_corrections(aclass)
|
||||
{
|
||||
var stylesheets = document.styleSheets;
|
||||
var ssheet = null;
|
||||
for (var i=0;i<stylesheets.length; i++){
|
||||
if (stylesheets[i].title === "opraf-css"){
|
||||
ssheet = stylesheets[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! ssheet){
|
||||
return;
|
||||
}
|
||||
for (var i=0;i<ssheet.cssRules.length;i++){
|
||||
var rule = ssheet.cssRules[i];
|
||||
if (rule.selectorText === '.'+aclass){
|
||||
if (rule.style.display === ""){
|
||||
rule.style.display = "none";
|
||||
} else {
|
||||
rule.style.display = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
place_comments();
|
||||
|
||||
}
|
||||
|
||||
|
||||
String.prototype.unescapeHTML = function () {
|
||||
return(
|
||||
this.replace(/&/g,'&').
|
||||
replace(/>/g,'>').
|
||||
replace(/</g,'<').
|
||||
replace(/"/g,'"')
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div id="commform-div">
|
||||
<form action='' onsubmit='save_scroll(this)' id="commform" method="POST">
|
||||
<form action='' id="commform" method="POST">
|
||||
{% csrf_token %}
|
||||
<input size="24" name="au" value="{{user.first_name}} {{user.last_name}}" readonly/>
|
||||
<input type=submit value="Oprav!"/>
|
||||
|
@ -12,6 +12,72 @@
|
|||
<input type="hidden" size="3" id="commform-img-id" name="img-id"/>
|
||||
<input type="hidden" size="3" id="commform-id" name="id"/>
|
||||
<input type="hidden" size="3" id="commform-action" name="action"/>
|
||||
<input type="hidden" size="3" id="commform-action" name="scroll"/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// ctrl-enter submits form
|
||||
function textarea_onkey(ev)
|
||||
{
|
||||
if( (ev.keyCode == 13 || ev.keyCode == 10 ) && ev.ctrlKey ) {
|
||||
var form = document.getElementById('commform');
|
||||
if( form ) {
|
||||
form.submit();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//hide comment form
|
||||
function close_commform() {
|
||||
var formdiv = document.getElementById('commform-div');
|
||||
if( formdiv == null ) {
|
||||
alert("form null");
|
||||
return true;
|
||||
}
|
||||
formdiv.style.display = 'none';
|
||||
return false;
|
||||
}
|
||||
|
||||
//fill up comment form and show him
|
||||
function show_form(img_id, dx, dy, id, text, action) {
|
||||
var form = document.getElementById('commform');
|
||||
var formdiv = document.getElementById('commform-div');
|
||||
var textarea = document.getElementById('commform-text');
|
||||
var inputX = document.getElementById('commform-x');
|
||||
var inputY = document.getElementById('commform-y');
|
||||
var inputImgId = document.getElementById('commform-img-id');
|
||||
var inputId = document.getElementById('commform-id');
|
||||
var inputAction = document.getElementById('commform-action');
|
||||
var img = document.getElementById(img_id);
|
||||
|
||||
if( formdiv == null || textarea == null ) {
|
||||
alert("form null");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//form.action = "#" + img_id;
|
||||
|
||||
// set hidden values
|
||||
inputX.value = dx;
|
||||
inputY.value = dy;
|
||||
inputImgId.value = img_id;
|
||||
inputId.value = id;
|
||||
inputAction.value = action;
|
||||
textarea.value = text;
|
||||
|
||||
//textarea.value = "dxy:"+ dx + "x" + dy + "\n" + 'id:' + img_id;
|
||||
|
||||
// show form
|
||||
formdiv.style.display = 'block';
|
||||
formdiv.style.left = dx;
|
||||
formdiv.style.top = dy;
|
||||
|
||||
img.parentNode.appendChild(formdiv);
|
||||
|
||||
textarea.focus();
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
<div class='author'>{{k.autor}}</div>
|
||||
<div class="float-right">
|
||||
<!-- Komentar !-->
|
||||
<form action='' onsubmit='save_scroll(this)' method='POST'>
|
||||
<form action='' method='POST'>
|
||||
{% csrf_token %}
|
||||
<input type='hidden' name='id' value='{{k.id}}'>
|
||||
<input type='hidden' name='scroll'>
|
||||
<button style="display: none" type='submit' name='action' value='del-comment' title='Smaž komentář'
|
||||
onclick='return confirm("Opravdu smazat komentář?")'>
|
||||
<img src="{% static "korektury/imgs/delete.png" %}"/>
|
||||
|
@ -21,4 +20,4 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id='kt{{k.id}}'>{{k.text|linebreaks}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,12 +2,17 @@
|
|||
|
||||
<div onclick='img_click(this,event)'
|
||||
id='op{{o.id}}-pointer'
|
||||
class='pointer {{o.status}}'>
|
||||
class='pointer'
|
||||
data-opravastatus="{{o.status}}"
|
||||
>
|
||||
</div>
|
||||
<div name='op{{o.id}}' id='op{{o.id}}'
|
||||
class='box {{o.status}}'
|
||||
class='box'
|
||||
data-opravastatus="{{o.status}}"
|
||||
data-opravazobrazit="true"
|
||||
onmouseover='box_onmouseover(this)'
|
||||
onmouseout='box_onmouseout(this)'>
|
||||
onmouseout='box_onmouseout(this)'
|
||||
>
|
||||
|
||||
<div class='corr-body' id='op{{o.id}}-body'>
|
||||
|
||||
|
@ -18,52 +23,40 @@
|
|||
</div>
|
||||
<div class='corr-header'>
|
||||
<span class='float-right'>
|
||||
<span id='op{{o.id}}-buttons'>
|
||||
<form action='' onsubmit='save_scroll(this)' method='POST'>
|
||||
<span id='op{{o.id}}-buttons' class='corr-buttons'>
|
||||
<form action='' method='POST'>
|
||||
{% csrf_token %}
|
||||
<input type='hidden' name='id' value='{{o.id}}'>
|
||||
<input type='hidden' name='scroll'>
|
||||
|
||||
<button style="display: none" type='submit' name='action' value='del' title='Smaž opravu'>
|
||||
<img src="{% static "korektury/imgs/delete.png"%}"/>
|
||||
</button>
|
||||
{% if o.status != o.STATUS.K_OPRAVE %}
|
||||
<button type='submit' name='action' value='{{ o.STATUS.K_OPRAVE }}' title='Označ jako neopravené'>
|
||||
<img src="{% static "korektury/imgs/undo.png"%}"/>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if o.status != o.STATUS.OPRAVENO %}
|
||||
<button type='submit' name='action' value='{{ o.STATUS.OPRAVENO }}' title='Označ jako opravené'>
|
||||
<img src="{% static "korektury/imgs/check.png"%}"/>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if o.status != o.STATUS.NENI_CHYBA %}
|
||||
<button type='submit' name='action' value='{{ o.STATUS.NENI_CHYBA }}' title='Označ, že se nebude měnit'>
|
||||
<img src="{% static "korektury/imgs/cross.png" %}"/>
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if o.status != o.STATUS.K_ZANESENI %}
|
||||
<button type='submit' name='action' value='{{ o.STATUS.K_ZANESENI }}' title='Označ jako připraveno k zanesení'>
|
||||
<img src="{% static "korektury/imgs/tex.png" %}"/>
|
||||
</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
||||
{% if o.status == 'opraveno' or o.status == 'neni_chyba' %}
|
||||
<button type='button' title='Korekturu nelze komentovat, protože už je uzavřená'>
|
||||
<button type='button' value="notcomment" title='Korekturu nelze komentovat, protože už je uzavřená'>
|
||||
<img src="{% static "korektury/imgs/comment-gr.png" %}"/>
|
||||
</button>
|
||||
{% else %}
|
||||
<button type='button' onclick='box_edit("op{{o.id}}", "comment");' title='Komentovat'>
|
||||
<button type='button' value="comment" onclick='box_edit("op{{o.id}}", "comment");' title='Komentovat'>
|
||||
<img src="{% static "korektury/imgs/comment.png" %}"/>
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
</span>
|
||||
<button type='button' onclick='toggle_visibility("op{{o.id}}");' title='Skrýt/Zobrazit'>
|
||||
<img id='op{{o.id}}-toggleimg' src="{% static "korektury/imgs/hide.png" %}"/>
|
||||
<button type='button' onclick='toggle_visibility(this.parentElement.parentElement.parentElement);' title='Skrýt/Zobrazit'>
|
||||
<img id='op{{o.id}}-toggleimg' class='toggle-button' src="{% static "korektury/imgs/hide.png" %}"/>
|
||||
</button>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -24,7 +24,4 @@
|
|||
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
|
||||
{% endfor %}
|
||||
[]]
|
||||
{% if scroll %}
|
||||
window.scrollTo(0,{{scroll}});
|
||||
{% endif %}
|
||||
</script>
|
||||
|
|
|
@ -20,4 +20,32 @@ Zobrazit:
|
|||
onchange="toggle_corrections('k_zaneseni')" checked>
|
||||
<label for="k_zaneseni_checkbox">K zanesení ({{k_zaneseni_cnt}})</label>
|
||||
|
||||
<hr/>
|
||||
<hr/>
|
||||
|
||||
<script>
|
||||
function toggle_corrections(aclass)
|
||||
{
|
||||
var stylesheets = document.styleSheets;
|
||||
var ssheet = null;
|
||||
for (var i=0;i<stylesheets.length; i++){
|
||||
if (stylesheets[i].title === "opraf-css"){
|
||||
ssheet = stylesheets[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! ssheet){
|
||||
return;
|
||||
}
|
||||
for (var i=0;i<ssheet.cssRules.length;i++){
|
||||
var rule = ssheet.cssRules[i];
|
||||
if (rule.selectorText === '[data-opravastatus="'+aclass+'"]'){
|
||||
if (rule.style.display === ""){
|
||||
rule.style.display = "none";
|
||||
} else {
|
||||
rule.style.display = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
place_comments();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
<script>
|
||||
const pdfstav_form = document.getElementById('PDFSTAV_FORM');
|
||||
const csrf_form = document.getElementById('CSRF_FORM');
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -42,3 +42,25 @@
|
|||
<hr>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
function zmenStavKorektury(event) {
|
||||
event.preventDefault();
|
||||
|
||||
oprava = event.target.parentElement.parentElement.parentElement.parentElement;
|
||||
|
||||
const data = new FormData(event.target);
|
||||
data.append("action", event.submitter.value);
|
||||
|
||||
fetch("{% url 'korektury_api_oprava_stav' %}", {method: "POST", body: data})
|
||||
.then(response => {
|
||||
if (!response.ok) {alert("Něco se nepovedlo:" + response.statusText);}
|
||||
else response.json().then(data => {oprava.dataset.opravastatus = data["status"]; oprava.previousElementSibling.dataset.opravastatus = data["status"]});
|
||||
})
|
||||
.catch(error => {alert("Něco se nepovedlo:" + error);});
|
||||
}
|
||||
|
||||
for (const form of document.querySelectorAll("[action='']")) form.addEventListener('submit', async event => { zmenStavKorektury(event); });
|
||||
</script>
|
||||
|
|
|
@ -61,7 +61,6 @@ class KorekturyView(generic.TemplateView):
|
|||
|
||||
def post(self, request, *args, **kwargs):
|
||||
q = request.POST
|
||||
scroll = q.get('scroll')
|
||||
|
||||
# prirazeni autora podle prihlaseni
|
||||
autor_user = request.user
|
||||
|
@ -70,9 +69,6 @@ class KorekturyView(generic.TemplateView):
|
|||
if not autor:
|
||||
return HttpResponseForbidden()
|
||||
|
||||
if not scroll:
|
||||
scroll = 0
|
||||
|
||||
action = q.get('action')
|
||||
if (action == ''): # Přidej
|
||||
x = int(q.get('x'))
|
||||
|
@ -119,7 +115,6 @@ class KorekturyView(generic.TemplateView):
|
|||
self.pdf.status = status
|
||||
self.pdf.save()
|
||||
context = self.get_context_data()
|
||||
context['scroll'] = scroll
|
||||
context['autor'] = autor
|
||||
return render(request, 'korektury/korekturovatko/htmlstrana.html', context)
|
||||
|
||||
|
|
Loading…
Reference in a new issue