Browse Source

feat(ui): implement computed signal on isLoading

pull/6295/head
KenTandrian 3 days ago
parent
commit
249e1ae7fa
  1. 18
      libs/ui/src/lib/activities-table/activities-table.component.html
  2. 10
      libs/ui/src/lib/activities-table/activities-table.component.ts

18
libs/ui/src/lib/activities-table/activities-table.component.html

@ -177,7 +177,7 @@
[deviceType]="deviceType" [deviceType]="deviceType"
[isDate]="true" [isDate]="true"
[locale]="locale" [locale]="locale"
[value]="isLoading ? undefined : element.date" [value]="isLoading() ? undefined : element.date"
/> />
</div> </div>
</td> </td>
@ -201,7 +201,7 @@
<gf-value <gf-value
[isCurrency]="true" [isCurrency]="true"
[locale]="locale" [locale]="locale"
[value]="isLoading ? undefined : element.quantity" [value]="isLoading() ? undefined : element.quantity"
/> />
</div> </div>
</td> </td>
@ -225,7 +225,7 @@
<gf-value <gf-value
[isCurrency]="true" [isCurrency]="true"
[locale]="locale" [locale]="locale"
[value]="isLoading ? undefined : element.unitPrice" [value]="isLoading() ? undefined : element.unitPrice"
/> />
</div> </div>
</td> </td>
@ -249,7 +249,7 @@
<gf-value <gf-value
[isCurrency]="true" [isCurrency]="true"
[locale]="locale" [locale]="locale"
[value]="isLoading ? undefined : element.fee" [value]="isLoading() ? undefined : element.fee"
/> />
</div> </div>
</td> </td>
@ -272,7 +272,7 @@
<gf-value <gf-value
[isCurrency]="true" [isCurrency]="true"
[locale]="locale" [locale]="locale"
[value]="isLoading ? undefined : element.value" [value]="isLoading() ? undefined : element.value"
/> />
</div> </div>
</td> </td>
@ -304,7 +304,7 @@
<gf-value <gf-value
[isCurrency]="true" [isCurrency]="true"
[locale]="locale" [locale]="locale"
[value]="isLoading ? undefined : element.valueInBaseCurrency" [value]="isLoading() ? undefined : element.valueInBaseCurrency"
/> />
</div> </div>
</td> </td>
@ -500,7 +500,7 @@
</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"
@ -514,7 +514,7 @@
<mat-paginator <mat-paginator
[length]="totalItems" [length]="totalItems"
[ngClass]="{ [ngClass]="{
'd-none': (isLoading && !totalItems) || totalItems <= pageSize 'd-none': (isLoading() && !totalItems) || totalItems <= pageSize
}" }"
[pageIndex]="pageIndex" [pageIndex]="pageIndex"
[pageSize]="pageSize" [pageSize]="pageSize"
@ -526,7 +526,7 @@
!hasActivities && !hasActivities &&
dataSource().data.length === 0 && dataSource().data.length === 0 &&
hasPermissionToCreateActivity && hasPermissionToCreateActivity &&
!isLoading !isLoading()
) { ) {
<div class="p-3 text-center"> <div class="p-3 text-center">
<gf-no-transactions-info-indicator [hasBorder]="false" /> <gf-no-transactions-info-indicator [hasBorder]="false" />

10
libs/ui/src/lib/activities-table/activities-table.component.ts

@ -26,6 +26,7 @@ import {
OnInit, OnInit,
Output, Output,
ViewChild, ViewChild,
computed,
inject, inject,
input input
} from '@angular/core'; } from '@angular/core';
@ -138,13 +139,16 @@ export class GfActivitiesTableComponent
public hasDrafts = false; public hasDrafts = false;
public hasErrors = false; public hasErrors = false;
public isAfter = isAfter; public isAfter = isAfter;
public isLoading = true;
public isUUID = isUUID; public isUUID = isUUID;
public routeQueryParams: Subscription; public routeQueryParams: Subscription;
public selectedRows = new SelectionModel<Activity>(true, []); public selectedRows = new SelectionModel<Activity>(true, []);
public readonly dataSource = input.required<MatTableDataSource<Activity>>(); public readonly dataSource = input.required<MatTableDataSource<Activity>>();
public readonly isLoading = computed(() => {
return !this.dataSource();
});
private readonly notificationService = inject(NotificationService); private readonly notificationService = inject(NotificationService);
private readonly unsubscribeSubject = new Subject<void>(); private readonly unsubscribeSubject = new Subject<void>();
@ -220,10 +224,6 @@ export class GfActivitiesTableComponent
return column !== 'nameWithSymbol'; return column !== 'nameWithSymbol';
}); });
} }
if (this.dataSource()) {
this.isLoading = false;
}
} }
public areAllRowsSelected() { public areAllRowsSelected() {

Loading…
Cancel
Save