WIP search
This commit is contained in:
parent
39b9515f76
commit
b20943cfd2
1 changed files with 26 additions and 2 deletions
|
|
@ -153,11 +153,31 @@ export class Application {
|
|||
for (const folder of folders)
|
||||
this.recordsTree.append(folder.render())
|
||||
|
||||
this.removeEmptyFolders()
|
||||
|
||||
// Subscribe to settings update since the elements they will change
|
||||
// exists now.
|
||||
_mbus.subscribe('settings_updated', event => this.handlerSettingsUpdated(event.detail))
|
||||
this.setBoxedFolders(this.settings.get('boxed_folders'))
|
||||
}// }}}
|
||||
removeEmptyFolders(folder) {// {{{
|
||||
if (folder === undefined)
|
||||
folder = this.topFolder
|
||||
|
||||
folder.subfolders.forEach((folder, _label) => {
|
||||
this.removeEmptyFolders(folder)
|
||||
})
|
||||
|
||||
// This is a leaf folder in the tree.
|
||||
// It has to be removed from the parent as well, since that could be up for
|
||||
// removal as well, all the way up the chain.
|
||||
if (folder.subfolders.size === 0 && folder.records.length === 0) {
|
||||
if (folder.parentFolder) {
|
||||
folder.parentFolder.subfolders.delete(folder.labels()[0])
|
||||
}
|
||||
|
||||
folder.div?.remove()
|
||||
}
|
||||
}// }}}
|
||||
handlerKeys(event) {// {{{
|
||||
let handled = true
|
||||
|
|
@ -175,6 +195,10 @@ export class Application {
|
|||
new RecordDialog(new Record()).show()
|
||||
break
|
||||
|
||||
case 'f':
|
||||
this.searchField.focus()
|
||||
break
|
||||
|
||||
default:
|
||||
handled = false
|
||||
}
|
||||
|
|
@ -195,13 +219,13 @@ export class Application {
|
|||
else
|
||||
document.body.classList.remove('boxed-folders')
|
||||
}// }}}
|
||||
search() {
|
||||
search() {// {{{
|
||||
this.searchFor = this.searchField.value.trim().toLowerCase()
|
||||
|
||||
this.cleanFolders()
|
||||
this.renderFolders()
|
||||
this.render()
|
||||
}
|
||||
}// }}}
|
||||
}
|
||||
|
||||
class Folder {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue