Show notes TO-DO on search, mark them as such.

This commit is contained in:
Sergio Martínez Portela 2022-10-30 23:58:44 +01:00
parent b676e2f949
commit 208a9b2e97
2 changed files with 27 additions and 15 deletions

View File

@ -80,22 +80,29 @@ function _codigoparallevar_enable_search_box(selector, options) {
} }
resultsList.innerHTML = ''; resultsList.innerHTML = '';
for (const note of body.results.notes) { for (const list of [
if (note.is_todo === "1") { body.results.notes.filter(n => n.is_todo !== "1"),
continue; body.results.notes.filter(n => n.is_todo === "1"),
]){
for (const note of list) {
const resultCard = document.createElement('li');
const resultContents = document.createElement('a');
resultContents.setAttribute('href', './' + note.id + '.node.html');
const resultTitle = document.createElement('h2');
resultTitle.innerText = `${note.title} (${note.top_level_title})`;
if (note.is_todo === "1") {
resultTitle.setAttribute('class', 'is-todo');
}
else if (note.is_done === "1") {
resultTitle.setAttribute('class', 'is-done');
}
resultContents.appendChild(resultTitle);
resultCard.appendChild(resultContents);
resultsList.appendChild(resultCard);
} }
const resultCard = document.createElement('li');
const resultContents = document.createElement('a');
resultContents.setAttribute('href', './' + note.id + '.node.html');
const resultTitle = document.createElement('h2');
resultTitle.innerText = `${note.title} (${note.top_level_title})`;
resultContents.appendChild(resultTitle);
resultCard.appendChild(resultContents);
resultsList.appendChild(resultCard);
} }
if (body.results.notes.length == 0) { if (body.results.notes.length == 0) {
noResultsBox.classList.remove('hidden'); noResultsBox.classList.remove('hidden');

View File

@ -87,6 +87,11 @@ body nav input {
margin: 0; margin: 0;
} }
.results-box li h2.is-todo::before {
content: ' [TODO] ';
color: #D00;
}
.no-results-box { .no-results-box {
padding: 1rem; padding: 1rem;
} }