Skip to content

Commit 787b4c1

Browse files
jessewashburndogi
andauthored
teams: smoother finances loading message (fixes #9085) (#9092)
Co-authored-by: dogi <[email protected]>
1 parent 40eb1cc commit 787b4c1

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "planet",
33
"license": "AGPL-3.0",
4-
"version": "0.20.29",
4+
"version": "0.20.30",
55
"myplanet": {
66
"latest": "v0.32.3",
77
"min": "v0.31.3"

src/app/community/community.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<planet-community-list></planet-community-list>
101101
</mat-tab>
102102
<mat-tab i18n-label label="Finances" *ngIf="isLoggedIn">
103-
<planet-teams-view-finances [finances]="finances" [team]="team" (financesChanged)="dataChanged()" [editable]="isCommunityLeader && !planetCode"></planet-teams-view-finances>
103+
<planet-teams-view-finances [finances]="finances" [isLoading]="financesLoading" [team]="team" (financesChanged)="dataChanged()" [editable]="isCommunityLeader && !planetCode"></planet-teams-view-finances>
104104
</mat-tab>
105105
<mat-tab i18n-label label="Reports" *ngIf="isLoggedIn">
106106
<planet-teams-reports [reports]="reports" [editable]="isCommunityLeader && !planetCode" [team]="team" (reportsChanged)="dataChanged()"></planet-teams-reports>

src/app/community/community.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class CommunityComponent implements OnInit, OnDestroy {
4747
filteredNews: any[] = [];
4848
links: any[] = [];
4949
finances: any[] = [];
50+
financesLoading = false;
5051
councillors: any[] = [];
5152
reports: any[] = [];
5253
showNewsButton = true;
@@ -192,6 +193,7 @@ export class CommunityComponent implements OnInit, OnDestroy {
192193
this.team = this.teamObject(this.planetCode);
193194
this.teamId = this.team._id;
194195
this.requestNewsAndUsers(this.planetCode);
196+
this.financesLoading = true;
195197
return this.getLinks(this.planetCode);
196198
}),
197199
switchMap((res) => {
@@ -301,6 +303,7 @@ export class CommunityComponent implements OnInit, OnDestroy {
301303
this.deleteMode = this.deleteMode && this.links.length !== 0;
302304
this.finances = finances;
303305
this.reports = reports;
306+
this.financesLoading = false;
304307
}
305308

306309
dataChanged() {

src/app/teams/teams-view-finances.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<mat-card class="margin-lr" *ngIf="showBalanceWarning">
2222
<div class="warning-container"><mat-icon color="accent">warning</mat-icon><span i18n>The current balance is negative!</span></div>
2323
</mat-card>
24+
<ng-container *ngIf="!isLoading; else loadingTpl">
2425
<mat-table [dataSource]="table" *ngIf="!emptyTable; else emptyMessage">
2526
<ng-container matColumnDef="date">
2627
<mat-header-cell *matHeaderCellDef class="narrow-column" i18n>Date</mat-header-cell>
@@ -53,7 +54,11 @@
5354
</ng-container>
5455
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
5556
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
56-
</mat-table>
57+
</mat-table>
58+
</ng-container>
59+
<ng-template #loadingTpl>
60+
<p i18n>Loading transactions...</p>
61+
</ng-template>
5762
<ng-template #emptyMessage>
5863
<p i18n>There are no transactions</p>
5964
</ng-template>

src/app/teams/teams-view-finances.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class TeamsViewFinancesComponent implements OnInit, OnChanges {
2424
@Input() team: any = {};
2525
@Input() getMembers;
2626
@Input() editable = true;
27+
@Input() isLoading = false;
2728
@Output() financesChanged = new EventEmitter<void>();
2829
table = new MatTableDataSource<any>();
2930
displayedColumns = [ 'date', 'description', 'credit', 'debit', 'balance' ];
@@ -59,16 +60,17 @@ export class TeamsViewFinancesComponent implements OnInit, OnChanges {
5960
if (transactions.length > 0 && transactions[0].filter !== this.filterString()) {
6061
transactions[0] = this.setTransactionsTable(transactions)[0];
6162
}
62-
this.showBalanceWarning = (this.finances && this.finances.length) === (this.table.filteredData.length - 1) &&
63-
transactions[0].balance < 0;
63+
const hasRows = this.table.filteredData && this.table.filteredData.length > 0;
64+
this.showBalanceWarning = hasRows && (this.finances && this.finances.length) === (this.table.filteredData.length - 1) &&
65+
this.table.filteredData[0].balance < 0;
6466
});
6567
}
6668

6769
ngOnChanges() {
6870
if (this.editable !== this.displayedColumns.indexOf('action') > -1) {
6971
this.displayedColumns = [ ...this.displayedColumns, this.editable ? 'action' : [] ].flat();
7072
}
71-
if (this.finances) {
73+
if (!this.isLoading && this.finances) {
7274
this.table.data = this.setTransactionsTable(this.finances);
7375
}
7476
}

src/app/teams/teams-view.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ <h4 i18n>Members ({{members.length}})</h4>
161161
<ng-template mat-tab-label>
162162
<ng-container i18n>Finances</ng-container> ({{ financesCount }})
163163
</ng-template>
164-
<planet-teams-view-finances [finances]="finances" [team]="team" [getMembers]="getMembers" (financesChanged)="resetData()" [editable]="userStatus === 'member'"></planet-teams-view-finances>
164+
<planet-teams-view-finances [isLoading]="financesLoading" [finances]="finances" [team]="team" [getMembers]="getMembers" (financesChanged)="resetData()" [editable]="userStatus === 'member'"></planet-teams-view-finances>
165165
</mat-tab>
166166
</ng-container>
167167
<mat-tab *ngIf="mode==='enterprise'" i18n-label label="Reports">

src/app/teams/teams-view.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class TeamsViewComponent implements OnInit, AfterViewChecked, OnDestroy {
5959
readonly dbName = 'teams';
6060
leaderDialog: any;
6161
finances: any[] = [];
62+
financesLoading = true;
6263
reports: any[] = [];
6364
tasks: any[];
6465
tabSelectedIndex = 0;
@@ -195,8 +196,10 @@ export class TeamsViewComponent implements OnInit, AfterViewChecked, OnDestroy {
195196

196197
getMembers() {
197198
if (this.team === undefined) {
199+
this.financesLoading = false;
198200
return of([]);
199201
}
202+
this.financesLoading = true;
200203
return this.teamsService.getTeamMembers(this.team, true).pipe(switchMap((docs: any[]) => {
201204
const src = (member) => {
202205
const { attachmentDoc, userId, userPlanetCode, userDoc } = member;
@@ -220,7 +223,7 @@ export class TeamsViewComponent implements OnInit, AfterViewChecked, OnDestroy {
220223
this.setStatus(this.team, this.leader, this.userService.get());
221224
this.setTasks(this.tasks);
222225
return this.teamsService.getTeamResources(docs.filter(doc => doc.docType === 'resourceLink'));
223-
}), map(resources => this.resources = resources));
226+
}), map(resources => this.resources = resources), finalize(() => this.financesLoading = false));
224227
}
225228

226229
setTasks(tasks = []) {

0 commit comments

Comments
 (0)