Add a user-facing option to enable or disable series view (#1748)

This commit is contained in:
Aditya Chandel
2025-12-03 21:17:06 -07:00
committed by GitHub
parent 9b6079a3b5
commit f22f9bd1e0
15 changed files with 106 additions and 28 deletions
@@ -129,6 +129,7 @@ export interface UserSettings {
sidebarShelfSorting: SidebarShelfSorting;
filterSortingMode: 'alphabetical' | 'count';
metadataCenterViewMode: 'route' | 'dialog';
enableSeriesView: boolean;
entityViewPreferences: EntityViewPreferences;
tableColumnPreference?: TableColumnPreference[];
dashboardConfig?: DashboardConfig;
@@ -173,7 +174,7 @@ export class UserService {
private http = inject(HttpClient);
private authService = inject(AuthService);
private userStateSubject = new BehaviorSubject<UserState>({
userStateSubject = new BehaviorSubject<UserState>({
user: null,
loaded: false,
error: null,
@@ -1,11 +1,11 @@
<div class="main-container enclosing-container">
<div class="settings-header">
<h2 class="settings-title">
<i class="pi pi-window-maximize"></i>
Open Metadata Center
<i class="pi pi-cog"></i>
View Preferences
</h2>
<p class="settings-description">
Decide how you want to view book details - inline as a full page or in a pop-up dialog.
Customize how you view metadata and series information.
</p>
</div>
@@ -16,7 +16,7 @@
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">
Display Mode
Metadata Center Display Mode
<i class="pi pi-info-circle text-sky-600"
pTooltip="Choose whether to open the Metadata Center in the current page or as a popup dialog window."
tooltipPosition="right"
@@ -47,6 +47,42 @@
</p>
</div>
</div>
<!-- Series View Mode Setting -->
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">
Series View Mode
<i class="pi pi-info-circle text-sky-600"
pTooltip="Enable or disable the series view mode for displaying series information."
tooltipPosition="right"
style="cursor: pointer;">
</i>
</label>
<div class="radio-group">
<div class="radio-option">
<p-radioButton name="seriesViewMode"
[value]="true"
[(ngModel)]="seriesViewMode"
inputId="seriesViewModeTrue"
(onClick)="onSeriesViewModeChange(true)"></p-radioButton>
<label for="seriesViewModeTrue">Enabled</label>
</div>
<div class="radio-option">
<p-radioButton name="seriesViewMode"
[value]="false"
[(ngModel)]="seriesViewMode"
inputId="seriesViewModeFalse"
(onClick)="onSeriesViewModeChange(false)"></p-radioButton>
<label for="seriesViewModeFalse">Disabled</label>
</div>
</div>
</div>
<p class="setting-description">
Enable or disable the series view mode for displaying series information.
</p>
</div>
</div>
</div>
</div>
</div>
@@ -10,8 +10,8 @@
}
.settings-header {
margin-top: 1rem;
margin-bottom: 2rem;
margin-top: 1.25rem;
margin-bottom: 1rem;
}
.settings-title {
@@ -19,6 +19,7 @@ import {Subject} from 'rxjs';
})
export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
viewMode: 'route' | 'dialog' = 'route';
seriesViewMode: boolean = false;
private userService = inject(UserService);
private messageService = inject(MessageService);
@@ -34,6 +35,10 @@ export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
if (preference === 'dialog' || preference === 'route') {
this.viewMode = preference;
}
const seriesPref = userState.user?.userSettings?.enableSeriesView;
if (typeof seriesPref === 'boolean') {
this.seriesViewMode = seriesPref;
}
});
}
@@ -47,6 +52,11 @@ export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
this.savePreference(value);
}
onSeriesViewModeChange(value: boolean): void {
this.seriesViewMode = value;
this.saveSeriesViewPreference(value);
}
private savePreference(value: 'route' | 'dialog'): void {
const user = this.userService.getCurrentUser();
if (!user) return;
@@ -61,4 +71,19 @@ export class MetaCenterViewModeComponent implements OnInit, OnDestroy {
life: 1500,
});
}
private saveSeriesViewPreference(value: boolean): void {
const user = this.userService.getCurrentUser();
if (!user) return;
user.userSettings.enableSeriesView = value;
this.userService.updateUserSetting(user.id, 'enableSeriesView', value);
this.messageService.add({
severity: 'success',
summary: 'Preferences Updated',
detail: 'Your series view mode preference has been saved.',
life: 1500,
});
}
}
@@ -10,8 +10,8 @@
}
.settings-header {
margin-top: 1rem;
margin-bottom: 2rem;
margin-top: 1.25rem;
margin-bottom: 1rem;
}
.settings-title {