mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-02-24 00:59:35 -06:00
Cleanup
This commit is contained in:
@@ -76,6 +76,16 @@ export class SavedViewsComponent
|
|||||||
this.reloadViews()
|
this.reloadViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private reloadViews(): void {
|
||||||
|
this.loading = true
|
||||||
|
this.savedViewService
|
||||||
|
.listAll(null, null, { full_perms: true })
|
||||||
|
.subscribe((r) => {
|
||||||
|
this.savedViews = r.results
|
||||||
|
this.initialize()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.settings.organizingSidebarSavedViews = false
|
this.settings.organizingSidebarSavedViews = false
|
||||||
super.ngOnDestroy()
|
super.ngOnDestroy()
|
||||||
@@ -134,9 +144,6 @@ export class SavedViewsComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public deleteSavedView(savedView: SavedView) {
|
public deleteSavedView(savedView: SavedView) {
|
||||||
if (!this.canDeleteSavedView(savedView)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.savedViewService.delete(savedView).subscribe(() => {
|
this.savedViewService.delete(savedView).subscribe(() => {
|
||||||
this.savedViewsGroup.removeControl(savedView.id.toString())
|
this.savedViewsGroup.removeControl(savedView.id.toString())
|
||||||
this.savedViews.splice(this.savedViews.indexOf(savedView), 1)
|
this.savedViews.splice(this.savedViews.indexOf(savedView), 1)
|
||||||
@@ -173,6 +180,9 @@ export class SavedViewsComponent
|
|||||||
if (value.show_in_sidebar) {
|
if (value.show_in_sidebar) {
|
||||||
sidebarVisibleIds.push(value.id)
|
sidebarVisibleIds.push(value.id)
|
||||||
}
|
}
|
||||||
|
// Would be fine to send, but no longer stored on the model
|
||||||
|
delete value.show_on_dashboard
|
||||||
|
delete value.show_in_sidebar
|
||||||
|
|
||||||
if (!group.get('name')?.enabled) {
|
if (!group.get('name')?.enabled) {
|
||||||
// Quick check for user doesn't have permissions, then bail
|
// Quick check for user doesn't have permissions, then bail
|
||||||
@@ -189,22 +199,19 @@ export class SavedViewsComponent
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
delete value.show_on_dashboard
|
|
||||||
delete value.show_in_sidebar
|
|
||||||
changed.push(value)
|
changed.push(value)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!changed.length && !visibilityChanged) {
|
if (!changed.length && !visibilityChanged) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// First save only changed views
|
|
||||||
let saveOperation = of([])
|
let saveOperation = of([])
|
||||||
if (changed.length) {
|
if (changed.length) {
|
||||||
saveOperation = saveOperation.pipe(
|
saveOperation = saveOperation.pipe(
|
||||||
switchMap(() => this.savedViewService.patchMany(changed))
|
switchMap(() => this.savedViewService.patchMany(changed))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Then save the visibility changes in the settings
|
|
||||||
if (visibilityChanged) {
|
if (visibilityChanged) {
|
||||||
saveOperation = saveOperation.pipe(
|
saveOperation = saveOperation.pipe(
|
||||||
switchMap(() =>
|
switchMap(() =>
|
||||||
@@ -240,9 +247,6 @@ export class SavedViewsComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public editPermissions(savedView: SavedView): void {
|
public editPermissions(savedView: SavedView): void {
|
||||||
if (!this.canDeleteSavedView(savedView)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const modal = this.modalService.open(PermissionsDialogComponent, {
|
const modal = this.modalService.open(PermissionsDialogComponent, {
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
})
|
})
|
||||||
@@ -271,14 +275,4 @@ export class SavedViewsComponent
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private reloadViews(): void {
|
|
||||||
this.loading = true
|
|
||||||
this.savedViewService
|
|
||||||
.list(1, 100000, null, null, { full_perms: true })
|
|
||||||
.subscribe((r) => {
|
|
||||||
this.savedViews = r.results
|
|
||||||
this.initialize()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user