Migrate existing control flow directives to use new control-flow schematic
This commit is contained in:
committed by
Aditya Chandel
parent
246efdaa34
commit
0f852ef068
+25
-20
@@ -1,25 +1,30 @@
|
||||
<p class="dashboard-scroller-title">{{ title }}</p>
|
||||
|
||||
<div class="dashboard-scroller-no-books" *ngIf="!books || books.length === 0">
|
||||
<p class="text-sm">
|
||||
{{ bookListType === 'lastRead' ? "You haven't read any books yet!" : "No books have been added to BookLore!" }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-scroller-infinite"
|
||||
*ngIf="books"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
#scrollContainer
|
||||
[horizontal]="true">
|
||||
|
||||
<div class="dashboard-scroller-card" *ngFor="let book of books">
|
||||
<app-book-card [book]="book" [isCheckboxEnabled]="false"></app-book-card>
|
||||
@if (!books || books.length === 0) {
|
||||
<div class="dashboard-scroller-no-books">
|
||||
<p class="text-sm">
|
||||
{{ bookListType === 'lastRead' ? "You haven't read any books yet!" : "No books have been added to BookLore!" }}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
@if (books) {
|
||||
<div class="dashboard-scroller-infinite"
|
||||
infiniteScroll
|
||||
[infiniteScrollDistance]="2"
|
||||
[infiniteScrollThrottle]="50"
|
||||
#scrollContainer
|
||||
[horizontal]="true">
|
||||
@for (book of books; track book) {
|
||||
<div class="dashboard-scroller-card">
|
||||
<app-book-card [book]="book" [isCheckboxEnabled]="false"></app-book-card>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div *ngIf=" books === null">
|
||||
<p class="text-sm">Failed to load books! :(</p>
|
||||
</div>
|
||||
@if ( books === null) {
|
||||
<div>
|
||||
<p class="text-sm">Failed to load books! :(</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
import {Component, ElementRef, Input, OnChanges, OnInit, ViewChild} from '@angular/core';
|
||||
import {BookCardComponent} from '../../../book/components/book-browser/book-card/book-card.component';
|
||||
import {InfiniteScrollDirective} from 'ngx-infinite-scroll';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
|
||||
import {ProgressSpinnerModule} from 'primeng/progressspinner';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
|
||||
@@ -11,11 +11,9 @@ import {Book} from '../../../book/model/book.model';
|
||||
styleUrls: ['./dashboard-scroller.component.scss'],
|
||||
imports: [
|
||||
InfiniteScrollDirective,
|
||||
NgForOf,
|
||||
NgIf,
|
||||
BookCardComponent,
|
||||
ProgressSpinnerModule
|
||||
],
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
export class DashboardScrollerComponent {
|
||||
|
||||
+45
-41
@@ -1,46 +1,50 @@
|
||||
<div class="dashboard-container">
|
||||
<p-progressSpinner *ngIf="(bookState$ | async)?.loaded === false" styleClass="spinner center-spinner"></p-progressSpinner>
|
||||
<div class="dashboard" *ngIf="(bookState$ | async)?.loaded === true">
|
||||
<div>
|
||||
<div class="dashboard-no-library" *ngIf="isLibrariesEmpty$ | async; else dashboardScroller">
|
||||
<div *ngIf="(userService.userState$ | async)?.permissions as permissions">
|
||||
<div *ngIf="permissions.admin || permissions.canManipulateLibrary">
|
||||
<h1 class="no-library-header">Looks like you haven't added a library yet. Let's add one!</h1>
|
||||
<p-button
|
||||
label="Add a Library"
|
||||
icon="pi pi-plus"
|
||||
styleClass="p-button-rounded p-button-outlined"
|
||||
(click)="createNewLibrary()">
|
||||
</p-button>
|
||||
@if ((bookState$ | async)?.loaded === false) {
|
||||
<p-progressSpinner styleClass="spinner center-spinner"></p-progressSpinner>
|
||||
}
|
||||
@if ((bookState$ | async)?.loaded === true) {
|
||||
<div class="dashboard">
|
||||
<div>
|
||||
@if (isLibrariesEmpty$ | async) {
|
||||
<div class="dashboard-no-library">
|
||||
@if ((userService.userState$ | async)?.permissions; as permissions) {
|
||||
<div>
|
||||
@if (permissions.admin || permissions.canManipulateLibrary) {
|
||||
<div>
|
||||
<h1 class="no-library-header">Looks like you haven't added a library yet. Let's add one!</h1>
|
||||
<p-button
|
||||
label="Add a Library"
|
||||
icon="pi pi-plus"
|
||||
styleClass="p-button-rounded p-button-outlined"
|
||||
(click)="createNewLibrary()">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
} @else {
|
||||
<app-dashboard-scroller
|
||||
[books]="lastReadBooks$ | async"
|
||||
[bookListType]="'lastRead'"
|
||||
[title]="'Last Read Books'">
|
||||
</app-dashboard-scroller>
|
||||
<div class="mb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
<app-dashboard-scroller
|
||||
[books]="latestAddedBooks$ | async"
|
||||
[title]="'Latest Added Books'">
|
||||
</app-dashboard-scroller>
|
||||
<div class="mb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
<app-dashboard-scroller
|
||||
[books]="randomBooks$ | async"
|
||||
[title]="'Discover Random Reads'">
|
||||
</app-dashboard-scroller>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ng-template #dashboardScroller>
|
||||
<app-dashboard-scroller
|
||||
[books]="lastReadBooks$ | async"
|
||||
[bookListType]="'lastRead'"
|
||||
[title]="'Last Read Books'">
|
||||
</app-dashboard-scroller>
|
||||
|
||||
<div class="mb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<app-dashboard-scroller
|
||||
[books]="latestAddedBooks$ | async"
|
||||
[title]="'Latest Added Books'">
|
||||
</app-dashboard-scroller>
|
||||
|
||||
<div class="mb-6">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<app-dashboard-scroller
|
||||
[books]="randomBooks$ | async"
|
||||
[title]="'Discover Random Reads'">
|
||||
</app-dashboard-scroller>
|
||||
</ng-template>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {LibraryService} from '../../../book/service/library.service';
|
||||
import {filter, Observable, take} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgIf} from '@angular/common';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import {DashboardScrollerComponent} from '../dashboard-scroller/dashboard-scroller.component';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {BookState} from '../../../book/model/state/book-state.model';
|
||||
@@ -20,12 +20,11 @@ import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
styleUrls: ['./main-dashboard.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
NgIf,
|
||||
DashboardScrollerComponent,
|
||||
AsyncPipe,
|
||||
Divider,
|
||||
ProgressSpinner
|
||||
],
|
||||
],
|
||||
providers: [DialogService],
|
||||
standalone: true
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user