diff --git a/src-ui/src/app/data/ui-settings.ts b/src-ui/src/app/data/ui-settings.ts index c47c409d5..de3f1426c 100644 --- a/src-ui/src/app/data/ui-settings.ts +++ b/src-ui/src/app/data/ui-settings.ts @@ -62,6 +62,10 @@ export const SETTINGS_KEYS = { 'general-settings:update-checking:backend-setting', SAVED_VIEWS_WARN_ON_UNSAVED_CHANGE: 'general-settings:saved-views:warn-on-unsaved-change', + DASHBOARD_VIEWS_VISIBLE_IDS: + 'general-settings:saved-views:dashboard-views-visible-ids', + SIDEBAR_VIEWS_VISIBLE_IDS: + 'general-settings:saved-views:sidebar-views-visible-ids', DASHBOARD_VIEWS_SORT_ORDER: 'general-settings:saved-views:dashboard-views-sort-order', SIDEBAR_VIEWS_SORT_ORDER: @@ -248,6 +252,16 @@ export const SETTINGS: UiSetting[] = [ type: 'array', default: [], }, + { + key: SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS, + type: 'array', + default: null, + }, + { + key: SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS, + type: 'array', + default: null, + }, { key: SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER, type: 'array', diff --git a/src-ui/src/app/services/rest/saved-view.service.spec.ts b/src-ui/src/app/services/rest/saved-view.service.spec.ts index 585425ecc..03c70d1b2 100644 --- a/src-ui/src/app/services/rest/saved-view.service.spec.ts +++ b/src-ui/src/app/services/rest/saved-view.service.spec.ts @@ -102,6 +102,15 @@ describe(`Additional service tests for SavedViewService`, () => { ]) }) + it('should use user-specific dashboard visibility when configured', () => { + service['savedViews'] = saved_views + jest.spyOn(settingsService, 'get').mockImplementation((key) => { + if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS) return [4, 2] + if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER) return [] + }) + expect(service.dashboardViews).toEqual([saved_views[1], saved_views[3]]) + }) + it('should sort sidebar views', () => { service['savedViews'] = saved_views jest.spyOn(settingsService, 'get').mockImplementation((key) => { @@ -114,6 +123,15 @@ describe(`Additional service tests for SavedViewService`, () => { ]) }) + it('should use user-specific sidebar visibility when configured', () => { + service['savedViews'] = saved_views + jest.spyOn(settingsService, 'get').mockImplementation((key) => { + if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS) return [4, 2] + if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_SORT_ORDER) return [] + }) + expect(service.sidebarViews).toEqual([saved_views[1], saved_views[3]]) + }) + it('should treat empty display_fields as null', () => { subscription = service .patch({ diff --git a/src-ui/src/app/services/rest/saved-view.service.ts b/src-ui/src/app/services/rest/saved-view.service.ts index 7bdb890a0..ba7205e95 100644 --- a/src-ui/src/app/services/rest/saved-view.service.ts +++ b/src-ui/src/app/services/rest/saved-view.service.ts @@ -65,8 +65,27 @@ export class SavedViewService extends AbstractPaperlessService { return this.savedViews } + private getVisibleViewIds(setting: string): number[] | null { + const configured = this.settingsService.get(setting) + return Array.isArray(configured) ? configured : null + } + + private isDashboardVisible(view: SavedView): boolean { + const visibleIds = this.getVisibleViewIds( + SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS + ) + return visibleIds ? visibleIds.includes(view.id) : !!view.show_on_dashboard + } + + private isSidebarVisible(view: SavedView): boolean { + const visibleIds = this.getVisibleViewIds( + SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS + ) + return visibleIds ? visibleIds.includes(view.id) : !!view.show_in_sidebar + } + get sidebarViews(): SavedView[] { - const sidebarViews = this.savedViews.filter((v) => v.show_in_sidebar) + const sidebarViews = this.savedViews.filter((v) => this.isSidebarVisible(v)) const sorted: number[] = this.settingsService.get( SETTINGS_KEYS.SIDEBAR_VIEWS_SORT_ORDER @@ -81,7 +100,9 @@ export class SavedViewService extends AbstractPaperlessService { } get dashboardViews(): SavedView[] { - const dashboardViews = this.savedViews.filter((v) => v.show_on_dashboard) + const dashboardViews = this.savedViews.filter((v) => + this.isDashboardVisible(v) + ) const sorted: number[] = this.settingsService.get( SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER