Migrate existing control flow directives to use new control-flow schematic

This commit is contained in:
aditya.chandel
2025-06-05 18:18:10 -06:00
committed by Aditya Chandel
parent 246efdaa34
commit 0f852ef068
86 changed files with 2567 additions and 2173 deletions
@@ -2,35 +2,47 @@
<div class="flex flex-col flex-grow">
<div class="flex justify-between items-center p-2 rounded-t-xl mb-4 bg-[var(--card-background)]">
<div class="flex items-center pl-2">
<ng-container *ngIf="entityType$ | async as entityType">
<p *ngIf="entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
{{ entityType }}: {{ (entity$ | async)?.name }}
</p>
<p *ngIf="entityType === EntityType.ALL_BOOKS" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
All Books
</p>
<p *ngIf="entityType === EntityType.UNSHELVED" class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
Unshelved Books
</p>
<div *ngIf="userService.userState$ | async as userData">
<div *ngIf="entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED && (userData.permissions.admin || userData.permissions.canManipulateLibrary) ">
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
@if (entityType$ | async; as entityType) {
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
{{ entityType }}: {{ (entity$ | async)?.name }}
</p>
}
@if (entityType === EntityType.ALL_BOOKS) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
All Books
</p>
}
@if (entityType === EntityType.UNSHELVED) {
<p class="text-2xl whitespace-nowrap overflow-hidden text-ellipsis">
Unshelved Books
</p>
}
@if (userService.userState$ | async; as userData) {
<div>
@if (entityType !== EntityType.ALL_BOOKS && entityType !== EntityType.UNSHELVED && (userData.permissions.admin || userData.permissions.canManipulateLibrary) ) {
<div>
<p-button icon="pi pi-ellipsis-v" [rounded]="true" [text]="true" severity="info" (click)="entitymenu.toggle($event)"></p-button>
<p-menu #entitymenu [model]="entityOptions" [popup]="true" appendTo="body"></p-menu>
</div>
}
</div>
</div>
</ng-container>
}
}
</div>
<div class="flex items-center gap-8">
<div class="flex flex-row items-center gap-6">
<a *ngIf="isFilterActive" class="topbar-items topbar-item" (click)="clearFilter()">
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
</i>
</a>
@if (isFilterActive) {
<a class="topbar-items topbar-item" (click)="clearFilter()">
<i
class="pi pi-filter-slash"
pTooltip="Clear applied filters"
tooltipPosition="top">
</i>
</a>
}
<div>
<a
@@ -38,7 +50,7 @@
(click)="sizeOverlay.toggle($event)"
pTooltip="Adjust grid item scale"
tooltipPosition="top"
>
>
<i class="pi pi-th-large"></i>
</a>
@@ -71,7 +83,9 @@
<ng-template pTemplate="item" let-item>
<div class="flex justify-between items-center px-4 py-2 cursor-pointer" (click)="sortBooks(item.field)">
<span>{{ item.label }}</span>
<i *ngIf="item.icon" [class]="item.icon"></i>
@if (item.icon) {
<i [class]="item.icon"></i>
}
</div>
</ng-template>
</p-menu>
@@ -96,16 +110,17 @@
[(ngModel)]="bookTitle"
(ngModelChange)="onSearchTermChange($event)"
class="search-input"
/>
<p-button
*ngIf="bookTitle"
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2"
(click)="clearSearch()">
</p-button>
/>
@if (bookTitle) {
<p-button
icon="pi pi-times"
[text]="true"
size="small"
[rounded]="true"
class="absolute right-2 top-1/2 -translate-y-1/2"
(click)="clearSearch()">
</p-button>
}
</div>
</p-fluid>
@@ -121,100 +136,118 @@
</div>
</div>
<div *ngIf="bookState$ | async as bookState">
<div *ngIf="!bookState?.loaded && !bookState?.error">
<p-progressSpinner></p-progressSpinner>
</div>
<div class="relative">
<div class="no-books-container" *ngIf="bookState?.error">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
<div class="no-books-container" *ngIf="!bookState?.error && bookState?.loaded && bookState?.books?.length === 0">
<p class="no-books-text">
This collection has no books!
</p>
</div>
<div class="book-card-container" *ngIf="bookState?.books as books">
<app-book-table *ngIf="currentViewMode === 'table' && books.length > 0" [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort!"></app-book-table>
<virtual-scroller *ngIf="currentViewMode === 'grid'" class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fit, minmax(' + gridColumnMinWidth + ', 1fr))'}">
<div
class="virtual-scroller-item"
*ngFor="let book of scroll.viewPortItems"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
@if (bookState$ | async; as bookState) {
<div>
@if (!bookState?.loaded && !bookState?.error) {
<div>
<p-progressSpinner></p-progressSpinner>
</div>
}
<div class="relative">
@if (bookState?.error) {
<div class="no-books-container">
<p class="no-books-text">
{{ entityType === EntityType.LIBRARY ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
</p>
</div>
}
@if (!bookState?.error && bookState?.loaded && bookState?.books?.length === 0) {
<div class="no-books-container">
<p class="no-books-text">
This collection has no books!
</p>
</div>
}
@if (bookState?.books; as books) {
<div class="book-card-container">
@if (currentViewMode === 'table' && books.length > 0) {
<app-book-table [books]="books" (selectedBooksChange)="onSelectedBooksChange($event)"
[sortOption]="selectedSort!"></app-book-table>
}
@if (currentViewMode === 'grid') {
<virtual-scroller class="virtual-scroller" #scroll [items]="books">
<div
class="grid"
#container
[ngStyle]="{'grid-template-columns': 'repeat(auto-fit, minmax(' + gridColumnMinWidth + ', 1fr))'}">
@for (book of scroll.viewPortItems; track book) {
<div
class="virtual-scroller-item"
[ngStyle]="{width: currentCardSize.width + 'px', height: currentCardSize.height + 'px'}">
<app-book-card
[book]="book"
[isCheckboxEnabled]="true"
[onBookSelect]="handleBookSelect.bind(this)"
[isSelected]="selectedBooks.has(book.id)">
</app-book-card>
</div>
}
</div>
</virtual-scroller>
}
</div>
}
@if (selectedBooks.size > 0) {
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" [@slideInOut]>
<div class="flex justify-between gap-8">
@if (entityType$ | async; as entityType) {
@if (entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED) {
<p-button
icon="pi pi-bookmark-fill"
outlined="true"
severity="info"
(onClick)="openShelfAssigner()"
pTooltip="Assign to shelf"
tooltipPosition="top">
</p-button>
}
@if (entityType === EntityType.SHELF) {
<p-button
icon="pi pi-bookmark"
outlined="true"
severity="info"
(click)="unshelfBooks()"
pTooltip="Remove from shelf"
tooltipPosition="top">
</p-button>
}
@if (userService.userState$ | async; as userData) {
<div>
@if (userData.permissions.canEditMetadata) {
<p-button
icon="pi pi-database"
outlined="true"
severity="info"
(click)="updateMetadata()"
pTooltip="Update metadata"
tooltipPosition="top">
</p-button>
}
</div>
}
<p-button
outlined="true"
icon="pi pi-lock"
severity="info"
(click)="lockUnlockMetadata()"
pTooltip="Lock/Unlock metadata"
tooltipPosition="top">
</p-button>
<p-button
outlined="true"
icon="pi pi-times"
severity="warn"
(click)="deselectAllBooks()"
pTooltip="Deselect all books"
tooltipPosition="top">
</p-button>
}
</div>
</div>
</virtual-scroller>
</div>
<div class="book-browser-footer bg-[var(--card-background)] bg-opacity-10" *ngIf="selectedBooks.size > 0" [@slideInOut]>
<div class="flex justify-between gap-8">
<ng-container *ngIf="entityType$ | async as entityType">
<p-button
*ngIf="entityType === EntityType.LIBRARY || entityType === EntityType.ALL_BOOKS || entityType === EntityType.UNSHELVED"
icon="pi pi-bookmark-fill"
outlined="true"
severity="info"
(onClick)="openShelfAssigner()"
pTooltip="Assign to shelf"
tooltipPosition="top">
</p-button>
<p-button
*ngIf="entityType === EntityType.SHELF"
icon="pi pi-bookmark"
outlined="true"
severity="info"
(click)="unshelfBooks()"
pTooltip="Remove from shelf"
tooltipPosition="top">
</p-button>
<div *ngIf="userService.userState$ | async as userData">
<p-button
*ngIf="userData.permissions.canEditMetadata"
icon="pi pi-database"
outlined="true"
severity="info"
(click)="updateMetadata()"
pTooltip="Update metadata"
tooltipPosition="top">
</p-button>
</div>
<p-button
outlined="true"
icon="pi pi-lock"
severity="info"
(click)="lockUnlockMetadata()"
pTooltip="Lock/Unlock metadata"
tooltipPosition="top">
</p-button>
<p-button
outlined="true"
icon="pi pi-times"
severity="warn"
(click)="deselectAllBooks()"
pTooltip="Deselect all books"
tooltipPosition="top">
</p-button>
</ng-container>
</div>
}
</div>
</div>
</div>
}
</div>
<app-book-filter [entity$]="entity$" [entityType$]="entityType$" [resetFilter$]="resetFilterSubject"></app-book-filter>