Add filters and columns for hardcover rating and review count

This commit is contained in:
aditya.chandel
2025-05-31 14:32:07 -06:00
committed by Aditya Chandel
parent 4c3d9423fd
commit 8518e57d92
4 changed files with 12 additions and 6 deletions
@@ -127,6 +127,8 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
{label: 'Amazon #', icon: '', field: 'amazonReviewCount', command: () => this.sortBooks('amazonReviewCount')},
{label: 'Goodreads Rating', icon: '', field: 'goodreadsRating', command: () => this.sortBooks('goodreadsRating')},
{label: 'Goodreads #', icon: '', field: 'goodreadsReviewCount', command: () => this.sortBooks('goodreadsReviewCount')},
{label: 'Hardcover Rating', icon: '', field: 'hardcoverRating', command: () => this.sortBooks('hardcoverRating')},
{label: 'Hardcover #', icon: '', field: 'hardcoverReviewCount', command: () => this.sortBooks('hardcoverReviewCount')},
{label: 'Pages', icon: '', field: 'pageCount', command: () => this.sortBooks('pageCount')}
];
@@ -34,8 +34,8 @@
<th>Amz #</th>
<th>Goodreads</th>
<th>GR #</th>
<th>Rating (L)</th>
<th>Reviews (L)</th>
<th>Hardcover</th>
<th>HC #</th>
</tr>
</ng-template>
<ng-template #body let-book>
@@ -109,15 +109,15 @@
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
<span class="flex items-center gap-1">
<p-rating
[(ngModel)]="metadata.rating"
[(ngModel)]="metadata.hardcoverRating"
readonly
stars="5"
[style.--p-rating-icon-active-color]="getStarColor(metadata.rating)">
[style.--p-rating-icon-active-color]="getStarColor(metadata.hardcoverRating)">
</p-rating>
<span *ngIf="metadata.rating != null">({{ metadata.rating?.toFixed(1) }})</span>
<span *ngIf="metadata.hardcoverRating != null">({{ metadata.hardcoverRating?.toFixed(1) }})</span>
</span>
</td>
<td class="min-w-[3rem] max-w-[3rem] overflow-hidden truncate">{{ metadata.reviewCount }}</td>
<td class="min-w-[6rem] max-w-[6rem] overflow-hidden truncate">{{ metadata.hardcoverReviewCount }}</td>
</tr>
</ng-template>
</p-table>
@@ -28,6 +28,8 @@ export class SortService {
amazonReviewCount: (book) => book.metadata?.amazonReviewCount || null,
goodreadsRating: (book) => book.metadata?.goodreadsRating || null,
goodreadsReviewCount: (book) => book.metadata?.goodreadsReviewCount || null,
hardcoverRating: (book) => book.metadata?.hardcoverRating || null,
hardcoverReviewCount: (book) => book.metadata?.hardcoverReviewCount || null,
locked: (book) =>
Object.keys(book.metadata ?? {})
.filter((key) => key.endsWith('Locked'))
@@ -43,6 +43,8 @@ export class ViewPreferencesComponent implements OnInit {
{label: 'Amazon #', field: 'amazonReviewCount'},
{label: 'Goodreads Rating', field: 'goodreadsRating'},
{label: 'Goodreads #', field: 'goodreadsReviewCount'},
{label: 'Hardcover Rating', field: 'hardcoverRating'},
{label: 'Hardcover #', field: 'hardcoverReviewCount'},
{label: 'Pages', field: 'pageCount'}
];