show answered question history on dashboard
This commit is contained in:
parent
411cf86632
commit
6ba4241a45
4 changed files with 67 additions and 3 deletions
|
|
@ -488,11 +488,10 @@
|
|||
function renderQuestions(s) {
|
||||
const root = $('questions-section');
|
||||
root.innerHTML = '';
|
||||
const fmt = (n) => new Date(n * 1000).toISOString().replace('T', ' ').slice(0, 19);
|
||||
if (!s.questions || !s.questions.length) {
|
||||
root.append(el('p', { class: 'empty' }, 'no pending questions'));
|
||||
return;
|
||||
}
|
||||
const fmt = (n) => new Date(n * 1000).toISOString().replace('T', ' ').slice(0, 19);
|
||||
const ul = el('ul', { class: 'questions' });
|
||||
for (const q of s.questions) {
|
||||
const li = el('li', { class: 'question' });
|
||||
|
|
@ -576,7 +575,34 @@
|
|||
li.append(cancelForm);
|
||||
ul.append(li);
|
||||
}
|
||||
root.append(ul);
|
||||
if (s.questions && s.questions.length) root.append(ul);
|
||||
|
||||
// Answered question history
|
||||
const hist = s.question_history || [];
|
||||
if (hist.length) {
|
||||
const details = el('details', { class: 'q-history', 'data-restore-key': 'q-history' });
|
||||
details.append(el('summary', {}, '◆ answ3red (' + hist.length + ')'));
|
||||
const hul = el('ul', { class: 'questions questions-answered' });
|
||||
for (const q of hist) {
|
||||
const li = el('li', { class: 'question question-answered' });
|
||||
const head = el('div', { class: 'q-head' },
|
||||
el('span', { class: 'msg-ts' }, fmt(q.answered_at)), ' ',
|
||||
el('span', { class: 'msg-from' }, q.asker), ' ',
|
||||
el('span', { class: 'msg-sep' }, 'asked:'),
|
||||
);
|
||||
li.append(
|
||||
head,
|
||||
el('div', { class: 'q-body' }, q.question),
|
||||
el('div', { class: 'q-answer' },
|
||||
el('span', { class: 'msg-sep' }, 'answer: '),
|
||||
el('span', { class: 'q-answer-text' }, q.answer || '(none)'),
|
||||
),
|
||||
);
|
||||
hul.append(li);
|
||||
}
|
||||
details.append(hul);
|
||||
root.append(details);
|
||||
}
|
||||
}
|
||||
|
||||
function renderInbox(s) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue