Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

import { Component, OnInit, OnChanges, Input, OnDestroy } from '@angular/core';
import { EwvViewerService } from '../../ewv-viewer/ewv-viewer.service';
import { Subscription } from 'rxjs/Subscription';
import {
BillingProviderInfo,
ServiceLocationInfo
} from '../../ewv-viewer/ewv-viewer.model';
@Component({
selector: 'app-vendor-info',
templateUrl: './vendor-info.component.html',
styleUrls: ['../../../ewv/ewv-viewer/ewv-viewer.component.scss']
})
export class VendorInfoComponent implements OnInit, OnDestroy, OnChanges {
@Input() billingProviderInfo: BillingProviderInfo;
@Input() serviceLocationInfo: ServiceLocationInfo;
@Input() accordionId;
isServiceLine = false;

isSplitView: boolean; // This
isSplitSubscription = new Subscription(); // This

collapseState = true;

collapseStateSubscription: Subscription = new Subscription();
vendorInfoMsg = 'No Vendor Information Found';

constructor(private ewvViewerService: EwvViewerService) {}

ngOnInit() {
this.collapseStateSubscription = this.ewvViewerService
.getCollapseState()
.subscribe(state => {
this.collapseState = state;
});
}

ngOnChanges() {
this.populateData();
}

populateData() {
this.isSplitSubscription = this.ewvViewerService.isSplitView.subscribe(
data => (this.isSplitView = data)
);
for (const v in this.serviceLocationInfo) {
if (this.serviceLocationInfo[v]) {
this.isServiceLine = true;
break;
}
}
this.isServiceLine ? this.serviceLocationInfo = this.serviceLocationInfo : this.serviceLocationInfo = this.billingProviderInfo;
}

getCopyBillingProviderInformationAddressTextValue() {
let copyBillingProviderInformationAddressTextValue = '';
copyBillingProviderInformationAddressTextValue =
this.getBillingProviderInformationName() + '\r';
if (this.getBillingProviderInformationAddressOne()) {
copyBillingProviderInformationAddressTextValue +=
this.getBillingProviderInformationAddressOne() + '\r';
}

if (this.getBillingProviderInformationAddressTwo()) {
copyBillingProviderInformationAddressTextValue +=
this.getBillingProviderInformationAddressTwo() + '\r';
}

copyBillingProviderInformationAddressTextValue +=
this.getBillingProviderInformationCity() +
', ' +
this.getBillingProviderInformationState() +
' ' +
this.getBillingProviderInformationZipCode() +
'\r';
if (this.getBillingProviderInformationCountry()) {
copyBillingProviderInformationAddressTextValue += this.getBillingProviderInformationCountry();
}

return copyBillingProviderInformationAddressTextValue;
}

getCopyServiceLocationInformationAddressTextValue() {
let copyServiceLocationInformationAddressTextValue = '';

copyServiceLocationInformationAddressTextValue =
this.getServiceLocationInformationName() + '\r';
if (this.getServiceLocationInformationAddressOne()) {
copyServiceLocationInformationAddressTextValue +=
this.getServiceLocationInformationAddressOne() + '\r';
}

if (this.getServiceLocationInformationAddressTwo()) {
copyServiceLocationInformationAddressTextValue +=
this.getServiceLocationInformationAddressTwo() + '\r';
}

copyServiceLocationInformationAddressTextValue +=
this.getServiceLocationInformationCity() +
', ' +
this.getServiceLocationInformationState() +
' ' +
this.getServiceLocationInformationZipCode() +
'\r';
if (this.getServiceLocationInformationCountry()) {
copyServiceLocationInformationAddressTextValue += this.getServiceLocationInformationCountry();
}

return copyServiceLocationInformationAddressTextValue;
}

getServiceLocationInformationName() {
let name = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.name &&
this.serviceLocationInfo.name !== '\u2013\u2013\u2013'
) {
name = this.serviceLocationInfo.name;
}
return name;
}

getServiceLocationInformationAddressOne() {
let address = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.addressLineOne &&
this.serviceLocationInfo.addressLineOne !== '\u2013\u2013\u2013'
) {
address = this.serviceLocationInfo.addressLineOne;
}
return address;
}

getServiceLocationInformationAddressTwo() {
let address = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.addressLineTwo &&
this.serviceLocationInfo.addressLineTwo !== '\u2013\u2013\u2013'
) {
address = this.serviceLocationInfo.addressLineTwo;
}
return address;
}

getServiceLocationInformationCity() {
let city = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.city &&
this.serviceLocationInfo.city !== '\u2013\u2013\u2013'
) {
city = this.serviceLocationInfo.city;
}
return city;
}

getServiceLocationInformationState() {
let state = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.state &&
this.serviceLocationInfo.state !== '\u2013\u2013\u2013'
) {
state = this.serviceLocationInfo.state;
}
return state;
}

getServiceLocationInformationZipCode() {
let zipCode = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.postalCode &&
this.serviceLocationInfo.postalCode !== '\u2013\u2013\u2013'
) {
zipCode = this.serviceLocationInfo.postalCode;
}
return zipCode;
}

getServiceLocationInformationCountry() {
let country = '';
if (
this.serviceLocationInfo &&
this.serviceLocationInfo.country &&
this.serviceLocationInfo.country !== '\u2013\u2013\u2013'
) {
country = this.serviceLocationInfo.country;
}
return country;
}

getBillingProviderInformationName() {
let name = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.name &&
this.billingProviderInfo.name !== '\u2013\u2013\u2013'
) {
name = this.billingProviderInfo.name;
}
return name;
}

getBillingProviderInformationAddressOne() {
let address = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.addressLineOne &&
this.billingProviderInfo.addressLineOne !== '\u2013\u2013\u2013'
) {
address = this.billingProviderInfo.addressLineOne;
}
return address;
}

getBillingProviderInformationAddressTwo() {
let address = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.addressLineTwo &&
this.billingProviderInfo.addressLineTwo !== '\u2013\u2013\u2013'
) {
address = this.billingProviderInfo.addressLineTwo;
}
return address;
}

getBillingProviderInformationCity() {
let city = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.city &&
this.billingProviderInfo.city !== '\u2013\u2013\u2013'
) {
city = this.billingProviderInfo.city;
}
return city;
}

getBillingProviderInformationState() {
let state = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.state &&
this.billingProviderInfo.state !== '\u2013\u2013\u2013'
) {
state = this.billingProviderInfo.state;
}
return state;
}

getBillingProviderInformationZipCode() {
let zipCode = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.postalCode &&
this.billingProviderInfo.postalCode !== '\u2013\u2013\u2013'
) {
zipCode = this.billingProviderInfo.postalCode;
}
return zipCode;
}

getBillingProviderInformationCountry() {
let country = '';
if (
this.billingProviderInfo &&
this.billingProviderInfo.country &&
this.billingProviderInfo.country !== '\u2013\u2013\u2013'
) {
country = this.billingProviderInfo.country;
}
return country;
}

ngOnDestroy() {
this.collapseStateSubscription.unsubscribe();
this.isSplitSubscription.unsubscribe(); // This
}

copyStringToClipboard(stringToCopy) {
// Idea of code below came from the https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f web page.
const el = document.createElement('textarea');
el.value = stringToCopy;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}

copyServiceLocationInformationAddressToClipboard() {
this.copyStringToClipboard(
this.getCopyServiceLocationInformationAddressTextValue()
);
}

copyBillingProviderInformationAddressToClipboard() {
this.copyStringToClipboard(
this.getCopyBillingProviderInformationAddressTextValue()
);
}
}