I have a dialog box where a user can copy a charts to different workspace card but when ever user click on selected workspace card to copy particular chart, the Chart count is not updated immediately on the selected workspace card.
The chart is copied but the chart count on the workspace card is not updated.
I can only see the chart count number change when I close the Copy Dialog and open it again.
I'll be really appreciated if I can get any suggestion or help on how I can update the chart count immediately on selected workspace card without having to close the dialog first.
Workspace Card.HTML
<div>
<span class="details ws-name" matLine>{{chartCount}} Chart{{chartCount !== 1 ? 's' : ''}}</span>
</div>
Workspace Card.TS
chartCount: number = 0;
ngOnInit(): void {
if(!this.workspace.chartCount && this.workspace.charts) {
this.chartCount = this.workspace.charts.length;
}
else {
this.chartCount = this.workspace.chartCount;
}
}
Select Workspace List.HTML
<div class="header">Copy Chart to a Workspace</div>
<mat-hint class="sub-header">Select one of the following workspaces. The chart will be automatically staged.</mat-hint>
<mat-progress-bar *ngIf="loading || copying" color="primary" mode="indeterminate"></mat-progress-bar>
<div class="list" *ngIf="!loading">
<mc-workspace-card *ngFor="let workspace of workspaces" [workspace]="workspace" [isCopyModal] = "true" (click)="copy(workspace)">
</mc-workspace-card>
</div>
Select Workspace List.TS
copy(workspace: Workspace) {
this.copying = true;
this.chartService.copyChartToWorkspace(this.chartGuid, workspace.guid).subscribe(newChart => {
this.copying = false;
this._snackBar.open(`Chart has been copied to ${workspace.name}`, 'Check it out!', { duration: 5000, panelClass: "snackbar-button" }).onAction().subscribe(() => {
this.dialogRef.close();
this.router.navigate(['workspace', workspace.guid], { state: { data: workspace.guid } });
})
})
}