Browse Source

feat(lib): change isLoading to a computed field

pull/6301/head
KenTandrian 1 day ago
parent
commit
3d189b126c
  1. 4
      libs/ui/src/lib/accounts-table/accounts-table.component.html
  2. 9
      libs/ui/src/lib/accounts-table/accounts-table.component.ts

4
libs/ui/src/lib/accounts-table/accounts-table.component.html

@ -348,12 +348,12 @@
<tr <tr
*matFooterRowDef="displayedColumns()" *matFooterRowDef="displayedColumns()"
mat-footer-row mat-footer-row
[ngClass]="{ 'd-none': isLoading || !showFooter }" [ngClass]="{ 'd-none': isLoading() || !showFooter }"
></tr> ></tr>
</table> </table>
</div> </div>
@if (isLoading) { @if (isLoading()) {
<ngx-skeleton-loader <ngx-skeleton-loader
animation="pulse" animation="pulse"
class="px-4 py-3" class="px-4 py-3"

9
libs/ui/src/lib/accounts-table/accounts-table.component.ts

@ -73,7 +73,6 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
public dataSource = new MatTableDataSource<Account>(); public dataSource = new MatTableDataSource<Account>();
public isLoading = true;
public routeQueryParams: Subscription; public routeQueryParams: Subscription;
public readonly accounts = input.required<Account[] | undefined>(); public readonly accounts = input.required<Account[] | undefined>();
@ -118,6 +117,8 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
return columns; return columns;
}); });
protected readonly isLoading = computed(() => !this.accounts());
private readonly notificationService = inject(NotificationService); private readonly notificationService = inject(NotificationService);
private readonly router = inject(Router); private readonly router = inject(Router);
private readonly unsubscribeSubject = new Subject<void>(); private readonly unsubscribeSubject = new Subject<void>();
@ -135,16 +136,10 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
} }
public ngOnChanges() { public ngOnChanges() {
this.isLoading = true;
this.dataSource = new MatTableDataSource(this.accounts()); this.dataSource = new MatTableDataSource(this.accounts());
this.dataSource.sortingDataAccessor = getLowercase; this.dataSource.sortingDataAccessor = getLowercase;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;
if (this.accounts()) {
this.isLoading = false;
}
} }
public onDeleteAccount(aId: string) { public onDeleteAccount(aId: string) {

Loading…
Cancel
Save