From 22446b65e01ad14e3ba211baf125832ea8319e65 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 15 2016 10:28:14 +0000 Subject: [PATCH 1/5] Set the assignee name when updating the page via SSE --- diff --git a/pagure/static/issue_ev.js b/pagure/static/issue_ev.js index 52fcefe..ea5f263 100644 --- a/pagure/static/issue_ev.js +++ b/pagure/static/issue_ev.js @@ -49,6 +49,7 @@ assigne_issue = function(data, _issues_url) { selectize.settings.create = true; selectize.createItem(data.assigned.name); selectize.settings.create = false; + $('#assignee').val(data.assigned.name); var field = $('#assignee_plain'); var _url = '\n + {% endif %} diff --git a/pagure/templates/_render_repo.html b/pagure/templates/_render_repo.html index b2f0a10..a88c080 100644 --- a/pagure/templates/_render_repo.html +++ b/pagure/templates/_render_repo.html @@ -132,18 +132,18 @@ {% endif %}
- {% for repo in list %} - -
{{ repo.name }}
-
- {% else %} -

No projects found

- {% endfor %} + {% for repo in list %} + +
{{ repo.name }}
+
+ {% else %} +

No projects found

+ {% endfor %}
{% if total and total > 1 %} From 8cf3512bd1972ba57c7b32e8b9d19a647529f21a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 15 2016 10:28:14 +0000 Subject: [PATCH 3/5] Make the issue page be a single, large form again This allows changing multiple fields at one and fix updating the page via SSE for multiple actions following each other (for example assigning the ticket then making a comment). --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 93a7a63..d9dd2e7 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -175,32 +175,26 @@
-
-
- - - - {% if repo_admin or ( - g.fas_user and g.fas_user.username == comment.user.username) %} - - - {% endif %} - {% if repo_admin %} - - {{ form.csrf_token }} - {% endif %} -
-
+
+ + + + {% if repo_admin or ( + g.fas_user and g.fas_user.username == comment.user.username) %} + + + {% endif %} + {% if repo_admin %} + + {% endif %} +
{% endmacro %} diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index e35b11a..bddac95 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -15,8 +15,12 @@ {% block repo %}
-
+
+ {{ form.csrf_token }} +

#{{ issueid }} {{issue.title | noJS("img") | safe }} @@ -32,10 +36,6 @@ {{ show_initial_comment(issue, username, repo,issueid, repo_admin, form) }} - - {{ form.csrf_token }}
{% if issue.comments %} {% for comment in issue.comments %} @@ -43,7 +43,6 @@ {% endfor %} {% endif %}
-
@@ -51,12 +50,6 @@
{% if authenticated and form %} -
- {{ form.csrf_token }} -
@@ -72,7 +65,8 @@
Select files OR drag them into the comment field below. - + Markdown Syntax - - - - -
- - -
- +
+ + +
{% else %}

Login @@ -101,18 +90,11 @@

-

+
- {% if authenticated and form %} -
- {{ form.csrf_token }} - {% endif %}
+ +
{% endblock %} @@ -326,6 +323,27 @@ $(document).ready(function() { return false; }; + {% if repo_admin %} + $('#closeticket').click(function(event){ + event.preventDefault(); + var closeForm = jQuery('
', { + 'method': 'POST', + 'action': '{{ + url_for('.delete_issue', + username=username, repo=repo.name, issueid=issueid) }}', + }).append(jQuery('', { + 'name': 'csrf_token', + 'value': '{{ form.csrf_token.current_token }}', + 'type': 'hidden' + })).appendTo('body'); + console.log(closeForm); + if (confirm('Are you sure to delete this ticket? \nThis is final and cannot be un-done.')){ + console.log(closeForm.submit()); + } + return false; + }); + {% endif %} + $(window.onload=highlight_comment()); $(window).on('hashchange', highlight_comment); cancel_edit_btn(); @@ -375,7 +393,8 @@ source.addEventListener('message', function(e) { {% if authenticated and form %} function try_async_comment(form) { - $(form).find('input[type="submit"]').attr("disabled", "disabled"); + console.log(form) + $('body').find('input[type="submit"]').attr("disabled", "disabled"); var _data = $(form).serialize(); var btn = $(document.activeElement); if (btn[0].name == 'drop_comment'){ @@ -408,7 +427,7 @@ function try_async_comment(form) { $(form).off('submit'); form.submit(); }) - $(form).find('input[type="submit"]').removeAttr("disabled"); + $('body').find('input[type="submit"]').removeAttr("disabled"); return false; }; {% endif %} From 31015dbcea85dcf38e92291ca9bdc8cf61728976 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 15 2016 11:20:47 +0000 Subject: [PATCH 4/5] Remove debugging code and replace jQuery. by $. --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index bddac95..5e6d828 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -297,7 +297,7 @@ function setup_reply_btns() { var _text = _comment.text().split("\n"); var _output = new Array(); for (cnt = 0; cnt < _text.length ; cnt ++) { - _output[cnt] = '> ' + jQuery.trim(_text[cnt]); + _output[cnt] = '> ' + $.trim(_text[cnt]); } $( "#comment" ).val(_output.join("\n")); } @@ -326,19 +326,18 @@ $(document).ready(function() { {% if repo_admin %} $('#closeticket').click(function(event){ event.preventDefault(); - var closeForm = jQuery('', { + var closeForm = $('', { 'method': 'POST', 'action': '{{ url_for('.delete_issue', username=username, repo=repo.name, issueid=issueid) }}', - }).append(jQuery('', { + }).append($('', { 'name': 'csrf_token', 'value': '{{ form.csrf_token.current_token }}', 'type': 'hidden' })).appendTo('body'); - console.log(closeForm); if (confirm('Are you sure to delete this ticket? \nThis is final and cannot be un-done.')){ - console.log(closeForm.submit()); + closeForm.submit(); } return false; }); From d0d6bc920e2bddf6f485ae65cfabdb693b76fa2a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 15 2016 13:12:29 +0000 Subject: [PATCH 5/5] Disable and re-enable the submit buttons in the form --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 5e6d828..b2a2a2e 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -393,7 +393,7 @@ source.addEventListener('message', function(e) { {% if authenticated and form %} function try_async_comment(form) { console.log(form) - $('body').find('input[type="submit"]').attr("disabled", "disabled"); + $(form).find('input[type="submit"]').attr("disabled", "disabled"); var _data = $(form).serialize(); var btn = $(document.activeElement); if (btn[0].name == 'drop_comment'){ @@ -426,7 +426,7 @@ function try_async_comment(form) { $(form).off('submit'); form.submit(); }) - $('body').find('input[type="submit"]').removeAttr("disabled"); + $(form).find('input[type="submit"]').removeAttr("disabled"); return false; }; {% endif %}