From 2faa60c307316e2e5ae8098446aa2549e8f6b856 Mon Sep 17 00:00:00 2001
From: Anish Kr Singh <116036738+anishfyle@users.noreply.github.com>
Date: Mon, 14 Nov 2022 13:18:01 +0530
Subject: [PATCH] Org link and '-' instead of 0 (#32)
* enable links for org in table-view
* Code Refactor
---
cypress/coverage/coverage-summary.json | 2 +-
.../client-table/client-table.component.html | 22 ++++++++++---------
.../client-table.component.spec.ts | 4 ++++
.../client-table/client-table.component.ts | 13 +++++++++--
4 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/cypress/coverage/coverage-summary.json b/cypress/coverage/coverage-summary.json
index ef1ae37..8035454 100644
--- a/cypress/coverage/coverage-summary.json
+++ b/cypress/coverage/coverage-summary.json
@@ -1,2 +1,2 @@
-{"total": {"lines":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"statements":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"functions":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"branches":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
+{"total": {"lines":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"statements":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"functions":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"},"branches":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
}
diff --git a/src/app/shared/components/home/client-table/client-table.component.html b/src/app/shared/components/home/client-table/client-table.component.html
index 9c34981..64cbdcf 100644
--- a/src/app/shared/components/home/client-table/client-table.component.html
+++ b/src/app/shared/components/home/client-table/client-table.component.html
@@ -45,14 +45,16 @@
- {{ client.name }}
+
+ {{ client.name }}
+
- {{ client.billed_users_count }}
+ {{ client.billed_users_count === 0 ? '-' : client.billed_users_count }}
|
- {{ client.enabled_users_count }}
-
+ {{ client.enabled_users_count === 0 ? '-' : client.enabled_users_count }}
+
View
@@ -60,8 +62,8 @@
|
- {{ client.pending_users_count }}
-
+ {{ client.pending_users_count === 0 ? '-' : client.pending_users_count }}
+
View
@@ -69,8 +71,8 @@
|
- {{ client.incomplete_expenses_count }}
-
+ {{ client.incomplete_expenses_count === 0 ? '-' : client.incomplete_expenses_count }}
+
View
@@ -78,8 +80,8 @@
|
- {{ client.approval_pending_reports_count }}
-
+ {{ client.approval_pending_reports_count === 0 ? '-' : client.approval_pending_reports_count }}
+
View
diff --git a/src/app/shared/components/home/client-table/client-table.component.spec.ts b/src/app/shared/components/home/client-table/client-table.component.spec.ts
index 66ae8ef..bac686e 100644
--- a/src/app/shared/components/home/client-table/client-table.component.spec.ts
+++ b/src/app/shared/components/home/client-table/client-table.component.spec.ts
@@ -43,6 +43,10 @@ describe('ClientTableComponent', () => {
expect(component).toBeTruthy();
});
+ it('should open org in Fyle', () => {
+ expect(component.openOrg('dummy_org_id')).toBeUndefined();
+ });
+
it('should show/hide View button for table rows', () => {
const client = clientOrgResponse.data[0];
expect(component.showOrHideViewInFyle(client, true));
diff --git a/src/app/shared/components/home/client-table/client-table.component.ts b/src/app/shared/components/home/client-table/client-table.component.ts
index e63f6a3..c366d3a 100644
--- a/src/app/shared/components/home/client-table/client-table.component.ts
+++ b/src/app/shared/components/home/client-table/client-table.component.ts
@@ -1,9 +1,11 @@
import { Component, EventEmitter, HostListener, Input, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
-import { ClientRedirectionType } from 'src/app/core/models/enum/enum.model';
+import { ClientRedirectionType, RedirectLink } from 'src/app/core/models/enum/enum.model';
import { Client, PageScroll, TableColumn } from 'src/app/core/models/home/client.model';
import { HomeService } from 'src/app/core/services/home/home.service';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
+import { environment } from 'src/environments/environment';
+import { WindowService } from 'src/app/core/services/core/window.service';
@Component({
selector: 'app-client-table',
@@ -68,7 +70,8 @@ export class ClientTableComponent implements OnInit {
constructor(
private homeService: HomeService,
- private trackingService: TrackingService
+ private trackingService: TrackingService,
+ private windowService: WindowService
) { }
onWindowScroll(event: any) {
@@ -90,6 +93,12 @@ export class ClientTableComponent implements OnInit {
client.showViewinFyle = isRowHovered;
}
+ openOrg(org_id: string): void {
+ const url = `${environment.fyle_app_url}${RedirectLink.FYLE_ADMIN}?org_id=${org_id}`;
+ this.trackingService.onClickViewEvent(ClientRedirectionType.FYLE_ADMIN);
+ this.windowService.openInNewTab(url);
+ }
+
redirect(clientRedirectionType: ClientRedirectionType, org_id: string): void {
this.trackingService.onClickViewEvent(clientRedirectionType);
this.homeService.redirect(clientRedirectionType, org_id);
|