Add sort preference option for Magic Shelf names in the left sidebar (#1749)
This commit is contained in:
@@ -36,6 +36,11 @@ export interface SidebarShelfSorting {
|
||||
order: string;
|
||||
}
|
||||
|
||||
export interface SidebarMagicShelfSorting {
|
||||
field: string;
|
||||
order: string;
|
||||
}
|
||||
|
||||
export interface PerBookSetting {
|
||||
pdf: string;
|
||||
epub: string;
|
||||
@@ -129,6 +134,7 @@ export interface UserSettings {
|
||||
newPdfReaderSetting: NewPdfReaderSetting;
|
||||
sidebarLibrarySorting: SidebarLibrarySorting;
|
||||
sidebarShelfSorting: SidebarShelfSorting;
|
||||
sidebarMagicShelfSorting: SidebarMagicShelfSorting;
|
||||
filterMode: BookFilterMode;
|
||||
filterSortingMode: FilterSortingMode;
|
||||
metadataCenterViewMode: 'route' | 'dialog';
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
</p-select>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Choose the default mode for combining filters selected from the filter sidebar.
|
||||
Choose the default mode for combining filters selected from the right filter sidebar.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
.settings-header {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.settings-title {
|
||||
|
||||
+24
-13
@@ -5,7 +5,7 @@
|
||||
Sidebar Library and Shelf Sorting Preference
|
||||
</h2>
|
||||
<p class="settings-description">
|
||||
Configure sorting options for your library and shelves shown in the sidebar.
|
||||
Configure sorting options for your library and shelves names shown in the left menu sidebar.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -17,11 +17,6 @@
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">
|
||||
Library
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Choose how books are sorted and displayed in the library sidebar."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</label>
|
||||
<p-select
|
||||
size="small"
|
||||
@@ -33,7 +28,7 @@
|
||||
</p-select>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Choose how books are sorted and displayed in the library sidebar.
|
||||
Choose how library names are sorted and displayed in the sidebar.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -43,11 +38,6 @@
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">
|
||||
Shelf
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Choose how books are sorted and displayed in the shelf sidebar."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer;">
|
||||
</i>
|
||||
</label>
|
||||
<p-select
|
||||
size="small"
|
||||
@@ -59,7 +49,28 @@
|
||||
</p-select>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Choose how books are sorted and displayed in the shelf sidebar.
|
||||
Choose how shelf names are sorted and displayed in the sidebar.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">
|
||||
Magic Shelf
|
||||
</label>
|
||||
<p-select
|
||||
size="small"
|
||||
[options]="sortingOptions"
|
||||
[(ngModel)]="selectedMagicShelfSorting"
|
||||
(ngModelChange)="onMagicShelfSortingChange()"
|
||||
appendTo="body"
|
||||
placeholder="Select Sorting">
|
||||
</p-select>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Choose how magic shelf names are sorted and displayed in the sidebar.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+7
-3
@@ -1,7 +1,6 @@
|
||||
import {Component, inject, OnDestroy, OnInit} from '@angular/core';
|
||||
import {Select} from 'primeng/select';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {SidebarLibrarySorting, SidebarShelfSorting, User, UserService, UserSettings, UserState} from '../../user-management/user.service';
|
||||
import {SidebarLibrarySorting, SidebarMagicShelfSorting, SidebarShelfSorting, User, UserService, UserSettings, UserState} from '../../user-management/user.service';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Observable, Subject} from 'rxjs';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
@@ -11,7 +10,6 @@ import {filter, takeUntil} from 'rxjs/operators';
|
||||
selector: 'app-sidebar-sorting-preferences',
|
||||
imports: [
|
||||
Select,
|
||||
Tooltip,
|
||||
FormsModule
|
||||
],
|
||||
templateUrl: './sidebar-sorting-preferences.component.html',
|
||||
@@ -28,6 +26,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
||||
|
||||
selectedLibrarySorting: SidebarLibrarySorting = {field: 'id', order: 'asc'};
|
||||
selectedShelfSorting: SidebarShelfSorting = {field: 'id', order: 'asc'};
|
||||
selectedMagicShelfSorting: SidebarMagicShelfSorting = {field: 'id', order: 'asc'};
|
||||
|
||||
private readonly userService = inject(UserService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
@@ -54,6 +53,7 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
||||
private loadPreferences(settings: UserSettings): void {
|
||||
this.selectedLibrarySorting = settings.sidebarLibrarySorting;
|
||||
this.selectedShelfSorting = settings.sidebarShelfSorting;
|
||||
this.selectedMagicShelfSorting = settings.sidebarMagicShelfSorting;
|
||||
}
|
||||
|
||||
private updatePreference(path: string[], value: any): void {
|
||||
@@ -82,4 +82,8 @@ export class SidebarSortingPreferencesComponent implements OnInit, OnDestroy {
|
||||
onShelfSortingChange() {
|
||||
this.updatePreference(['sidebarShelfSorting'], this.selectedShelfSorting);
|
||||
}
|
||||
|
||||
onMagicShelfSortingChange() {
|
||||
this.updatePreference(['sidebarMagicShelfSorting'], this.selectedMagicShelfSorting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ export class AppMenuComponent implements OnInit {
|
||||
librarySortOrder: 'asc' | 'desc' = 'desc';
|
||||
shelfSortField: 'name' | 'id' = 'name';
|
||||
shelfSortOrder: 'asc' | 'desc' = 'asc';
|
||||
magicShelfSortField: 'name' | 'id' = 'name';
|
||||
magicShelfSortOrder: 'asc' | 'desc' = 'asc';
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -60,6 +62,10 @@ export class AppMenuComponent implements OnInit {
|
||||
this.shelfSortField = this.validateSortField(userState.user.userSettings.sidebarShelfSorting.field);
|
||||
this.shelfSortOrder = this.validateSortOrder(userState.user.userSettings.sidebarShelfSorting.order);
|
||||
}
|
||||
if (userState.user?.userSettings.sidebarMagicShelfSorting) {
|
||||
this.magicShelfSortField = this.validateSortField(userState.user.userSettings.sidebarMagicShelfSorting.field);
|
||||
this.magicShelfSortOrder = this.validateSortOrder(userState.user.userSettings.sidebarMagicShelfSorting.order);
|
||||
}
|
||||
this.initMenus();
|
||||
});
|
||||
|
||||
@@ -113,7 +119,7 @@ export class AppMenuComponent implements OnInit {
|
||||
this.magicShelfMenu$ = this.magicShelfService.shelvesState$.pipe(
|
||||
map((state: MagicShelfState) => {
|
||||
const shelves = state.shelves ?? [];
|
||||
const sortedShelves = this.sortArray(shelves, 'name', 'asc');
|
||||
const sortedShelves = this.sortArray(shelves, this.magicShelfSortField, this.magicShelfSortOrder);
|
||||
return [
|
||||
{
|
||||
label: 'Magic Shelves',
|
||||
|
||||
Reference in New Issue
Block a user