saved search note now has refresh button, closes #369

This commit is contained in:
zadam 2019-03-30 00:12:32 +01:00
parent f479c0e10e
commit 7bbf797caf
6 changed files with 29 additions and 6 deletions

View File

@ -107,6 +107,8 @@ $("#logout-button").click(() => {
$("#tree").on("click", ".unhoist-button", hoistedNoteService.unhoist);
$("#tree").on("click", ".refresh-search-button", searchNotesService.refreshSearch);
$("body").on("click", "a.external", function () {
window.open($(this).attr("href"), '_blank');
});

View File

@ -1,6 +1,5 @@
import noteDetailService from "./note_detail.js";
import treeService from "./tree.js";
import infoService from './info.js';
import searchNotesService from "./search_notes.js";
const $searchString = $("#search-string");
const $component = $('#note-detail-search');
@ -31,9 +30,7 @@ function getContent() {
$refreshButton.click(async () => {
await noteDetailService.saveNoteIfChanged();
treeService.reload();
infoService.showMessage('Tree has been refreshed.');
await searchNotesService.refreshSearch();
});
export default {

View File

@ -96,6 +96,15 @@ async function saveSearch() {
resetSearch();
}
async function refreshSearch() {
const activeNode = treeService.getActiveNode();
activeNode.load(true);
activeNode.setExpanded(true);
infoService.showMessage("Saved search note refreshed.");
}
function init() {
const hashValue = treeService.getHashValueFromAddress();
@ -129,6 +138,7 @@ export default {
toggleSearch,
resetSearch,
showSearch,
refreshSearch,
doSearch,
init
};

View File

@ -453,6 +453,14 @@ function initFancyTree(tree) {
$span.append(unhoistButton);
}
const note = await treeCache.getNote(node.data.noteId);
if (note.type === 'search' && $span.find('.refresh-search-button').length === 0) {
const refreshSearchButton = $('<span>&nbsp; <span class="refresh-search-button jam jam-refresh" title="Refresh saved search results"></span></span>');
$span.append(refreshSearchButton);
}
},
// this is done to automatically lazy load all expanded search notes after tree load
loadChildren: function(event, data) {

View File

@ -133,4 +133,10 @@ li.dropdown-submenu:hover > ul.dropdown-menu {
.dropdown-menu > li > a:hover:after {
text-decoration: underline;
transform: rotate(-90deg);
}
.refresh-search-button {
cursor: pointer;
position: relative;
top: -1px;
}

View File

@ -5,7 +5,7 @@
<span>
&nbsp; &nbsp;
<button type="button" class="btn btn-primary" id="note-detail-search-refresh-results-button">Refresh tree</button>
<button type="button" class="btn btn-primary" id="note-detail-search-refresh-results-button">Refresh search results</button>
</span>
</div>