libs/core/src/lib/services/taly-page-data.service.ts
Properties |
|
stage (Optional) | |
Type |
Stage
|
import { Injectable } from '@angular/core';
import { BehaviorSubject, ReplaySubject } from 'rxjs';
/**
* This service will be embed into `AbstractBuildingBlockPage`
* which acts as the base class of all Building Block Pages.
*
* Any page being created can report it's set of `TalyPageData`
* so it can be used in a different place, outside of the actual page component.
*/
@Injectable({ providedIn: 'root' })
export class TalyPageDataService {
private _currentPageData!: PageDataForTemplate;
private _pageDataSubject = new BehaviorSubject<PageDataForTemplate>({});
private _pageIdSubject = new ReplaySubject<string>(1);
storeData(data: PageDataForTemplate) {
this._currentPageData = data;
this._pageDataSubject.next(this._currentPageData);
}
get pageData$() {
return this._pageDataSubject.asObservable();
}
get pageData() {
return this._currentPageData;
}
setPageId(id: string) {
this._pageIdSubject.next(id);
}
get pageId$() {
return this._pageIdSubject.asObservable();
}
}
export interface PageDataForTemplate extends PageData {
stage?: Stage;
}
/**
* @additionalProperties false
*/
export interface Navigation {
/**
* Hide the navigation when the user is on this particular page.
*/
hidden?: boolean;
/**
* Disable navigation by clicking on the navigation menu
*/
preventClickNavigation?: boolean;
}
/**
* @additionalProperties false
*/
export interface PageData {
navigation?: Navigation;
pageActionConfig?: PageActionConfig;
}
/**
* @additionalProperties false
*/
export interface PageActionConfig {
/**
* Hide the "NEXT" button on this page.
*/
nextButtonHidden?: boolean;
/**
* Hide the "BACK" button on this page.
*/
backButtonHidden?: boolean;
/**
* Provide a customized text for the "BACK" button of page (default is 'Back').
* Specify either a string or different labels that are linked to conditions.
* This value will be translatable.
* @examples [[{"label": "My conditional label", "condition": "{$.person.firstName} === {$.person.lastName}"}], "My label"]
*/
backButtonLabel?: string | PageActionButtonLabel[];
/**
* Override the default styling for the back button in the page, making it a "tertiary" button.
* Only applies for Expert journeys.
*/
backButtonUseTertiaryStyle?: boolean;
/**
* Provide a customized text for the "NEXT" button of page (default is 'Next').
* Specify either a string or different labels that are linked to conditions.
* This value will be translatable.
* @examples [[{"label": "My conditional label", "condition": "{$.person.firstName} === {$.person.lastName}"}], "My label"]
*/
nextButtonLabel?: string | PageActionButtonLabel[];
/**
* Provide a customized text for the "CANCEL" button of page (default is 'Cancel').
* Specify either a string or different labels that are linked to conditions.
* This value will be translatable.
* @examples [[{"label": "My conditional label", "condition": "{$.person.firstName} === {$.person.lastName}"}], "My label"]
*/
cancelButtonLabel?: string | PageActionButtonLabel[];
/**
* Configure additional buttons that will be shown along the Next and the Back button.
* @default []
* @examples [["SAVE_OFFER"]]
*/
extraActions?: ExtraPageAction[];
}
export interface PageActionButtonLabel {
label: string;
condition: string;
}
/**
* Available types of additional action buttons
*/
// Developer's note: add new page actions via unions (e.g. `'TYPE' | 'TYPE2'`).
// If we turn this list of actions into an enum we run into problems in generated
// apps that use `strict` compilation because of the way we "render" page data.
export type ExtraPageAction = 'SAVE_OFFER' | 'CANCEL_OPERATION';
export type Stage =
| PageTitleAsStageBase
| PageTitleAsStageWithSubline
| PageTitleAsStageWithTopline;
export type PageTitle = string | PageTitleObject | Stage;
/**
* @additionalProperties false
*/
export interface PageTitleObject {
/**
* The headline of the page title.
*/
headline: string;
/**
* Specifies whether to show the page title as a stage.
*/
showAsStage?: false;
/**
* The subline of the page title.
*/
subline?: string;
}
/**
* @additionalProperties false
*/
export interface PageTitleAsStageBase {
/**
* The headline of the page title.
*/
headline: string;
/**
* Specifies whether to show the page title as a stage.
*/
showAsStage: true;
/**
* The image on the end side of the horizontal axis (right-hand when LTR)
*/
endImage?: string;
/**
* Replacement when the screen estate is limited like on the mobile layout.
*/
narrowImage?: string;
/**
* The image on the start side of the horizontal axis (left-hand when LTR)
*/
startImage?: string;
/**
* Flag that allows to hide the back link for specific pages, in case being displayed for the generated app
*/
hideBackLink?: boolean;
}
/**
* @additionalProperties false
*/
export interface PageTitleAsStageWithSubline extends PageTitleAsStageBase {
/**
* The subline of the page title. The subline can only be set if no topline exists.
*/
subline: string;
}
/**
* @additionalProperties false
*/
export interface PageTitleAsStageWithTopline extends PageTitleAsStageBase {
/**
* The topline of the page title. The topline can only be set if no subline exists.
*/
topline: string;
}