Relocate sidebar filter setting to Library/Shelf header
This commit is contained in:
committed by
Aditya Chandel
parent
25e59323f3
commit
2fe7b0b5e3
@@ -51,7 +51,7 @@
|
||||
<i class="pi pi-cog"></i>
|
||||
</a>
|
||||
<p-popover #seriesCollapseOverlay [dismissable]="true" appendTo="body">
|
||||
<div class="w-[220px] p-3 space-y-4 text-sm">
|
||||
<div class="w-[220px] p-2 space-y-4 text-sm">
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="collapse-series-checkbox" class="font-medium">Collapse series</label>
|
||||
<p-checkbox
|
||||
@@ -64,7 +64,7 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="font-medium text-sm">Grid item size</label>
|
||||
<p-slider
|
||||
[(ngModel)]="coverScaleManager.scaleFactor"
|
||||
[(ngModel)]="coverScalePreferenceService.scaleFactor"
|
||||
[min]="0.5"
|
||||
[max]="1.5"
|
||||
[step]="0.01"
|
||||
@@ -72,7 +72,18 @@
|
||||
(onChange)="updateScale()">
|
||||
</p-slider>
|
||||
<div class="text-center">
|
||||
{{ coverScaleManager.scaleFactor.toFixed(2) }}x
|
||||
{{ coverScalePreferenceService.scaleFactor.toFixed(2) }}x
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="font-medium text-sm">Sidbar Filter Sort:</label>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="filterSortPreferenceService.filterSortingOptions"
|
||||
[(ngModel)]="filterSortPreferenceService.selectedFilterSorting"
|
||||
placeholder="Select Sorting">
|
||||
</p-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,13 +32,15 @@ import {OverlayPanelModule} from 'primeng/overlaypanel';
|
||||
import {SeriesCollapseFilter} from './filters/SeriesCollapseFilter';
|
||||
import {SideBarFilter} from './filters/SidebarFilter';
|
||||
import {HeaderFilter} from './filters/HeaderFilter';
|
||||
import {CoverScaleManager} from './CoverScaleManager';
|
||||
import {CoverScalePreferenceService} from './cover-scale-preference.service';
|
||||
import {BookSorter} from './sorting/BookSorter';
|
||||
import {BookDialogHelperService} from './BookDialogHelperService';
|
||||
import {DropdownModule} from 'primeng/dropdown';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Popover} from 'primeng/popover';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {Select} from 'primeng/select';
|
||||
import {FilterSortPreferenceService} from './filters/filter-sorting-preferences.service';
|
||||
|
||||
export enum EntityType {
|
||||
LIBRARY = 'Library',
|
||||
@@ -71,7 +73,7 @@ const SORT_DIRECTION = {
|
||||
standalone: true,
|
||||
templateUrl: './book-browser.component.html',
|
||||
styleUrls: ['./book-browser.component.scss'],
|
||||
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider],
|
||||
imports: [Button, VirtualScrollerModule, BookCardComponent, AsyncPipe, ProgressSpinner, Menu, InputText, FormsModule, BookTableComponent, BookFilterComponent, Tooltip, NgClass, Fluid, PrimeTemplate, NgStyle, OverlayPanelModule, DropdownModule, Checkbox, Popover, Slider, Select],
|
||||
providers: [SeriesCollapseFilter],
|
||||
animations: [
|
||||
trigger('slideInOut', [
|
||||
@@ -118,7 +120,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
entityViewPreferences!: EntityViewPreferences;
|
||||
|
||||
protected userService = inject(UserService);
|
||||
protected coverScaleManager = inject(CoverScaleManager);
|
||||
protected coverScalePreferenceService = inject(CoverScalePreferenceService);
|
||||
protected filterSortPreferenceService = inject(FilterSortPreferenceService);
|
||||
|
||||
private activatedRoute = inject(ActivatedRoute);
|
||||
private messageService = inject(MessageService);
|
||||
@@ -142,19 +145,19 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
private settingFiltersFromUrl = false;
|
||||
|
||||
get currentCardSize() {
|
||||
return this.coverScaleManager.currentCardSize;
|
||||
return this.coverScalePreferenceService.currentCardSize;
|
||||
}
|
||||
|
||||
get gridColumnMinWidth(): string {
|
||||
return this.coverScaleManager.gridColumnMinWidth;
|
||||
return this.coverScalePreferenceService.gridColumnMinWidth;
|
||||
}
|
||||
|
||||
updateScale(): void {
|
||||
this.coverScaleManager.setScale(this.coverScaleManager.scaleFactor);
|
||||
this.coverScalePreferenceService.setScale(this.coverScalePreferenceService.scaleFactor);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.coverScaleManager.scaleChange$.pipe(debounceTime(1000)).subscribe();
|
||||
this.coverScalePreferenceService.scaleChange$.pipe(debounceTime(1000)).subscribe();
|
||||
|
||||
this.bookService.loadBooks();
|
||||
|
||||
@@ -239,11 +242,11 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
this.currentFilterLabel = 'All Books';
|
||||
}
|
||||
|
||||
|
||||
this.entityViewPreferences = user.userSettings?.entityViewPreferences;
|
||||
const globalPrefs = this.entityViewPreferences?.global;
|
||||
const currentEntityTypeStr = this.entityType ? this.entityType.toString().toUpperCase() : undefined;
|
||||
this.coverScaleManager.scaleFactor = user.userSettings.entityViewPreferences?.global?.coverSize ?? 1.0;
|
||||
this.coverScalePreferenceService.initScaleValue(user?.userSettings?.entityViewPreferences?.global?.coverSize);
|
||||
this.filterSortPreferenceService.initValue(user?.userSettings?.filterSortingMode);
|
||||
|
||||
const override = this.entityViewPreferences?.overrides?.find(o =>
|
||||
o.entityType?.toUpperCase() === currentEntityTypeStr &&
|
||||
|
||||
+36
-29
@@ -1,6 +1,6 @@
|
||||
import {Component, EventEmitter, inject, Input, OnInit, Output} from '@angular/core';
|
||||
import {combineLatest, Observable, of, Subject} from 'rxjs';
|
||||
import {filter, map, take} from 'rxjs/operators';
|
||||
import {Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output} from '@angular/core';
|
||||
import {BehaviorSubject, combineLatest, Observable, of, Subject, takeUntil} from 'rxjs';
|
||||
import {distinctUntilChanged, filter, map, take} from 'rxjs/operators';
|
||||
import {BookService} from '../../../service/book.service';
|
||||
import {Library} from '../../../model/library.model';
|
||||
import {Shelf} from '../../../model/shelf.model';
|
||||
@@ -12,6 +12,7 @@ import {Badge} from 'primeng/badge';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {SelectButton} from 'primeng/selectbutton';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {FilterSortPreferenceService} from '../filters/filter-sorting-preferences.service';
|
||||
|
||||
type Filter<T> = { value: T; bookCount: number };
|
||||
|
||||
@@ -114,7 +115,7 @@ export function getMatchScoreRangeFilters(score?: number | null): { id: string;
|
||||
SelectButton
|
||||
]
|
||||
})
|
||||
export class BookFilterComponent implements OnInit {
|
||||
export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
@Output() filterSelected = new EventEmitter<Record<string, any> | null>();
|
||||
@Output() filterModeChanged = new EventEmitter<'and' | 'or'>();
|
||||
|
||||
@@ -148,41 +149,42 @@ export class BookFilterComponent implements OnInit {
|
||||
matchScore: 'Metadata Match Score'
|
||||
};
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
bookService = inject(BookService);
|
||||
userService = inject(UserService);
|
||||
sidebarFilterSortingManager = inject(FilterSortPreferenceService);
|
||||
|
||||
ngOnInit(): void {
|
||||
combineLatest([
|
||||
this.userService.userState$.pipe(
|
||||
filter((u): u is NonNullable<typeof u> => !!u),
|
||||
take(1)
|
||||
),
|
||||
this.sidebarFilterSortingManager.sortMode$.pipe(distinctUntilChanged()),
|
||||
this.entity$ ?? of(null),
|
||||
this.entityType$ ?? of(EntityType.ALL_BOOKS)
|
||||
]).subscribe(([user]) => {
|
||||
const sortMode = user.userSettings?.filterSortingMode ?? 'count';
|
||||
this.filterStreams = {
|
||||
author: this.getFilterStream((book: Book) => book.metadata?.authors.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
|
||||
category: this.getFilterStream((book: Book) => book.metadata?.categories.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
|
||||
series: this.getFilterStream((book) => (book.metadata?.seriesName ? [{id: book.metadata.seriesName, name: book.metadata.seriesName}] : []), 'id', 'name', sortMode),
|
||||
matchScore: this.getFilterStream((book: Book) => getMatchScoreRangeFilters(book.metadataMatchScore), 'id', 'name', 'sortIndex'),
|
||||
publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name', sortMode),
|
||||
shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name', sortMode),
|
||||
publishedDate: this.getFilterStream(extractPublishedYearFilter, 'id', 'name', sortMode),
|
||||
language: this.getFilterStream(getLanguageFilter, 'id', 'name', sortMode),
|
||||
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', sortMode),
|
||||
amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating!), 'id', 'name', sortMode),
|
||||
goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating!), 'id', 'name', sortMode),
|
||||
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', sortMode),
|
||||
pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), 'id', 'name', sortMode),
|
||||
};
|
||||
])
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe(([sortMode]) => {
|
||||
this.filterStreams = {
|
||||
author: this.getFilterStream((book: Book) => book.metadata?.authors.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
|
||||
category: this.getFilterStream((book: Book) => book.metadata?.categories.map(name => ({id: name, name})) || [], 'id', 'name', sortMode),
|
||||
series: this.getFilterStream((book) => (book.metadata?.seriesName ? [{id: book.metadata.seriesName, name: book.metadata.seriesName}] : []), 'id', 'name', sortMode),
|
||||
matchScore: this.getFilterStream((book: Book) => getMatchScoreRangeFilters(book.metadataMatchScore), 'id', 'name', 'sortIndex'),
|
||||
publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name', sortMode),
|
||||
shelfStatus: this.getFilterStream(getShelfStatusFilter, 'id', 'name', sortMode),
|
||||
publishedDate: this.getFilterStream(extractPublishedYearFilter, 'id', 'name', sortMode),
|
||||
language: this.getFilterStream(getLanguageFilter, 'id', 'name', sortMode),
|
||||
fileSize: this.getFilterStream((book: Book) => getFileSizeRangeFilters(book.fileSizeKb), 'id', 'name', sortMode),
|
||||
amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating!), 'id', 'name', sortMode),
|
||||
goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating!), 'id', 'name', sortMode),
|
||||
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating!), 'id', 'name', sortMode),
|
||||
pageCount: this.getFilterStream((book: Book) => getPageCountRangeFilters(book.metadata?.pageCount!), 'id', 'name', sortMode),
|
||||
};
|
||||
|
||||
this.filterTypes = Object.keys(this.filterStreams);
|
||||
this.setExpandedPanels();
|
||||
});
|
||||
this.filterTypes = Object.keys(this.filterStreams);
|
||||
this.setExpandedPanels();
|
||||
});
|
||||
|
||||
if (this.resetFilter$) {
|
||||
this.resetFilter$.subscribe(() => this.clearActiveFilter());
|
||||
this.resetFilter$.pipe(takeUntil(this.destroy$)).subscribe(() => this.clearActiveFilter());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,4 +300,9 @@ export class BookFilterComponent implements OnInit {
|
||||
onFiltersChanged(): void {
|
||||
this.setExpandedPanels();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
|
||||
+24
-17
@@ -1,15 +1,17 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {debounceTime} from 'rxjs/operators';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CoverScaleManager {
|
||||
private readonly baseWidth = 135;
|
||||
private readonly baseHeight = 220;
|
||||
export class CoverScalePreferenceService {
|
||||
|
||||
private readonly BASE_WIDTH = 135;
|
||||
private readonly BASE_HEIGHT = 220;
|
||||
private readonly DEBOUNCE_MS = 1000;
|
||||
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly userService = inject(UserService);
|
||||
@@ -21,8 +23,12 @@ export class CoverScaleManager {
|
||||
|
||||
constructor() {
|
||||
this.scaleChange$
|
||||
.pipe(debounceTime(1000))
|
||||
.subscribe(scale => this.persistScale(scale));
|
||||
.pipe(debounceTime(this.DEBOUNCE_MS))
|
||||
.subscribe(scale => this.saveScalePreference(scale));
|
||||
}
|
||||
|
||||
initScaleValue(scale: number | undefined): void {
|
||||
this.scaleFactor = scale ?? 1.0;
|
||||
}
|
||||
|
||||
setScale(scale: number): void {
|
||||
@@ -32,8 +38,8 @@ export class CoverScaleManager {
|
||||
|
||||
get currentCardSize(): { width: number; height: number } {
|
||||
return {
|
||||
width: Math.round(this.baseWidth * this.scaleFactor),
|
||||
height: Math.round(this.baseHeight * this.scaleFactor),
|
||||
width: Math.round(this.BASE_WIDTH * this.scaleFactor),
|
||||
height: Math.round(this.BASE_HEIGHT * this.scaleFactor),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,19 +47,20 @@ export class CoverScaleManager {
|
||||
return `${this.currentCardSize.width}px`;
|
||||
}
|
||||
|
||||
private persistScale(scale: number): void {
|
||||
private saveScalePreference(scale: number): void {
|
||||
const user = this.userService.getCurrentUser();
|
||||
const entityViewPreferences = user?.userSettings?.entityViewPreferences;
|
||||
if (!user || !entityViewPreferences) {
|
||||
return;
|
||||
}
|
||||
entityViewPreferences.global = entityViewPreferences.global ?? {};
|
||||
entityViewPreferences.global.coverSize = scale;
|
||||
this.userService.updateUserSetting(user.id, 'entityViewPreferences', entityViewPreferences);
|
||||
const prefs = user?.userSettings?.entityViewPreferences;
|
||||
|
||||
if (!user || !prefs) return;
|
||||
|
||||
prefs.global = {...prefs.global, coverSize: scale};
|
||||
this.userService.updateUserSetting(user.id, 'entityViewPreferences', prefs);
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Cover Size Saved',
|
||||
detail: `Cover size set to ${scale.toFixed(2)}x.`
|
||||
detail: `Cover size set to ${scale.toFixed(2)}x.`,
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,8 @@ export class SeriesCollapseFilter implements BookFilter {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Preference Saved',
|
||||
detail: `Series collapse set to ${isCollapsed ? 'enabled' : 'disabled'}.`
|
||||
detail: `Series collapse set to ${isCollapsed ? 'enabled' : 'disabled'}.`,
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FilterSortPreferenceService {
|
||||
|
||||
readonly filterSortingOptions = [
|
||||
{ label: 'Alphabetical (A–Z)', value: 'alphabetical' },
|
||||
{ label: 'Book Count (High to Low)', value: 'count' }
|
||||
];
|
||||
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
|
||||
private readonly sortModeSubject = new BehaviorSubject<'alphabetical' | 'count'>('count');
|
||||
readonly sortMode$ = this.sortModeSubject.asObservable();
|
||||
|
||||
initValue(value: 'alphabetical' | 'count' | null | undefined): void {
|
||||
const resolved = value ?? 'count';
|
||||
this.sortModeSubject.next(resolved);
|
||||
}
|
||||
|
||||
get selectedFilterSorting(): 'alphabetical' | 'count' {
|
||||
return this.sortModeSubject.value;
|
||||
}
|
||||
|
||||
set selectedFilterSorting(value: 'alphabetical' | 'count') {
|
||||
if (this.sortModeSubject.value !== value) {
|
||||
this.sortModeSubject.next(value);
|
||||
this.savePreference(value);
|
||||
}
|
||||
}
|
||||
|
||||
private savePreference(value: 'alphabetical' | 'count'): void {
|
||||
const user = this.userService.getCurrentUser();
|
||||
if (!user) return;
|
||||
|
||||
user.userSettings.filterSortingMode = value;
|
||||
this.userService.updateUserSetting(user.id, 'filterSortingMode', value);
|
||||
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Preferences Updated',
|
||||
detail: 'Your filter sorting preference has been saved.',
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
<div class="p-4">
|
||||
<div class="flex items-center gap-2 pb-6 pt-4">
|
||||
<p class="text-lg">Sidebar Filter Sorting:</p>
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="This setting controls the order in which filter values (like authors, categories, etc.) appear in the sidebar."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-[auto,1fr] pl-6 gap-y-4 gap-x-4 items-center">
|
||||
<p class="py-1">Sorting Mode:
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="You can sort filter options alphabetically (A–Z) or by the number of books that match each filter value. For example, categories with more books can appear at the top."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</p>
|
||||
<div class="flex gap-4 justify-start">
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="filterSortingOptions"
|
||||
[(ngModel)]="selectedFilterSorting"
|
||||
(ngModelChange)="onFilterSortingChange()"
|
||||
placeholder="Select Sorting">
|
||||
</p-select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Select} from 'primeng/select';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {User, UserService, UserSettings} from '../../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Observable, Subscription} from 'rxjs';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar-filter-sorting-prefs-component',
|
||||
imports: [
|
||||
Select,
|
||||
Tooltip,
|
||||
FormsModule
|
||||
],
|
||||
templateUrl: './sidebar-filter-sorting-prefs-component.html',
|
||||
styleUrl: './sidebar-filter-sorting-prefs-component.scss'
|
||||
})
|
||||
export class SidebarFilterSortingPrefsComponent implements OnInit, OnDestroy {
|
||||
|
||||
readonly filterSortingOptions = [
|
||||
{label: 'Alphabetical (A–Z)', value: 'alphabetical'},
|
||||
{label: 'Book Count (High to Low)', value: 'count'}
|
||||
];
|
||||
|
||||
selectedFilterSorting: 'alphabetical' | 'count' = 'count';
|
||||
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
|
||||
userData$: Observable<User | null> = this.userService.userState$;
|
||||
private subscription?: Subscription;
|
||||
private currentUser: User | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscription = this.userData$.subscribe(user => {
|
||||
if (user) {
|
||||
this.currentUser = user;
|
||||
this.loadPreferences(user.userSettings);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription?.unsubscribe();
|
||||
}
|
||||
|
||||
private loadPreferences(settings: UserSettings): void {
|
||||
this.selectedFilterSorting = settings.filterSortingMode;
|
||||
}
|
||||
|
||||
private updatePreference(path: string[], value: any): void {
|
||||
if (!this.currentUser) return;
|
||||
let target: any = this.currentUser.userSettings;
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
target = target[path[i]] ||= {};
|
||||
}
|
||||
target[path.at(-1)!] = value;
|
||||
|
||||
const [rootKey] = path;
|
||||
const updatedValue = this.currentUser.userSettings[rootKey as keyof UserSettings];
|
||||
this.userService.updateUserSetting(this.currentUser.id, rootKey, updatedValue);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Preferences Updated',
|
||||
detail: 'Your preferences have been saved successfully.',
|
||||
life: 2000
|
||||
});
|
||||
}
|
||||
|
||||
onFilterSortingChange(): void {
|
||||
this.updatePreference(['filterSortingMode'], this.selectedFilterSorting);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -68,7 +68,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
||||
severity: 'success',
|
||||
summary: 'Preferences Updated',
|
||||
detail: 'Your preferences have been saved successfully.',
|
||||
life: 2000
|
||||
life: 1500
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -2,6 +2,4 @@
|
||||
<app-view-preferences></app-view-preferences>
|
||||
<p-divider></p-divider>
|
||||
<app-sidebar-sorting-preferences></app-sidebar-sorting-preferences>
|
||||
<p-divider></p-divider>
|
||||
<app-sidebar-filter-sorting-prefs-component></app-sidebar-filter-sorting-prefs-component>
|
||||
</div>
|
||||
|
||||
+1
-3
@@ -5,7 +5,6 @@ import {TableModule} from 'primeng/table';
|
||||
import {ToastModule} from 'primeng/toast';
|
||||
import {ViewPreferencesComponent} from './view-preferences/view-preferences.component';
|
||||
import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/sidebar-sorting-preferences.component';
|
||||
import {SidebarFilterSortingPrefsComponent} from './sidebar-filter-sorting-prefs-component/sidebar-filter-sorting-prefs-component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-preferences-parent',
|
||||
@@ -16,8 +15,7 @@ import {SidebarFilterSortingPrefsComponent} from './sidebar-filter-sorting-prefs
|
||||
TableModule,
|
||||
ToastModule,
|
||||
ViewPreferencesComponent,
|
||||
SidebarSortingPreferencesComponent,
|
||||
SidebarFilterSortingPrefsComponent
|
||||
SidebarSortingPreferencesComponent
|
||||
],
|
||||
templateUrl: './view-preferences-parent.component.html',
|
||||
styleUrl: './view-preferences-parent.component.scss'
|
||||
|
||||
Reference in New Issue
Block a user