|
|
@@ -15,6 +15,7 @@ export class TableComponent implements OnInit { |
|
|
|
showExportOptions: boolean = false; |
|
|
|
shouldHaveImplementationData: boolean = false; |
|
|
|
searchText: string = ''; |
|
|
|
selectedPartnerList: Array<any> = []; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private partnerProfileService: PartnerProfileService, |
|
|
@@ -62,59 +63,102 @@ export class TableComponent implements OnInit { |
|
|
|
this.router.navigate(['dashboard/partners/partner-details'], { queryParams: { data: JSON.stringify(partner) } }); |
|
|
|
} |
|
|
|
|
|
|
|
loadCSVData(partnerData: any) { |
|
|
|
JSON.stringify(partnerData).split |
|
|
|
|
|
|
|
let csvArray = [{ |
|
|
|
"PortalID": partnerData.portalId ? partnerData.portalId : '-', |
|
|
|
|
|
|
|
// TODO: DetailedProfile |
|
|
|
|
|
|
|
'Bio': partnerData.detailedProfile.bio, |
|
|
|
'Branch Location Countries': (partnerData.detailedProfile.branchLocationCountries).toString(), |
|
|
|
"Communities": (partnerData.detailedProfile.communities).toString(), |
|
|
|
"District": partnerData.detailedProfile.district, |
|
|
|
"Districts": (partnerData.detailedProfile.districts).toString(), |
|
|
|
"Files": partnerData.detailedProfile.files, |
|
|
|
"Have Branches In Other Districts": partnerData.detailedProfile.haveBranchesInOtherDistricts, |
|
|
|
"Logo": partnerData.detailedProfile.logo, |
|
|
|
"Partner Location": partnerData.detailedProfile.partnerLocation, |
|
|
|
"Preferred Languages": (partnerData.detailedProfile.preferredLanguages).toString(), |
|
|
|
"Preferred Mode Of Communications": (partnerData.detailedProfile.preferredModeOfCommunications).toString(), |
|
|
|
"State": partnerData.detailedProfile.state, |
|
|
|
"States": (partnerData.detailedProfile.states).toString(), |
|
|
|
"Total Reach Of Organization": partnerData.detailedProfile.totalReachOfOrganization, |
|
|
|
"Year Of Establishment": partnerData.detailedProfile.yearOfEstablishment, |
|
|
|
|
|
|
|
// Primary Contact |
|
|
|
|
|
|
|
"Primary Name": partnerData.primaryContact.contactNumber, |
|
|
|
"Primary Contact Number": partnerData.primaryContact.contactNumber, |
|
|
|
"Primary Email": partnerData.primaryContact.contactNumber, |
|
|
|
"Primary Designation": partnerData.primaryContact.contactNumber, |
|
|
|
|
|
|
|
// Alternative Contact |
|
|
|
|
|
|
|
'Alternative Name': partnerData.alternateContact.name, |
|
|
|
'Alternative ContactNumber': partnerData.alternateContact.contactNumber, |
|
|
|
'Alternative Email': partnerData.alternateContact.email, |
|
|
|
'Alternative Designation': partnerData.alternateContact.designation, |
|
|
|
|
|
|
|
// Strength |
|
|
|
|
|
|
|
"Other Specific Support Required": partnerData.strengthAndCapability.otherSpecificSupportRequired, |
|
|
|
"Primary Areas Of Support Offered": (partnerData.strengthAndCapability.otherSpecificSupportRequired).toString(), |
|
|
|
"Primary Areas Of Support Offered Description": partnerData.strengthAndCapability.primaryAreasOfSupportOffered, |
|
|
|
"Primary Areas Of Support Offered Other": partnerData.strengthAndCapability.primaryAreasOfSupportOfferedDescription, |
|
|
|
"Primary Areas Of Support Required": (partnerData.strengthAndCapability.primaryAreasOfSupportOfferedOther).toString(), |
|
|
|
"Primary Areas Of Support Required Description": partnerData.strengthAndCapability.primaryAreasOfSupportRequired, |
|
|
|
"Primary Areas Of Support Required Other": partnerData.strengthAndCapability.primaryAreasOfSupportRequiredOther, |
|
|
|
}] |
|
|
|
return csvArray; |
|
|
|
selectPartner(partner: any) { |
|
|
|
if (this.selectedPartnerList) { |
|
|
|
console.log(!this.checkedInput(partner)) |
|
|
|
if (this.selectedPartnerList.some(x => JSON.stringify(x) === JSON.stringify(partner))) { |
|
|
|
this.selectedPartnerList = this.selectedPartnerList.filter(x => JSON.stringify(x) !== JSON.stringify(partner)) |
|
|
|
} else this.selectedPartnerList.push(partner) |
|
|
|
} |
|
|
|
|
|
|
|
console.log(this.selectedPartnerList) |
|
|
|
} |
|
|
|
|
|
|
|
exportCSV() { |
|
|
|
console.log(this.tempUserData) |
|
|
|
let tempArray = []; |
|
|
|
|
|
|
|
for (const partner of this.selectedPartnerList) { |
|
|
|
let csvArray = [{ |
|
|
|
"PortalID": partner.portalId ? partner.portalId : '-', |
|
|
|
|
|
|
|
// Primary Contact |
|
|
|
|
|
|
|
"Primary Name": partner.primaryContact.contactNumber, |
|
|
|
"Primary Contact Number": partner.primaryContact.contactNumber, |
|
|
|
"Primary Email": partner.primaryContact.contactNumber, |
|
|
|
"Primary Designation": partner.primaryContact.contactNumber, |
|
|
|
|
|
|
|
// Basic Info |
|
|
|
|
|
|
|
"areasOfWork": partner.organizationBasicInfo.areasOfWork ? partner.organizationBasicInfo.areasOfWork.toString() : '', |
|
|
|
"name": partner.organizationBasicInfo.name, |
|
|
|
"reasonForBecomingMember": partner.organizationBasicInfo.reasonForBecomingMember, |
|
|
|
"referralName": partner.organizationBasicInfo.referralName, |
|
|
|
"source": partner.organizationBasicInfo.source, |
|
|
|
"type": partner.organizationBasicInfo.type, |
|
|
|
"website": partner.organizationBasicInfo.website, |
|
|
|
"wouldLikeUpdates": partner.organizationBasicInfo.wouldLikeUpdates, |
|
|
|
|
|
|
|
// Alternative Contact |
|
|
|
|
|
|
|
'Alternative Name': partner.alternateContact.name, |
|
|
|
'Alternative ContactNumber': partner.alternateContact.contactNumber, |
|
|
|
'Alternative Email': partner.alternateContact.email, |
|
|
|
'Alternative Designation': partner.alternateContact.designation, |
|
|
|
|
|
|
|
// Detailed Profile |
|
|
|
|
|
|
|
'Bio': partner.detailedProfile.bio, |
|
|
|
'Branch Location Countries': partner.detailedProfile.branchLocationCountries ? partner.detailedProfile.branchLocationCountries.toString() : '', |
|
|
|
"Communities": partner.detailedProfile.communities ? partner.detailedProfile.communities.toString() : '', |
|
|
|
"District": partner.detailedProfile.district, |
|
|
|
"Districts": partner.detailedProfile.districts ? partner.detailedProfile.districts.toString() : '', |
|
|
|
"Files": partner.detailedProfile.files, |
|
|
|
"Have Branches In Other Districts": partner.detailedProfile.haveBranchesInOtherDistricts, |
|
|
|
"Logo": partner.detailedProfile.logo, |
|
|
|
"Partner Location": partner.detailedProfile.partnerLocation, |
|
|
|
"Preferred Languages": partner.detailedProfile.preferredLanguages ? partner.detailedProfile.preferredLanguages.toString() : '', |
|
|
|
"Preferred Mode Of Communications": partner.detailedProfile.preferredModeOfCommunications ? partner.detailedProfile.preferredModeOfCommunications.toString() : '', |
|
|
|
"State": partner.detailedProfile.state, |
|
|
|
"States": partner.detailedProfile.states ? partner.detailedProfile.states.toString() : '', |
|
|
|
"Total Reach Of Organization": partner.detailedProfile.totalReachOfOrganization, |
|
|
|
"Year Of Establishment": partner.detailedProfile.yearOfEstablishment, |
|
|
|
|
|
|
|
// Strength |
|
|
|
|
|
|
|
"Other Specific Support Required": partner.strengthAndCapability.otherSpecificSupportRequired, |
|
|
|
"Primary Areas Of Support Offered": partner.strengthAndCapability.otherSpecificSupportRequired ? partner.strengthAndCapability.otherSpecificSupportRequired.toString() : '', |
|
|
|
"Primary Areas Of Support Offered Description": partner.strengthAndCapability.primaryAreasOfSupportOffered, |
|
|
|
"Primary Areas Of Support Offered Other": partner.strengthAndCapability.primaryAreasOfSupportOfferedDescription, |
|
|
|
"Primary Areas Of Support Required": partner.strengthAndCapability.primaryAreasOfSupportOfferedOther ? partner.strengthAndCapability.primaryAreasOfSupportOfferedOther.toString() : '', |
|
|
|
"Primary Areas Of Support Required Description": partner.strengthAndCapability.primaryAreasOfSupportRequired, |
|
|
|
"Primary Areas Of Support Required Other": partner.strengthAndCapability.primaryAreasOfSupportRequiredOther, |
|
|
|
}] |
|
|
|
|
|
|
|
tempArray.push(csvArray[0]) |
|
|
|
} |
|
|
|
|
|
|
|
let csvData = Papa.unparse(tempArray) |
|
|
|
let element = document.createElement('a'); |
|
|
|
let blob = new Blob([csvData], { type: 'text/csv;charset=utf-8;' }); |
|
|
|
let url = URL.createObjectURL(blob); |
|
|
|
element.href = url; |
|
|
|
element.setAttribute('download', 'PartnerProfile.csv'); |
|
|
|
element.click(); |
|
|
|
} |
|
|
|
|
|
|
|
checkedInput(partner : any){ |
|
|
|
return this.selectedPartnerList.some(x => JSON.stringify(x) === JSON.stringify(partner)) |
|
|
|
} |
|
|
|
|
|
|
|
checkedAllInput(){ |
|
|
|
return JSON.stringify(this.selectedPartnerList) === JSON.stringify(this.tempUserData) |
|
|
|
} |
|
|
|
|
|
|
|
selectAllPartner(){ |
|
|
|
if(JSON.stringify(this.selectedPartnerList) === JSON.stringify(this.tempUserData)){ |
|
|
|
this.selectedPartnerList = [] |
|
|
|
} else this.selectedPartnerList = this.tempUserData |
|
|
|
} |
|
|
|
|
|
|
|
} |