Skip to content

Commit

Permalink
Enable Links for Org in table-view (#27)
Browse files Browse the repository at this point in the history
* enable links for org in table-view

* table view : - instead of 0

* Removed view link for -

* Code Refactor
  • Loading branch information
anishfyle authored Nov 11, 2022
1 parent ba71719 commit 8b65fbb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,41 +45,43 @@
<svg-icon-sprite src="client" width="20px" height="20px" class="tw-text-sub-text-color">
</svg-icon-sprite>
</div>
{{ client.name }}
<p class="tw-font-500 tw-pb-4-px hover:tw-text-partner-hover tw-cursor-pointer" (click)="openOrg(client.id)">
{{ client.name }}
</p>
</td>
<td class="client-table--active-users">
{{ client.billed_users_count }}
{{ client.billed_users_count === 0 ? '-' : client.billed_users_count }}
</td>
<td class="client-table--row">
{{ client.enabled_users_count }}
<a class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.TOTAL_USERS, client.id)">
{{ client.enabled_users_count === 0 ? '-' : client.enabled_users_count }}
<a *ngIf="client.enabled_users_count !== 0" class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.TOTAL_USERS, client.id)">
View
<p class="tw-mx-8-px tw-h-16-px tw-w-1-px tw-rounded-4-px tw-bg-table-header"></p>
<svg-icon-sprite src="open-in-new-tab" width="16px" height="16px" class="tw-mt-2-px tw-text-table-row-hover tw-cursor-pointer">
</svg-icon-sprite>
</a>
</td>
<td class="client-table--row">
{{ client.pending_users_count }}
<a class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.PENDING_INVITATION, client.id)">
{{ client.pending_users_count === 0 ? '-' : client.pending_users_count }}
<a *ngIf="client.pending_users_count !== 0" class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.PENDING_INVITATION, client.id)">
View
<p class="tw-mx-8-px tw-h-16-px tw-w-1-px tw-rounded-4-px tw-bg-table-header"></p>
<svg-icon-sprite src="open-in-new-tab" width="16px" height="16px" class="tw-mt-2-px tw-text-table-row-hover tw-cursor-pointer">
</svg-icon-sprite>
</a>
</td>
<td class="client-table--row">
{{ client.incomplete_expenses_count }}
<a class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.INCOMPLETE_EXPENSES, client.id)">
{{ client.incomplete_expenses_count === 0 ? '-' : client.incomplete_expenses_count }}
<a *ngIf="client.incomplete_expenses_count !== 0" class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.INCOMPLETE_EXPENSES, client.id)">
View
<p class="tw-mx-8-px tw-h-16-px tw-w-1-px tw-rounded-4-px tw-bg-table-header"></p>
<svg-icon-sprite src="open-in-new-tab" width="16px" height="16px" class="tw-mt-2-px tw-text-table-row-hover tw-cursor-pointer">
</svg-icon-sprite>
</a>
</td>
<td class="client-table--row">
{{ client.approval_pending_reports_count }}
<a class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.REPORTS_TO_APPROVE, client.id)">
{{ client.approval_pending_reports_count === 0 ? '-' : client.approval_pending_reports_count }}
<a *ngIf="client.approval_pending_reports_count !== 0" class="client-table--redirection client-table--view-in-fyle" (click)="redirect(ClientRedirectionType.REPORTS_TO_APPROVE, client.id)">
View
<p class="tw-mx-8-px tw-h-16-px tw-w-1-px tw-rounded-4-px tw-bg-table-header"></p>
<svg-icon-sprite src="open-in-new-tab" width="16px" height="16px" class="tw-mt-2-px tw-text-table-row-hover tw-cursor-pointer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 8b65fbb

Please sign in to comment.