Jun 24 - Implement function to view history broadcast messages - fix issue
This commit is contained in:
@@ -109,16 +109,13 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for b in history %}
|
||||
<tr style="cursor:pointer;"
|
||||
onclick="showBroadcast(
|
||||
{{ b.id }},
|
||||
{{ b.title | tojson }},
|
||||
{{ b.body | tojson }},
|
||||
{{ b.sent_at.strftime('%b %-d, %Y %I:%M %p') | tojson }},
|
||||
{{ (b.sent_by.display_name if b.sent_by else '—') | tojson }},
|
||||
{{ b.recipient_count }},
|
||||
{{ b.target_roles | tojson }}
|
||||
)">
|
||||
<tr class="broadcast-row" style="cursor:pointer;"
|
||||
data-title="{{ b.title | e }}"
|
||||
data-body="{{ b.body | e }}"
|
||||
data-sent-at="{{ b.sent_at.strftime('%b %-d, %Y %I:%M %p') }}"
|
||||
data-sent-by="{{ (b.sent_by.display_name if b.sent_by else '—') | e }}"
|
||||
data-recipients="{{ b.recipient_count }}"
|
||||
data-roles="{{ b.target_roles | tojson | e }}">
|
||||
<td class="text-nowrap text-muted small">
|
||||
{{ b.sent_at.strftime('%b %-d, %Y') }}<br>
|
||||
<span class="text-muted" style="font-size:.75rem;">
|
||||
@@ -195,17 +192,20 @@
|
||||
<script>
|
||||
var ROLE_LABELS = {{ role_labels | tojson }};
|
||||
|
||||
function showBroadcast(id, title, body, sentAt, sentBy, recipientCount, roles) {
|
||||
document.getElementById('bdTitle').textContent = title;
|
||||
document.getElementById('bdBody').textContent = body;
|
||||
document.getElementById('bdSentAt').textContent = sentAt;
|
||||
document.getElementById('bdSentBy').textContent = sentBy;
|
||||
document.getElementById('bdRecipients').textContent = recipientCount + ' user(s)';
|
||||
document.getElementById('bdRoles').textContent = roles.map(function(r) {
|
||||
return ROLE_LABELS[r] || r;
|
||||
}).join(', ');
|
||||
new bootstrap.Modal(document.getElementById('broadcastDetailModal')).show();
|
||||
}
|
||||
document.querySelectorAll('.broadcast-row').forEach(function(row) {
|
||||
row.addEventListener('click', function() {
|
||||
var roles = JSON.parse(this.dataset.roles);
|
||||
document.getElementById('bdTitle').textContent = this.dataset.title;
|
||||
document.getElementById('bdBody').textContent = this.dataset.body;
|
||||
document.getElementById('bdSentAt').textContent = this.dataset.sentAt;
|
||||
document.getElementById('bdSentBy').textContent = this.dataset.sentBy;
|
||||
document.getElementById('bdRecipients').textContent = this.dataset.recipients + ' user(s)';
|
||||
document.getElementById('bdRoles').textContent = roles.map(function(r) {
|
||||
return ROLE_LABELS[r] || r;
|
||||
}).join(', ');
|
||||
new bootstrap.Modal(document.getElementById('broadcastDetailModal')).show();
|
||||
});
|
||||
});
|
||||
|
||||
(function () {
|
||||
var textarea = document.getElementById('body');
|
||||
|
||||
Reference in New Issue
Block a user