04/07 updated timezone, report via email, etc
This commit is contained in:
@@ -83,18 +83,65 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-3">
|
||||
<div class="card-body d-flex align-items-center justify-content-between">
|
||||
<span style="font-size:13px;color:var(--muted);">Did this article solve your issue?</span>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{{ url_for('tickets.knowledge_base') }}" class="btn btn-secondary btn-sm">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back
|
||||
</a>
|
||||
<a href="{{ url_for('tickets.create_ticket') }}" class="btn btn-primary btn-sm">
|
||||
<i class="bi bi-ticket me-1"></i>Still need help
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center justify-content-between flex-wrap gap-3">
|
||||
<!-- Feedback widget -->
|
||||
<div style="font-size:13px;">
|
||||
<span style="color:var(--muted);margin-right:10px;">Was this article helpful?</span>
|
||||
<button type="button" id="fb-yes"
|
||||
onclick="submitFeedback(1)"
|
||||
class="btn btn-sm {% if user_feedback and user_feedback.is_helpful %}btn-success{% else %}btn-outline-secondary{% endif %}"
|
||||
style="margin-right:6px;">
|
||||
<i class="bi bi-hand-thumbs-up me-1"></i>
|
||||
Yes <span id="fb-yes-count">({{ helpful_count }})</span>
|
||||
</button>
|
||||
<button type="button" id="fb-no"
|
||||
onclick="submitFeedback(0)"
|
||||
class="btn btn-sm {% if user_feedback and not user_feedback.is_helpful %}btn-danger{% else %}btn-outline-secondary{% endif %}">
|
||||
<i class="bi bi-hand-thumbs-down me-1"></i>
|
||||
No <span id="fb-no-count">({{ not_helpful_count }})</span>
|
||||
</button>
|
||||
<span id="fb-msg" style="font-size:12px;color:var(--muted);margin-left:10px;"></span>
|
||||
</div>
|
||||
<!-- Navigation -->
|
||||
<div class="d-flex gap-2">
|
||||
<a href="{{ url_for('tickets.knowledge_base') }}" class="btn btn-secondary btn-sm">
|
||||
<i class="bi bi-arrow-left me-1"></i>Back
|
||||
</a>
|
||||
<a href="{{ url_for('tickets.create_ticket') }}" class="btn btn-primary btn-sm">
|
||||
<i class="bi bi-ticket me-1"></i>Still need help
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const FEEDBACK_URL = '{{ url_for("tickets.kb_feedback", article_id=article.id) }}';
|
||||
const CSRF_TOKEN = document.querySelector('meta[name=csrf-token]').content;
|
||||
|
||||
async function submitFeedback(helpful) {
|
||||
const fd = new FormData();
|
||||
fd.append('helpful', helpful);
|
||||
fd.append('csrf_token', CSRF_TOKEN);
|
||||
try {
|
||||
const r = await fetch(FEEDBACK_URL, { method: 'POST', credentials: 'same-origin', body: fd });
|
||||
const data = await r.json();
|
||||
if (!data.ok) return;
|
||||
document.getElementById('fb-yes-count').textContent = `(${data.helpful_count})`;
|
||||
document.getElementById('fb-no-count').textContent = `(${data.not_helpful_count})`;
|
||||
const btnYes = document.getElementById('fb-yes');
|
||||
const btnNo = document.getElementById('fb-no');
|
||||
const msg = document.getElementById('fb-msg');
|
||||
btnYes.className = 'btn btn-sm ' + (data.user_vote === 'helpful' ? 'btn-success' : 'btn-outline-secondary');
|
||||
btnNo.className = 'btn btn-sm ' + (data.user_vote === 'not_helpful' ? 'btn-danger' : 'btn-outline-secondary');
|
||||
msg.textContent = data.user_vote ? 'Thanks for your feedback!' : 'Vote removed.';
|
||||
setTimeout(() => msg.textContent = '', 3000);
|
||||
} catch {
|
||||
// silent fail
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user