change behavior of book card component to also show actual hyperlinks on the read button (#3192)
This commit is contained in:
+2
-2
@@ -39,10 +39,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if (!_isSeriesViewActive && hasDigitalFile()) {
|
@if (!_isSeriesViewActive && hasDigitalFile()) {
|
||||||
<p-button [rounded]="true" [icon]="readButtonIcon" class="read-btn" (click)="readBook(book)"
|
<a [routerLink]="urlHelper.getBookPrimaryReadingUrl(book)" (click)="readBook(book)"><p-button [rounded]="true" [icon]="readButtonIcon" class="read-btn" (click)="readBook(book)"
|
||||||
[pTooltip]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : ''"
|
[pTooltip]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : ''"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
[ariaLabel]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : (_isAudiobook ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco))"></p-button>
|
[ariaLabel]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : (_isAudiobook ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco))"></p-button></a>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (isCheckboxEnabled) {
|
@if (isCheckboxEnabled) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {AuthService} from './auth.service';
|
|||||||
import {BookService} from '../../features/book/service/book.service';
|
import {BookService} from '../../features/book/service/book.service';
|
||||||
import {CoverGeneratorComponent} from '../components/cover-generator/cover-generator.component';
|
import {CoverGeneratorComponent} from '../components/cover-generator/cover-generator.component';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {Book} from '../../features/book/model/book.model';
|
import {Book,BookType} from '../../features/book/model/book.model';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -119,6 +119,41 @@ export class UrlHelperService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBookPrimaryReadingUrl(book: Book) {
|
||||||
|
const bookType: BookType | undefined = book.primaryFile?.bookType;
|
||||||
|
|
||||||
|
let baseUrl: string | null = null;
|
||||||
|
|
||||||
|
switch (bookType) {
|
||||||
|
case 'PDF':
|
||||||
|
baseUrl = 'pdf-reader';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'EPUB':
|
||||||
|
case 'FB2':
|
||||||
|
case 'MOBI':
|
||||||
|
case 'AZW3':
|
||||||
|
baseUrl = 'ebook-reader';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'CBX':
|
||||||
|
baseUrl = 'cbx-reader';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'AUDIOBOOK':
|
||||||
|
baseUrl = 'audiobook-player';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!baseUrl) {
|
||||||
|
console.error('Unsupported book type:', bookType);
|
||||||
|
//Go to book URL as a fall-back
|
||||||
|
return this.getBookUrl(book);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.router.createUrlTree([`/${baseUrl}/book/${book.id}`], undefined);
|
||||||
|
}
|
||||||
|
|
||||||
filterBooksBy(filterKey: string, filterValue: string) {
|
filterBooksBy(filterKey: string, filterValue: string) {
|
||||||
if (filterKey === 'series') {
|
if (filterKey === 'series') {
|
||||||
return this.router.createUrlTree(['/series', encodeURIComponent(filterValue)])
|
return this.router.createUrlTree(['/series', encodeURIComponent(filterValue)])
|
||||||
|
|||||||
Reference in New Issue
Block a user