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,11 +80,11 @@ 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 resultCard = document.createElement('li');
const resultContents = document.createElement('a'); const resultContents = document.createElement('a');
@ -92,11 +92,18 @@ function _codigoparallevar_enable_search_box(selector, options) {
const resultTitle = document.createElement('h2'); const resultTitle = document.createElement('h2');
resultTitle.innerText = `${note.title} (${note.top_level_title})`; 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); resultContents.appendChild(resultTitle);
resultCard.appendChild(resultContents); resultCard.appendChild(resultContents);
resultsList.appendChild(resultCard); 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;
} }