import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { PortalDeterminationService } from '@core/services/portal-determination.service'; import { ClientSettingsService } from '@features/client-settings/client-settings.service'; import { UserService } from '@features/users/user.service'; import { SummaryNumbers } from '@yourcause/common'; import { CachedAttr, CACHE_TYPES } from '@yourcause/common/cache'; import { I18nService } from '@yourcause/common/i18n'; @Component({ selector: 'gc-applicant-block', templateUrl: './applicant-block.component.html', styleUrls: ['./applicant-block.component.scss'] }) export class ApplicantBlockComponent implements OnInit { @Input() appId: number; @Input() name: string; @Input() email: string; @Input() addressString = ''; @Input() phone: string; @Input() initials: string; @Input() showClear = false; @Input() showMaskedToggle = false; @Input() isMasked = false; @Input() canViewMaskedApplicantInfo = false; @Input() isNomination = false; @Input() routerLinkForName: string | string[]; @Input() forTable = false; @Input() summaryNumbers: SummaryNumbers; @Output() onClear = new EventEmitter(); showMaskedApplicantsIcon = 'user-shield'; hideMaskedApplicantsIcon = 'user-times'; hideMaskedApplicantsTooltip = this.i18n.translate( 'MANAGE:textShowApplicantInformation', {}, 'Show applicant information' ); showMaskedApplicantsTooltip = this.i18n.translate( 'MANAGE:textHideApplicantInformation', {}, 'Hide applicant information' ); topLevelCustomIcon: string; topLevelCustomTooltip = ''; hasNominations = this.userService.user?.clientHasNominations; defaultCurrency = this.clientSettingsService.defaultCurrency; @CachedAttr( CACHE_TYPES.SESSION, false, undefined, undefined, (self: ApplicantBlockComponent) => { return `_yc_ShowMaskedApplicant_${self.appId}`; } ) showMaskedApplicant: boolean; constructor ( private i18n: I18nService, private clientSettingsService: ClientSettingsService, private portal: PortalDeterminationService, private userService: UserService ) { } get clientBranding () { return this.clientSettingsService.clientBranding; } get isManager () { return this.portal.isManager; } ngOnInit () { if (this.isNomination) { this.hideMaskedApplicantsTooltip = this.i18n.translate( 'MANAGE:textShowNominatorInformation', {}, 'Show nominator information' ); this.showMaskedApplicantsTooltip = this.i18n.translate( 'MANAGE:textHideNominatorInformation', {}, 'Hide nominator information' ); } if (this.isMasked) { this.setMaskedIconAndTooltip(); } } toggleShowMaskedApplicants () { this.showMaskedApplicant = !this.showMaskedApplicant; this.setMaskedIconAndTooltip(); } setMaskedIconAndTooltip () { this.topLevelCustomIcon = this.showMaskedApplicant ? this.hideMaskedApplicantsIcon : this.showMaskedApplicantsIcon; this.topLevelCustomTooltip = this.showMaskedApplicant ? this.showMaskedApplicantsTooltip : this.hideMaskedApplicantsTooltip; } }