Skip to content

Commit

Permalink
teams: smoother surveys count (fixes #8110) (#8122)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
jessewashburn and dogi authored Jan 22, 2025
1 parent de84231 commit aadb3da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.16.72",
"version": "0.16.73",
"myplanet": {
"latest": "v0.22.29",
"min": "v0.21.29"
Expand Down
8 changes: 6 additions & 2 deletions src/app/surveys/surveys.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy, Input } from '@angular/core';
import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { FormGroup } from '@angular/forms';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
Expand Down Expand Up @@ -34,6 +34,7 @@ export class SurveysComponent implements OnInit, AfterViewInit, OnDestroy {
surveys = new MatTableDataSource<any>();
@ViewChild(MatSort) sort: MatSort;
@ViewChild(MatPaginator) paginator: MatPaginator;
@Output() surveyCount = new EventEmitter<number>();
displayedColumns = (this.userService.doesUserHaveRole([ '_admin', 'manager' ]) ? [ 'select' ] : []).concat(
[ 'name', 'taken', 'courseTitle', 'createdDate', 'action' ]
);
Expand Down Expand Up @@ -97,7 +98,10 @@ export class SurveysComponent implements OnInit, AfterViewInit, OnDestroy {
this.dialogsLoadingService.stop();
});
this.couchService.checkAuthorization(this.dbName).subscribe((isAuthorized) => this.isAuthorized = isAuthorized);
this.surveys.connect().subscribe(surveys => this.parentCount = surveys.filter(survey => survey.parent === true).length);
this.surveys.connect().subscribe(surveys => {
this.parentCount = surveys.filter(survey => survey.parent === true).length;
this.surveyCount.emit(surveys.length);
});
}

ngAfterViewInit() {
Expand Down
5 changes: 4 additions & 1 deletion src/app/teams/teams-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ <h3 *ngIf="mode==='services'" class="margin-lr-3 ellipsis-title">{{configuration
</ng-template>
</mat-tab>
<mat-tab i18n-label label="Surveys">
<planet-surveys [teamId]="teamId"></planet-surveys>
<ng-template mat-tab-label>
<ng-container i18n>Surveys</ng-container> ({{surveysCount}})
</ng-template>
<planet-surveys [teamId]="teamId" (surveyCount)="surveysCount = $event"></planet-surveys>
</mat-tab>
<mat-tab *ngIf="mode!=='services'" #applicantTab>
<ng-template mat-tab-label>
Expand Down

0 comments on commit aadb3da

Please sign in to comment.