Add read status icons to book card and book browser table (#1149)
This commit is contained in:
@@ -71,10 +71,17 @@
|
||||
|
||||
<div [hidden]="bottomBarHidden">
|
||||
<div class="book-title-container flex items-center">
|
||||
@if (shouldShowStatusIcon()) {
|
||||
<div class="read-status-indicator"
|
||||
[ngClass]="getReadStatusClass()"
|
||||
[pTooltip]="'Status: ' + getReadStatusTooltip()"
|
||||
tooltipPosition="bottom">
|
||||
<i [class]="getReadStatusIcon()"></i>
|
||||
</div>
|
||||
}
|
||||
<h4 class="book-title m-0 pl-2"
|
||||
tooltipPosition="bottom"
|
||||
tooltipStyleClass="text-xs text-center"
|
||||
[pTooltip]="displayTitle">
|
||||
[pTooltip]="'Title: ' + displayTitle">
|
||||
{{ displayTitle }}
|
||||
</h4>
|
||||
<p-tieredmenu #menu [model]="items" [popup]="true" appendTo="body"></p-tieredmenu>
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
transition: opacity 0.2s ease, visibility 0.2s ease;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.select-checkbox .p-checkbox {
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -174,6 +175,42 @@
|
||||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.read-status-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: bold;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.status-read {
|
||||
color: #22c55e;
|
||||
}
|
||||
|
||||
.status-reading {
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
.status-re-reading {
|
||||
color: #06b6d4;
|
||||
}
|
||||
|
||||
.status-partially-read {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.status-paused {
|
||||
color: #eab308;
|
||||
}
|
||||
|
||||
.status-abandoned {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.status-wont-read {
|
||||
color: #ec4899;
|
||||
}
|
||||
|
||||
::ng-deep .progress-incomplete .p-progressbar-value {
|
||||
background-color: #3b82f6;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import {BookMetadataCenterComponent} from '../../../../metadata/book-metadata-ce
|
||||
import {take, takeUntil} from 'rxjs/operators';
|
||||
import {readStatusLabels} from '../book-filter/book-filter.component';
|
||||
import {ResetProgressTypes} from '../../../../shared/constants/reset-progress-type';
|
||||
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-card',
|
||||
@@ -66,6 +67,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
private userPermissions: any;
|
||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||
private destroy$ = new Subject<void>();
|
||||
protected readStatusHelper = inject(ReadStatusHelper);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userService.userState$
|
||||
@@ -717,4 +719,20 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
getReadStatusIcon(): string {
|
||||
return this.readStatusHelper.getReadStatusIcon(this.book.readStatus);
|
||||
}
|
||||
|
||||
getReadStatusClass(): string {
|
||||
return this.readStatusHelper.getReadStatusClass(this.book.readStatus);
|
||||
}
|
||||
|
||||
getReadStatusTooltip(): string {
|
||||
return this.readStatusHelper.getReadStatusTooltip(this.book.readStatus);
|
||||
}
|
||||
|
||||
shouldShowStatusIcon(): boolean {
|
||||
return this.readStatusHelper.shouldShowStatusIcon(this.book.readStatus);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -53,7 +53,18 @@
|
||||
</td>
|
||||
|
||||
@for (col of visibleColumns; track col.field) {
|
||||
@if (col.field === 'amazonRating' || col.field === 'goodreadsRating' || col.field === 'hardcoverRating') {
|
||||
@if (col.field === 'readStatus') {
|
||||
<td class="text-center min-w-[4rem] max-w-[4rem]">
|
||||
@if (shouldShowStatusIcon(book.readStatus)) {
|
||||
<div class="read-status-indicator"
|
||||
[ngClass]="getReadStatusClass(book.readStatus)"
|
||||
[pTooltip]="'Status: ' + getReadStatusTooltip(book.readStatus)"
|
||||
tooltipPosition="top">
|
||||
<i [class]="getReadStatusIcon(book.readStatus)"></i>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
} @else if (col.field === 'amazonRating' || col.field === 'goodreadsRating' || col.field === 'hardcoverRating') {
|
||||
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
|
||||
<span class="flex items-center gap-1">
|
||||
<p-rating
|
||||
|
||||
@@ -1 +1,38 @@
|
||||
.read-status-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 0.875rem;
|
||||
font-weight: bold;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.status-read {
|
||||
color: #22c55e;
|
||||
}
|
||||
|
||||
.status-reading {
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
.status-re-reading {
|
||||
color: #06b6d4;
|
||||
}
|
||||
|
||||
.status-partially-read {
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.status-paused {
|
||||
color: #eab308;
|
||||
}
|
||||
|
||||
.status-abandoned {
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.status-wont-read {
|
||||
color: #ec4899;
|
||||
}
|
||||
|
||||
+26
-3
@@ -1,10 +1,10 @@
|
||||
import {Component, EventEmitter, inject, Input, OnChanges, OnDestroy, OnInit, Output} from '@angular/core';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {DatePipe} from '@angular/common';
|
||||
import {DatePipe, NgClass} from '@angular/common';
|
||||
import {Rating} from 'primeng/rating';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {TooltipModule} from "primeng/tooltip";
|
||||
import {Book, BookMetadata} from '../../../model/book.model';
|
||||
import {Book, BookMetadata, ReadStatus} from '../../../model/book.model';
|
||||
import {SortOption} from '../../../model/sort.model';
|
||||
import {UrlHelperService} from '../../../../utilities/service/url-helper.service';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -16,6 +16,7 @@ import {UserService} from '../../../../settings/user-management/user.service';
|
||||
import {BookMetadataCenterComponent} from '../../../../metadata/book-metadata-center-component/book-metadata-center.component';
|
||||
import {DialogService} from 'primeng/dynamicdialog';
|
||||
import {take, takeUntil} from 'rxjs/operators';
|
||||
import {ReadStatusHelper} from '../../../helpers/read-status.helper';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-table',
|
||||
@@ -26,7 +27,8 @@ import {take, takeUntil} from 'rxjs/operators';
|
||||
Rating,
|
||||
FormsModule,
|
||||
Button,
|
||||
TooltipModule
|
||||
TooltipModule,
|
||||
NgClass
|
||||
],
|
||||
styleUrls: ['./book-table.component.scss'],
|
||||
providers: [DatePipe]
|
||||
@@ -47,11 +49,13 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
private dialogService = inject(DialogService);
|
||||
private router = inject(Router);
|
||||
private datePipe = inject(DatePipe);
|
||||
private readStatusHelper = inject(ReadStatusHelper);
|
||||
|
||||
private metadataCenterViewMode: 'route' | 'dialog' = 'route';
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
readonly allColumns = [
|
||||
{field: 'readStatus', header: '📖'},
|
||||
{field: 'title', header: 'Title'},
|
||||
{field: 'authors', header: 'Authors'},
|
||||
{field: 'publisher', header: 'Publisher'},
|
||||
@@ -189,8 +193,27 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
return mb >= 1 ? `${mb.toFixed(1)} MB` : `${mb.toFixed(2)} MB`;
|
||||
}
|
||||
|
||||
getReadStatusIcon(readStatus: ReadStatus | undefined): string {
|
||||
return this.readStatusHelper.getReadStatusIcon(readStatus);
|
||||
}
|
||||
|
||||
getReadStatusClass(readStatus: ReadStatus | undefined): string {
|
||||
return this.readStatusHelper.getReadStatusClass(readStatus);
|
||||
}
|
||||
|
||||
getReadStatusTooltip(readStatus: ReadStatus | undefined): string {
|
||||
return this.readStatusHelper.getReadStatusTooltip(readStatus);
|
||||
}
|
||||
|
||||
shouldShowStatusIcon(readStatus: ReadStatus | undefined): boolean {
|
||||
return this.readStatusHelper.shouldShowStatusIcon(readStatus);
|
||||
}
|
||||
|
||||
getCellValue(metadata: BookMetadata, book: Book, field: string): string | number {
|
||||
switch (field) {
|
||||
case 'readStatus':
|
||||
return this.readStatusHelper.getReadStatusTooltip(book?.readStatus);
|
||||
|
||||
case 'title':
|
||||
return metadata.title ?? '';
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ export class TableColumnPreferenceService {
|
||||
readonly preferences$ = this.preferencesSubject.asObservable();
|
||||
|
||||
private readonly allAvailableColumns = [
|
||||
{field: 'readStatus', header: 'Read'},
|
||||
{field: 'title', header: 'Title'},
|
||||
{field: 'authors', header: 'Authors'},
|
||||
{field: 'publisher', header: 'Publisher'},
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
<div class="header-left">
|
||||
<p-button size="small" class="menu-toggle-button" (click)="toggleDrawer()" icon="pi pi-bars" severity="secondary"></p-button>
|
||||
<div class="progress-info">
|
||||
<span class="progress-percentage"><span class="progress-label">Progress: </span>{{ progressPercentage }}%</span>
|
||||
<span class="progress-percentage"><span class="progress-label">Progress: </span>{{ progressPercentage }}%</span>
|
||||
</div>
|
||||
<p-drawer [(visible)]="isDrawerVisible" [modal]="true" [position]="'left'" header="Chapters">
|
||||
<ul class="chapter-list">
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ReadStatus} from '../model/book.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ReadStatusHelper {
|
||||
|
||||
getReadStatusIcon(readStatus: ReadStatus | undefined): string {
|
||||
if (!readStatus) return '';
|
||||
switch (readStatus) {
|
||||
case ReadStatus.READ:
|
||||
return 'pi pi-check';
|
||||
case ReadStatus.READING:
|
||||
return 'pi pi-play';
|
||||
case ReadStatus.RE_READING:
|
||||
return 'pi pi-refresh';
|
||||
case ReadStatus.PARTIALLY_READ:
|
||||
return 'pi pi-clock';
|
||||
case ReadStatus.PAUSED:
|
||||
return 'pi pi-pause';
|
||||
case ReadStatus.ABANDONED:
|
||||
return 'pi pi-times';
|
||||
case ReadStatus.WONT_READ:
|
||||
return 'pi pi-ban';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
getReadStatusClass(readStatus: ReadStatus | undefined): string {
|
||||
if (!readStatus) return '';
|
||||
switch (readStatus) {
|
||||
case ReadStatus.READ:
|
||||
return 'status-read';
|
||||
case ReadStatus.READING:
|
||||
return 'status-reading';
|
||||
case ReadStatus.RE_READING:
|
||||
return 'status-re-reading';
|
||||
case ReadStatus.PARTIALLY_READ:
|
||||
return 'status-partially-read';
|
||||
case ReadStatus.PAUSED:
|
||||
return 'status-paused';
|
||||
case ReadStatus.ABANDONED:
|
||||
return 'status-abandoned';
|
||||
case ReadStatus.WONT_READ:
|
||||
return 'status-wont-read';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
getReadStatusTooltip(readStatus: ReadStatus | undefined): string {
|
||||
if (!readStatus) return '';
|
||||
switch (readStatus) {
|
||||
case ReadStatus.READ:
|
||||
return 'Read';
|
||||
case ReadStatus.READING:
|
||||
return 'Currently Reading';
|
||||
case ReadStatus.RE_READING:
|
||||
return 'Re-reading';
|
||||
case ReadStatus.PARTIALLY_READ:
|
||||
return 'Partially Read';
|
||||
case ReadStatus.PAUSED:
|
||||
return 'Paused';
|
||||
case ReadStatus.ABANDONED:
|
||||
return 'Abandoned';
|
||||
case ReadStatus.WONT_READ:
|
||||
return 'Won\'t Read';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
shouldShowStatusIcon(readStatus: ReadStatus | undefined): boolean {
|
||||
return !!(readStatus && readStatus !== ReadStatus.UNREAD && readStatus !== ReadStatus.UNSET);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user