libs/common/web-components/src/back-link-adapter/back-link-utils.service.ts
Methods |
constructor(channel: CHANNEL, backLinkAdapterService: BackLinkAdapterService)
|
|||||||||
Parameters :
|
isBackLinkFeatureActiveForActions | ||||||
isBackLinkFeatureActiveForActions(isLastPage: boolean)
|
||||||
Parameters :
Returns :
boolean
|
isBackLinkFeatureActiveForStage | ||||||
isBackLinkFeatureActiveForStage(hideBackLink: boolean | undefined)
|
||||||
Parameters :
Returns :
boolean
|
import { CHANNEL, CHANNEL_TOKEN } from '@allianz/taly-core';
import { Inject, Injectable, Optional } from '@angular/core';
import { BackLinkAdapterService } from './back-link-adapter.service';
@Injectable({
providedIn: 'root'
})
export class BackLinkUtilsService {
private isRetailChannel: boolean;
constructor(
@Inject(CHANNEL_TOKEN) channel: CHANNEL,
@Optional() private backLinkAdapterService: BackLinkAdapterService
) {
this.isRetailChannel = channel === CHANNEL.RETAIL;
}
isBackLinkFeatureActiveForStage(hideBackLink: boolean | undefined): boolean {
return Boolean(
this.isRetailChannel &&
!hideBackLink &&
this.backLinkAdapterService?.backLinkData?.stageLinkLabel
);
}
isBackLinkFeatureActiveForActions(isLastPage: boolean): boolean {
return Boolean(this.isRetailChannel && isLastPage && this.hasNextButtonLabel());
}
private hasNextButtonLabel(): boolean {
const nextButtonLabel = this.backLinkAdapterService?.backLinkData?.nextButtonLabel;
if (Array.isArray(nextButtonLabel) && nextButtonLabel.length > 0) {
return true;
}
return Boolean(nextButtonLabel);
}
}