refactor(dashboard): move dashboard configuration to view preferences settings (#1822)
This commit is contained in:
-161
@@ -1,161 +0,0 @@
|
||||
<ng-container *transloco="let t; prefix: 'dashboard.settings'">
|
||||
<div class="dashboard-settings">
|
||||
<div class="panel-header">
|
||||
<div class="header-icon-wrapper">
|
||||
<i class="pi pi-sliders-h header-icon"></i>
|
||||
</div>
|
||||
<div class="header-text">
|
||||
<h2 class="panel-title">{{ t('title') }}</h2>
|
||||
<p class="panel-description">{{ t('description') }}</p>
|
||||
</div>
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
[text]="true"
|
||||
[rounded]="true"
|
||||
severity="secondary"
|
||||
(onClick)="cancel()"
|
||||
class="close-button"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="scrollers-container">
|
||||
@for (scroller of config.scrollers; track scroller.id; let i = $index) {
|
||||
<div class="scroller-item">
|
||||
<div class="scroller-content">
|
||||
<div class="scroller-controls-left">
|
||||
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="scroller-fields">
|
||||
<div class="scroller-field" [class.expanded]="scroller.type !== 'magicShelf'">
|
||||
<label [for]="'dashboard-scroller-type-' + scroller.id">{{ t('type') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-type-' + scroller.id"
|
||||
[options]="availableScrollerTypes()"
|
||||
[(ngModel)]="scroller.type"
|
||||
(onChange)="onScrollerTypeChange(scroller)"
|
||||
[placeholder]="t('selectType')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
@if (scroller.type === 'magicShelf') {
|
||||
<div class="scroller-field">
|
||||
<label [for]="'dashboard-scroller-magic-shelf-' + scroller.id">{{ t('magicShelf') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-magic-shelf-' + scroller.id"
|
||||
[options]="magicShelves()"
|
||||
[(ngModel)]="scroller.magicShelfId"
|
||||
[placeholder]="t('selectMagicShelf')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field">
|
||||
<label [for]="'dashboard-scroller-sort-field-' + scroller.id">{{ t('sortField') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-sort-field-' + scroller.id"
|
||||
[options]="sortFieldOptions()"
|
||||
[(ngModel)]="scroller.sortField"
|
||||
[placeholder]="t('selectField')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field">
|
||||
<label [for]="'dashboard-scroller-sort-direction-' + scroller.id">{{ t('direction') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-sort-direction-' + scroller.id"
|
||||
[options]="sortDirectionOptions()"
|
||||
[(ngModel)]="scroller.sortDirection"
|
||||
[placeholder]="t('selectDirection')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="scroller-field max-items-field">
|
||||
<label [for]="'dashboard-scroller-max-items-' + scroller.id">{{ t('maxItems') }}</label>
|
||||
<p-inputNumber
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-max-items-' + scroller.id"
|
||||
[(ngModel)]="scroller.maxItems"
|
||||
[min]="MIN_ITEMS"
|
||||
[max]="MAX_ITEMS"
|
||||
[showButtons]="true">
|
||||
</p-inputNumber>
|
||||
</div>
|
||||
|
||||
<div class="scroller-controls-right">
|
||||
<p-button
|
||||
icon="pi pi-arrow-up"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === 0"
|
||||
(click)="moveUp(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-arrow-down"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === config.scrollers.length - 1"
|
||||
(click)="moveDown(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
outlined
|
||||
rounded
|
||||
size="small"
|
||||
severity="danger"
|
||||
(click)="removeScroller(i)"
|
||||
[disabled]="config.scrollers.length === 1">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<div class="footer-left">
|
||||
<p-button
|
||||
[label]="t('addScroller')"
|
||||
icon="pi pi-plus"
|
||||
severity="primary"
|
||||
(click)="addScroller()"
|
||||
[disabled]="config.scrollers.length >= 5">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="t('resetToDefault')"
|
||||
icon="pi pi-refresh"
|
||||
severity="secondary"
|
||||
text
|
||||
(click)="resetToDefault()">
|
||||
</p-button>
|
||||
</div>
|
||||
<div class="footer-actions">
|
||||
<p-button
|
||||
[label]="'common.cancel' | transloco"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
(click)="cancel()">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="'common.save' | transloco"
|
||||
icon="pi pi-check"
|
||||
severity="success"
|
||||
(click)="save()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
@use '../../../../shared/styles/panel-shared' as panel;
|
||||
|
||||
.dashboard-settings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@media (width <= 640px) {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
@include panel.panel-header;
|
||||
}
|
||||
|
||||
.settings-controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6563rem;
|
||||
padding: 0.875rem 1.75rem;
|
||||
background: var(--color-page);
|
||||
border: 1px solid var(--color-border);
|
||||
border-top: none;
|
||||
|
||||
.settings-info {
|
||||
.info-content {
|
||||
display: flex;
|
||||
gap: 0.6563rem;
|
||||
padding: 0.6563rem;
|
||||
background: var(--color-page);
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--p-primary-300);
|
||||
|
||||
.info-icon {
|
||||
color: var(--color-primary);
|
||||
font-size: var(--app-text-lg);
|
||||
flex-shrink: 0;
|
||||
margin-top: 0.1094rem;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
flex: 1;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 480px) {
|
||||
padding: 0.875rem;
|
||||
gap: 0.4375rem;
|
||||
|
||||
.settings-info {
|
||||
.info-content {
|
||||
flex-direction: column;
|
||||
gap: 0.4375rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scrollers-container {
|
||||
padding: 1.3125rem 1.75rem;
|
||||
background: var(--color-page);
|
||||
border: 1px solid var(--color-border);
|
||||
border-top: none;
|
||||
min-height: 200px;
|
||||
max-height: 450px;
|
||||
overflow-y: auto;
|
||||
|
||||
@media (width <= 480px) {
|
||||
padding: 0.875rem;
|
||||
max-height: 400px;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-item {
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s;
|
||||
border-color: var(--p-content-border-color);
|
||||
background: var(--p-content-background);
|
||||
padding: 0.875rem;
|
||||
margin-bottom: 0.6563rem;
|
||||
border-radius: 0.3281rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding: 0.6563rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-content {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 0.6563rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-controls-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 0.5687rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding-bottom: 0;
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-controls-right {
|
||||
display: flex;
|
||||
gap: 0.4375rem;
|
||||
padding-bottom: 0.2188rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding-bottom: 0;
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 0.6563rem;
|
||||
flex: 1;
|
||||
|
||||
@media (width <= 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.6563rem;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
gap: 0.4375rem;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-field {
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 0.4375rem;
|
||||
}
|
||||
|
||||
&.expanded {
|
||||
flex: 1;
|
||||
|
||||
@media (width <= 768px) {
|
||||
flex: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.max-items-field {
|
||||
max-width: 7.875rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
@media (width <= 768px) {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--app-text-sm);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
@include panel.dialog-footer;
|
||||
|
||||
border-top: none;
|
||||
|
||||
.footer-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4375rem;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
.footer-left {
|
||||
flex-direction: column;
|
||||
gap: 0.4375rem;
|
||||
|
||||
::ng-deep .p-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
::ng-deep .p-button {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.add-scroller-wrapper {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
import {describe, it} from 'vitest';
|
||||
|
||||
// NOTE(frontend-seam): Real coverage here needs seams around effect-driven dashboard config syncing,
|
||||
// dynamic dialog lifecycle, translated option rebuilding, and magic-shelf collections so config edits
|
||||
// can be asserted without coupling the spec to the full dashboard settings UI.
|
||||
describe.skip('DashboardSettingsComponent', () => {
|
||||
it('needs config and dialog seams to verify scroller add/remove/reorder behavior and translated option rebuilding', () => {
|
||||
// TODO(seam): Cover dashboard config mutation and save/close flows once the config service and dialog interactions are wrapped.
|
||||
});
|
||||
});
|
||||
-12
@@ -38,18 +38,6 @@
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="dashboard-settings-button">
|
||||
<p-button
|
||||
icon="pi pi-cog"
|
||||
severity="info"
|
||||
rounded
|
||||
text
|
||||
[pTooltip]="t('customizeDashboard')"
|
||||
tooltipPosition="left"
|
||||
(click)="openDashboardSettings()">
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
@if (dashboardConfig(); as config) {
|
||||
@for (scroller of enabledScrollers(); track scroller.id; let idx = $index) {
|
||||
@if (idx < 2) {
|
||||
|
||||
-31
@@ -70,37 +70,6 @@
|
||||
background-color: rgb(0 0 0 / 50%);
|
||||
}
|
||||
|
||||
.dashboard-settings-button {
|
||||
position: fixed;
|
||||
top: 5.25rem;
|
||||
right: 1.75rem;
|
||||
z-index: 100;
|
||||
|
||||
::ng-deep .p-button {
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
|
||||
background: transparent;
|
||||
border: 1px solid var(--color-border);
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--color-app) 70%, var(--color-page));
|
||||
transform: scale(1.05);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width <= 768px) {
|
||||
.dashboard-settings-button {
|
||||
top: 4.375rem;
|
||||
right: 0.875rem;
|
||||
|
||||
::ng-deep .p-button {
|
||||
width: 2.1875rem;
|
||||
height: 2.1875rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-placeholder {
|
||||
height: 260px;
|
||||
margin-bottom: 1.75rem;
|
||||
|
||||
-6
@@ -4,7 +4,6 @@ import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroll
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
||||
import {ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
||||
@@ -24,7 +23,6 @@ import {Book} from '../../../book/model/book.model';
|
||||
Button,
|
||||
DashboardScrollerComponent,
|
||||
ProgressSpinner,
|
||||
Tooltip,
|
||||
TranslocoDirective
|
||||
],
|
||||
standalone: true
|
||||
@@ -61,10 +59,6 @@ export class MainDashboardComponent {
|
||||
return this.dashboardBookService.scrollerBooksMap().get(config.id) ?? [];
|
||||
}
|
||||
|
||||
openDashboardSettings(): void {
|
||||
void this.dialogLauncher.openDashboardSettingsDialog().catch(() => undefined);
|
||||
}
|
||||
|
||||
createNewLibrary() {
|
||||
void this.dialogLauncher.openLibraryCreateDialog().catch(() => undefined);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import {DEFAULT_MAX_ITEMS} from '../components/dashboard-settings/dashboard-settings.component';
|
||||
export const MAX_SCROLLERS = 5;
|
||||
export const DEFAULT_MAX_ITEMS = 20;
|
||||
export const MIN_ITEMS = 10;
|
||||
export const MAX_ITEMS = 20;
|
||||
|
||||
export enum ScrollerType {
|
||||
LAST_READ = 'lastRead',
|
||||
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<ng-container *transloco="let t; prefix: 'settingsView.dashboardScrollers'">
|
||||
<div class="settings-card">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">
|
||||
<i class="pi pi-sliders-h"></i>
|
||||
{{ t('sectionTitle') }}
|
||||
</h3>
|
||||
<p class="section-description">
|
||||
{{ t('sectionDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section-body">
|
||||
<div class="scrollers-container">
|
||||
@for (scroller of config.scrollers; track scroller.id; let i = $index) {
|
||||
<div class="scroller-item">
|
||||
<div class="scroller-content">
|
||||
<div class="scroller-controls-left">
|
||||
<p-checkbox [(ngModel)]="scroller.enabled" [binary]="true"></p-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="scroller-fields">
|
||||
<div class="scroller-field" [class.expanded]="scroller.type !== ScrollerType.MAGIC_SHELF">
|
||||
<label [for]="'dashboard-scroller-type-' + scroller.id">{{ t('type') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-type-' + scroller.id"
|
||||
[options]="availableScrollerTypes()"
|
||||
[(ngModel)]="scroller.type"
|
||||
(onChange)="onScrollerTypeChange(scroller)"
|
||||
[placeholder]="t('selectType')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
@if (scroller.type === ScrollerType.MAGIC_SHELF) {
|
||||
<div class="scroller-field">
|
||||
<label [for]="'dashboard-scroller-magic-shelf-' + scroller.id">{{ t('magicShelf') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-magic-shelf-' + scroller.id"
|
||||
[options]="magicShelves()"
|
||||
[(ngModel)]="scroller.magicShelfId"
|
||||
[placeholder]="t('selectMagicShelf')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field">
|
||||
<label [for]="'dashboard-scroller-sort-field-' + scroller.id">{{ t('sortField') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-sort-field-' + scroller.id"
|
||||
[options]="sortFieldOptions()"
|
||||
[(ngModel)]="scroller.sortField"
|
||||
[placeholder]="t('selectField')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
|
||||
<div class="scroller-field">
|
||||
<label [for]="'dashboard-scroller-sort-direction-' + scroller.id">{{ t('direction') }}</label>
|
||||
<p-select
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-sort-direction-' + scroller.id"
|
||||
[options]="sortDirectionOptions()"
|
||||
[(ngModel)]="scroller.sortDirection"
|
||||
[placeholder]="t('selectDirection')"
|
||||
appendTo="body">
|
||||
</p-select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="scroller-field max-items-field">
|
||||
<label [for]="'dashboard-scroller-max-items-' + scroller.id">{{ t('maxItems') }}</label>
|
||||
<p-inputNumber
|
||||
fluid
|
||||
[inputId]="'dashboard-scroller-max-items-' + scroller.id"
|
||||
[(ngModel)]="scroller.maxItems"
|
||||
[min]="MIN_ITEMS"
|
||||
[max]="MAX_ITEMS"
|
||||
[showButtons]="true">
|
||||
</p-inputNumber>
|
||||
</div>
|
||||
|
||||
<div class="scroller-controls-right">
|
||||
<p-button
|
||||
icon="pi pi-arrow-up"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === 0"
|
||||
(onClick)="moveUp(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-arrow-down"
|
||||
outlined
|
||||
rounded
|
||||
severity="info"
|
||||
size="small"
|
||||
[disabled]="i === config.scrollers.length - 1"
|
||||
(onClick)="moveDown(i)">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
outlined
|
||||
rounded
|
||||
size="small"
|
||||
severity="danger"
|
||||
(onClick)="removeScroller(i)"
|
||||
[disabled]="config.scrollers.length === 1">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="setting-actions">
|
||||
<div class="actions-left">
|
||||
<p-button
|
||||
[label]="t('addScroller')"
|
||||
icon="pi pi-plus"
|
||||
severity="primary"
|
||||
outlined
|
||||
size="small"
|
||||
(onClick)="addScroller()"
|
||||
[disabled]="config.scrollers.length >= MAX_SCROLLERS">
|
||||
</p-button>
|
||||
<p-button
|
||||
[label]="t('resetToDefault')"
|
||||
icon="pi pi-refresh"
|
||||
severity="secondary"
|
||||
text
|
||||
size="small"
|
||||
(onClick)="resetToDefault()">
|
||||
</p-button>
|
||||
</div>
|
||||
<p-button
|
||||
[label]="t('saveSettings')"
|
||||
icon="pi pi-save"
|
||||
outlined
|
||||
severity="success"
|
||||
(onClick)="save()">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
@use '../../../../shared/styles/settings-shared' as settings;
|
||||
|
||||
.settings-card {
|
||||
@include settings.settings-card;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
@include settings.settings-section-header;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
@include settings.settings-section-title;
|
||||
}
|
||||
|
||||
.section-description {
|
||||
@include settings.settings-section-description;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
@include settings.settings-section-body;
|
||||
}
|
||||
|
||||
.scrollers-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.scroller-item {
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s;
|
||||
border-color: var(--p-content-border-color);
|
||||
background: var(--p-content-background);
|
||||
padding: 0.875rem;
|
||||
margin-bottom: 0.6563rem;
|
||||
border-radius: 0.3281rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding: 0.6563rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-content {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 0.6563rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0.875rem;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-controls-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 0.5687rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding-bottom: 0;
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-controls-right {
|
||||
display: flex;
|
||||
gap: 0.4375rem;
|
||||
padding-bottom: 0.2188rem;
|
||||
|
||||
@media (width <= 768px) {
|
||||
padding-bottom: 0;
|
||||
align-self: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 0.6563rem;
|
||||
flex: 1;
|
||||
|
||||
@media (width <= 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.6563rem;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
gap: 0.4375rem;
|
||||
}
|
||||
}
|
||||
|
||||
.scroller-field {
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 0.4375rem;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--app-text-sm);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&.expanded {
|
||||
flex: 1;
|
||||
|
||||
@media (width <= 768px) {
|
||||
flex: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.max-items-field {
|
||||
max-width: 7.875rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
@media (width <= 768px) {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.6563rem;
|
||||
margin-top: 0.875rem;
|
||||
|
||||
.actions-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4375rem;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
.actions-left {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
::ng-deep .p-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
-25
@@ -1,23 +1,18 @@
|
||||
import {Component, computed, effect, inject} from '@angular/core';
|
||||
import {toSignal} from '@angular/core/rxjs-interop';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Select} from 'primeng/select';
|
||||
import {InputNumber} from 'primeng/inputnumber';
|
||||
import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model';
|
||||
import {DashboardConfigService} from '../../services/dashboard-config.service';
|
||||
import {DashboardConfig, DEFAULT_MAX_ITEMS, MAX_ITEMS, MAX_SCROLLERS, MIN_ITEMS, ScrollerConfig, ScrollerType} from '../../../dashboard/models/dashboard-config.model';
|
||||
import {DashboardConfigService} from '../../../dashboard/services/dashboard-config.service';
|
||||
import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service';
|
||||
import {TranslocoDirective, TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
export const MAX_SCROLLERS = 5;
|
||||
export const DEFAULT_MAX_ITEMS = 20;
|
||||
export const MIN_ITEMS = 10;
|
||||
export const MAX_ITEMS = 20;
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard-settings',
|
||||
selector: 'app-dashboard-preferences',
|
||||
standalone: true,
|
||||
imports: [
|
||||
FormsModule,
|
||||
@@ -25,15 +20,14 @@ export const MAX_ITEMS = 20;
|
||||
Checkbox,
|
||||
Select,
|
||||
InputNumber,
|
||||
TranslocoDirective,
|
||||
TranslocoPipe
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './dashboard-settings.component.html',
|
||||
styleUrls: ['./dashboard-settings.component.scss']
|
||||
templateUrl: './dashboard-preferences.component.html',
|
||||
styleUrls: ['./dashboard-preferences.component.scss']
|
||||
})
|
||||
export class DashboardSettingsComponent {
|
||||
export class DashboardPreferencesComponent {
|
||||
private readonly configService = inject(DashboardConfigService);
|
||||
private readonly dialogRef = inject(DynamicDialogRef);
|
||||
private readonly messageService = inject(MessageService);
|
||||
private readonly magicShelfService = inject(MagicShelfService);
|
||||
private readonly translocoService = inject(TranslocoService);
|
||||
private readonly activeLanguage = toSignal(this.translocoService.langChanges$, {
|
||||
@@ -44,7 +38,7 @@ export class DashboardSettingsComponent {
|
||||
|
||||
readonly availableScrollerTypes = computed(() => {
|
||||
this.activeLanguage(); // Trigger on language change
|
||||
const t = (key: string) => this.translocoService.translate(`dashboard.settings.${key}`);
|
||||
const t = (key: string) => this.translocoService.translate(`settingsView.dashboardScrollers.${key}`);
|
||||
return [
|
||||
{label: t('scrollerTypes.lastRead'), value: ScrollerType.LAST_READ},
|
||||
{label: t('scrollerTypes.lastListened'), value: ScrollerType.LAST_LISTENED},
|
||||
@@ -56,7 +50,7 @@ export class DashboardSettingsComponent {
|
||||
|
||||
readonly sortFieldOptions = computed(() => {
|
||||
this.activeLanguage();
|
||||
const t = (key: string) => this.translocoService.translate(`dashboard.settings.${key}`);
|
||||
const t = (key: string) => this.translocoService.translate(`settingsView.dashboardScrollers.${key}`);
|
||||
return [
|
||||
{label: t('sortFields.title'), value: 'title'},
|
||||
{label: t('sortFields.fileName'), value: 'fileName'},
|
||||
@@ -80,7 +74,7 @@ export class DashboardSettingsComponent {
|
||||
|
||||
readonly sortDirectionOptions = computed(() => {
|
||||
this.activeLanguage();
|
||||
const t = (key: string) => this.translocoService.translate(`dashboard.settings.${key}`);
|
||||
const t = (key: string) => this.translocoService.translate(`settingsView.dashboardScrollers.${key}`);
|
||||
return [
|
||||
{label: t('sortDirections.asc'), value: 'asc'},
|
||||
{label: t('sortDirections.desc'), value: 'desc'}
|
||||
@@ -106,6 +100,8 @@ export class DashboardSettingsComponent {
|
||||
|
||||
readonly MIN_ITEMS = MIN_ITEMS;
|
||||
readonly MAX_ITEMS = MAX_ITEMS;
|
||||
readonly MAX_SCROLLERS = MAX_SCROLLERS;
|
||||
readonly ScrollerType = ScrollerType;
|
||||
|
||||
private readonly syncConfigEffect = effect(() => {
|
||||
this.config = structuredClone(this.configService.config());
|
||||
@@ -188,15 +184,15 @@ export class DashboardSettingsComponent {
|
||||
scroller.title = this.getScrollerTitle(scroller);
|
||||
});
|
||||
this.configService.saveConfig(this.config);
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
this.dialogRef.close();
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.translocoService.translate('settingsView.dashboardScrollers.saveSuccess'),
|
||||
detail: this.translocoService.translate('settingsView.dashboardScrollers.saveSuccessDetail'),
|
||||
life: 1500,
|
||||
});
|
||||
}
|
||||
|
||||
resetToDefault(): void {
|
||||
this.configService.resetToDefault();
|
||||
this.dialogRef.close();
|
||||
}
|
||||
}
|
||||
+2
@@ -12,6 +12,8 @@
|
||||
|
||||
<app-display-preferences></app-display-preferences>
|
||||
<div class="section-divider"><hr></div>
|
||||
<app-dashboard-preferences></app-dashboard-preferences>
|
||||
<div class="section-divider"><hr></div>
|
||||
<app-view-preferences></app-view-preferences>
|
||||
<div class="section-divider"><hr></div>
|
||||
<app-filter-preferences></app-filter-preferences>
|
||||
|
||||
+2
@@ -7,6 +7,7 @@ import {SidebarSortingPreferencesComponent} from './sidebar-sorting-preferences/
|
||||
import {MetaCenterViewModeComponent} from './meta-center-view-mode/meta-center-view-mode-component';
|
||||
import {FilterPreferencesComponent} from './filter-preferences/filter-preferences.component';
|
||||
import {DisplayPreferencesComponent} from './display-preferences/display-preferences.component';
|
||||
import {DashboardPreferencesComponent} from './dashboard-preferences/dashboard-preferences.component';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Slider} from 'primeng/slider';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -23,6 +24,7 @@ import {LayoutService, SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH} from '../../../shar
|
||||
MetaCenterViewModeComponent,
|
||||
FilterPreferencesComponent,
|
||||
DisplayPreferencesComponent,
|
||||
DashboardPreferencesComponent,
|
||||
TranslocoDirective,
|
||||
Slider,
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user