:root {
+ --light-color:rgb(247, 247, 247);
--success-color:rgb(92, 184, 92);
--warning-color:rgb(240, 173, 78);
--danger-color:rgb(217, 83, 79);
top: 17em;
}
+.hidden {
+ visibility: hidden;
+}
+
/* Bootstrap overrides */
.navbar-inverse .navbar-brand > a {
font-family: "DejaVu Sans Mono", fixed;
}
+div[class^="comment-status-bar-"] {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+}
+
+.comment-status-label {
+ margin: 0px 8px;
+}
+
+button[class^=comment-action] {
+ background-color: var(--light-color);
+ border-radius: 4px;
+}
+
+.comment-action-addressed {
+ border-color: var(--success-color);
+}
+
+.comment-action-unaddressed {
+ border-color: var(--warning-color);
+}
+
+.comment-action-addressed:hover {
+ background-color: var(--success-color);
+ color: var(--light-color);
+}
+
+.comment-action-unaddressed:hover {
+ background-color: var(--warning-color);
+ color: var(--light-color);
+}
+
.quote {
color: #007f00;
}
+import { updateProperty } from "./rest.js";
+
$( document ).ready(function() {
+ const patchMeta = document.getElementById("patch-meta");
function toggleDiv(link_id, headers_id, label_show, label_hide) {
const link = document.getElementById(link_id)
const headers = document.getElementById(headers_id)
}
}
+ $("button[class^='comment-action']").click((event) => {
+ const submissionType = patchMeta.dataset.submissionType;
+ const submissionId = patchMeta.dataset.submissionId;
+ const commentId = event.target.parentElement.dataset.commentId;
+ const url = `/api/${submissionType}/${submissionId}/comments/${commentId}/`;
+ const data = {'addressed': event.target.value} ;
+ const updateMessage = {
+ 'error': "No comments updated",
+ 'success': "1 comment(s) updated",
+ };
+ updateProperty(url, data, updateMessage).then(isSuccess => {
+ if (isSuccess) {
+ $("div[class^='comment-status-bar-'][data-comment-id='"+commentId+"']").toggleClass("hidden");
+ }
+ })
+ });
+
// Click listener to show/hide headers
document.getElementById("toggle-patch-headers").addEventListener("click", function() {
toggleDiv("toggle-patch-headers", "patch-headers");
{% load person %}
{% load patch %}
{% load static %}
+{% load utils %}
{% block headers %}
<script type="module" src="{% static "js/submission.js" %}"></script>
<h1>{{ submission.name }}</h1>
</div>
-<table class="patch-meta">
+<table
+ id="patch-meta"
+ class="patch-meta"
+ data-submission-type={{submission|verbose_name_plural|lower}}
+ data-submission-id={{submission.id}}
+>
<tr>
<th>Message ID</th>
{% if submission.list_archive_url %}
{% if forloop.first %}
<h2>Comments</h2>
{% endif %}
-
+{% is_editable item user as comment_is_editable %}
<a name="{{ item.id }}"></a>
<div class="submission-message">
-<div class="meta">
- <span>{{ item.submitter|personify:project }}</span>
- <span class="message-date">{{ item.date }} UTC |
- <a href="{% url 'comment-redirect' comment_id=item.id %}">#{{ forloop.counter }}</a>
- </span>
-</div>
-<pre class="content">
-{{ item|commentsyntax }}
-</pre>
+ <div class="meta">
+ {{ item.submitter|personify:project }}
+ <span class="message-date">{{ item.date }} UTC |
+ <a href="{% url 'comment-redirect' comment_id=item.id %}">#{{ forloop.counter }}</a>
+ </span>
+ {% if item.addressed %}
+ <div class="comment-status-bar-addressed" data-comment-id={{item.id}}>
+ {% else %}
+ <div class="comment-status-bar-addressed hidden" data-comment-id={{item.id}}>
+ {% endif %}
+ <div class="comment-status-label text-success mx-3">
+ <span class="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>
+ Addressed
+ </div>
+ {% if editable or comment_is_editable %}
+ <button class="comment-action-unaddressed text-warning" value="false">
+ <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
+ Mark Unaddressed
+ </button>
+ {% endif %}
+ </div>
+ {% if item.addressed %}
+ <div class="comment-status-bar-unaddressed hidden" data-comment-id={{item.id}}>
+ {% else %}
+ <div class="comment-status-bar-unaddressed" data-comment-id={{item.id}}>
+ {% endif %}
+ <div class="comment-status-label text-warning mx-3">
+ <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
+ Unaddressed
+ </div>
+ {% if editable or comment_is_editable %}
+ <button class="comment-action-addressed text-success" value="true">
+ <span class="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>
+ Mark Addressed
+ </button>
+ {% endif %}
+ </div>
+ </div>
+ <pre class="content">
+ {{ item|commentsyntax }}
+ </pre>
</div>
{% endfor %}
comments = patch.comments.all()
comments = comments.select_related('submitter')
- comments = comments.only('submitter', 'date', 'id', 'content', 'patch')
+ comments = comments.only('submitter', 'date', 'id', 'content', 'patch',
+ 'addressed')
if patch.related:
related_same_project = patch.related.patches.only(
patch.check_set.all().select_related('user'),
)
context['submission'] = patch
+ context['editable'] = editable
context['patchform'] = form
context['createbundleform'] = createbundleform
context['project'] = patch.project