Allow closing individual documents from sidebar

This commit is contained in:
Michael Shamoon 2021-02-25 07:43:02 -08:00
parent 66f7ae3773
commit 548b1ea7ec
4 changed files with 51 additions and 7 deletions

View File

@ -92,9 +92,14 @@
<svg class="sidebaricon" fill="currentColor"> <svg class="sidebaricon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#file-text"/> <use xlink:href="assets/bootstrap-icons.svg#file-text"/>
</svg>&nbsp;{{d.title | documentTitle}} </svg>&nbsp;{{d.title | documentTitle}}
<span class="close bg-light" (click)="closeDocument(d); $event.preventDefault()">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-x" viewBox="0 0 16 16">
<use xlink:href="assets/bootstrap-icons.svg#x"/>
</svg>
</span>
</a> </a>
</li> </li>
<li class="nav-item w-100" *ngIf="openDocuments.length >= 1"> <li class="nav-item w-100" *ngIf="openDocuments.length > 1">
<a class="nav-link text-truncate" [routerLink]="" (click)="closeAll()"> <a class="nav-link text-truncate" [routerLink]="" (click)="closeAll()">
<svg class="sidebaricon" fill="currentColor"> <svg class="sidebaricon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#x"/> <use xlink:href="assets/bootstrap-icons.svg#x"/>

View File

@ -62,6 +62,25 @@
flex-wrap: nowrap; flex-wrap: nowrap;
} }
.nav-item {
position: relative;
&:hover .close {
display: block;
}
.close {
display: none;
position: absolute;
cursor: pointer;
opacity: 1;
top: 0;
padding: .25rem .3rem 0;
right: .4rem;
width: 1.8rem;
height: 100%;
}
.nav-item .nav-link-additional { .nav-item .nav-link-additional {
margin-top: 0.2rem; margin-top: 0.2rem;
margin-left: 0.25rem; margin-left: 0.25rem;
@ -71,6 +90,8 @@
margin-bottom: 2px; margin-bottom: 2px;
} }
} }
}
/* /*
* Navbar * Navbar

View File

@ -77,6 +77,20 @@ export class AppFrameComponent implements OnInit {
this.router.navigate(['search'], {queryParams: {query: this.searchField.value}}) this.router.navigate(['search'], {queryParams: {query: this.searchField.value}})
} }
closeDocument(d: PaperlessDocument) {
this.closeMenu()
this.openDocumentsService.closeDocument(d)
// TODO: is there a better way to do this? (taken from closeAll)
let route = this.activatedRoute
while (route.firstChild) {
route = route.firstChild
}
if (route.component == DocumentDetailComponent) {
this.router.navigate([""])
}
}
closeAll() { closeAll() {
this.closeMenu() this.closeMenu()
this.openDocumentsService.closeAll() this.openDocumentsService.closeAll()

View File

@ -63,6 +63,10 @@ $border-color-dark-mode: #47494f;
background-color: $bg-dark-mode; background-color: $bg-dark-mode;
color: $text-color-dark-mode; color: $text-color-dark-mode;
border-color: $border-color-dark-mode $border-color-dark-mode $bg-dark-mode; border-color: $border-color-dark-mode $border-color-dark-mode $bg-dark-mode;
.close {
background-color: inherit !important;
}
} }
&:hover { &:hover {