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) {
|
||||
|
|
|
|||
|
|
@ -517,6 +517,24 @@ summary:hover { color: var(--purple); }
|
|||
.qform .q-free input:focus { outline: 1px solid var(--amber); }
|
||||
.qform button { align-self: flex-start; }
|
||||
.qform-cancel { margin-top: 0.3em; }
|
||||
.q-history {
|
||||
margin-top: 0.8em;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
padding: 0.4em 0.7em;
|
||||
}
|
||||
.q-history summary { cursor: pointer; color: var(--muted); font-size: 0.9em; user-select: none; }
|
||||
.questions-answered {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
animation: none;
|
||||
padding: 0;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
.question-answered { opacity: 0.7; }
|
||||
.question-answered .q-body { color: var(--muted); margin-bottom: 0.15em; }
|
||||
.q-answer { font-size: 0.9em; color: var(--green, #a6e3a1); padding: 0.1em 0 0.4em 0; }
|
||||
.q-answer-text { font-style: italic; }
|
||||
.inbox {
|
||||
background: var(--bg-elev);
|
||||
border: 1px solid var(--border);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue