Date Range

Overview

The Date range component is a contractual component that helps the user select a range of time to filter through a list of records. The Date component displays the date in a row or with a drop-down option for user selection. When the user selects the drop-down option, a calendar appears displaying the default start and end date. The Date range component allows the user to select a variety of ranges such as six months, one year, two years, or a custom range. When the custom range is selected, the component also provides the option to select the start and end date.

The developer can customize various options such as the date formats, start date, end date, headers, and sub-headers at the component level. The run-time configurations for this component should be set in the parent of the component (such as the Form Controller).

NOTE: The Date Range component is used inside the Mobile Banking application.

Date Range Contracts

The Date Range component contains the following contracts for customizing the widgets and date selection.

Service Parameters

The Date Range component uses the Context variable to navigate to a different screen. The component does not use the Service Parameters contract. By default, the Date Range component does not contain any value for the Service Parameter contract.

{}

Data Mapping

The Data Mapping property of the Date Range component maps the widget IDs with the data to be displayed. The data is mapped to the template widgets using the Context variable.

Here is a sample of the JSON object provided in the Data Mapping of the Date Range component.

{
	"btnRanges": {
		"Last 7days": "7",
		"Previous 30 Days": 30,
		"3M": "90",
		"6M": 180,
		"Last Year": 365,
		"Custom": "-1"
	},
	"defaultRange": {
		"selectedTab": "3M"
	},
	"configurableLabels": {
		"HeaderVisibility": true,
		"HeaderLabel": "${i18n{i18n.common.byTimePeriod}}",
		"StartDateLabel": "${i18n{i18n.common.startDate}}",
		"EndDateLabel": "${i18n{i18n.common.endDate}}",
		"customStartDateHeader": "${i18n{i18n.common.byTimePeriod}}",
		"customStartDateSubHeader": "${i18n{i18n.common.pleaseSelectDate}}",
		"customEndDateHeader": "${i18n{i18n.common.byTimePeriod}}",
		"customEndDateSubHeader": "${i18n{i18n.common.pleaseSelectDate}}",
		"validStartDate": [22, 9, 2020],
		"validEndDate": "",
		"dateFormat": "DD/MM/YYYY",
		"blockDate": [
			[12, 12, 2021],
			[23, 12, 2021],
			[20, 11, 2021]
		]
	}
}

The Data Mapping contract is assigned a JSON object with the following key-value pairs.

Key Description
btnRanges

Configures the number of buttons or tabs in the Date Range component. This key accepts a JSON object with the following key-value pairs.

  • key: The text on the button or tab in a String format.
  • value: Sets the number of days in a String or Numerical format. This is used to calculate the Start date. The value in this key is '-1' for a custom or free date.
defaultRange

This key sets the default button to be selected when the Date Range component appears. This key accepts a JSON object with the following key-value pairs.

  • selectedTab: The name of the default tab that appears in the component.
configurableLabels

This key configures additional fields in the Date Range component. This parameter is assigned a JSON object with the following key-value pairs.

  • HeaderVisibility: Sets the visibility of the title.
  • StartDateLabel: Configures the static text or i18n key for the From/ Start Date Label.
  • EndDateLabel: Configures the static text or i18n key for the To/ End Date Label.
  • customStartDateHeader: Configures the static text or i18n key for the header in the dialog box that appears on the click of the From/ Start Date Label.
  • customStartDateSubHeader: Configures the static text or i18n key for the sub-header in the dialog box that appears on the click of the From/ Start Date Label.
  • customEndDateHeader: Configures the static text or i18n key for the header displayed when the calendar icon in To/ End Date Label is clicked.
  • customEndDateSubHeader: Configures the static text or i18n key for the sub-header in the dialog box that appears on the click of the To/ End Date Label.
  • validStartDate: Sets the valid start date for custom selection. This key accepts the date in the [dd, mm, yyyy] format. For example, if the valid first date is 22nd September 2020, then the value must be: [22,9,2020]. To allow the user to select any date from the calendar, provide an empty String ("") to this key.
  • validEndDate: Sets the valid end date for custom selection. This key accepts the date in the [dd, mm, yyyy] format. For example, if the valid end date is 22nd September 2020, then the value must be: [22,9,2020]. To select the current date as the end date by default, provide an empty String ("") to this key.
  • dateFormat: Sets the date format in a String format. This key supports the following date formats.
    • MM-DD-YYYY
    • DD-MM-YYYY
    • MM/DD/YYYY
    • DD/MM/YYYY
    • MM.DD.YYYY
    • DD.MM.YYYY
    • YYYY/MM/DD
    • YYYY-MM-DD
    • YYYY.MM.DD
  • blockDate: Sets the dates to be blocked from the calendar selection. This key accepts an array of dates in the following format.
    <blockDate> : [[dd,mm,yyyy], [dd,mm,yyyy]]

Data Formatting

The Data Formatting property is used to provide a custom format for a specific requirement. By default, this component contains no value in this contract.

{}

Conditional Mapping Key

The Conditional Mapping Key is used to define mapping based on a criterion.

For example, if a label defined in the UI must display different data according to the type of account, a developer must set the Conditional Mapping Key property to the following value. By default, this component contains no value in this contract.

{}

Conditional Mapping

The Conditional Mapping property key is used to map a widget with a data from Collection Object or service response as per the Conditional Mapping key. By default, this component contains no value in this contract.

{}

onError event

The OnError event is invoked when an error occurs during the user journey. When the onError event is invoked, an error object is passed to the parent widget. This object contains the information about the error as well as where it had occurred.

Parameter Value
Input parameter JSON object

Object Description

The JSON object contains the following keys:

  • level: This key contains the String value regarding the place in which the error occurs. It can be from the component View controller or from the component Business controller.
  • method: This key contains the method to be executed when an error occurs.
  • error: This key contains the actual error message and the stack.

Sample Input

var errordata = {
	"level": "ComponentViewController",
	"method": "render",
	"error": err
};
this.onError(errordata);

setContext Method

This method is invoked inside the parent component or form controller. Using this method, a developer can pass the data required for the component from the parent of the component.

Parameter Value

Syntax

this.view.componentID.setContext(contextData);

Input parameter

JSON object containing the context variable. For more information on the context object, click here.

Sample Input

this.view.daterange.setContext(contextData);

Return Type

None

getSelectedRange Method

This method retrieves the date range selected by the user.

Parameter Value
Input parameter

NA

Sample Output

var selectedRange = {
	"startDate": startDateValue,
	"endDate": endDateValue,
	"selectedTab": selectedTab
};
selectedRange = this.view.daterange.getSelectedRange();

Return Type

JSON object containing the following key-value pairs.

  • startDate: Contains the data about the start date set by the user.
  • endDate: Contains the data about the end date set by the user.
  • selectedTab: Contains the data about the tab set by the user.

setConfigsFromParent Method

This method sets the configurations from the parent component to the Date Range component when the Date Range component is placed inside another component.

Parameter Value

Syntax

this.view.<componentID>.setConfigsFromParent(configParams);

Input parameter

configParams: Sets the JSON object required for the child component. The JSON object can contain all the contracts used in the Date Range component as keys.

  • serviceParameters: JSON object containing the Service configurations.
  • dataMapping: JSON object containing the data mapped with the widget.
  • dataFormatting: JSON object containing the look and feel of the data.

Sample Input

var configParams ={
	"serviceParameters": "this._ServiceParameters",
	"dataMapping": "this._DataMapping",
	"dataFormatting": "this._DataFormatting"
}
this.view.daterange.setConfigsFromParent(configParams);

Return Type

None

Context Object

The Context Object is a JSON object used to pass data from the component's parent to the component. In the Date Range component, the Context Object passes the following data required for the component from the component consumer.

  • dates
  • selectedStartDate
  • selectedEndDate
  • selectedTab

Here is a sample of the Context JSON Object used inside the component.

let date = [[13, 12, 2021]];
let param = {
	"dates": date,
	"selectedStartDate": startDate,
	"selectedEndDate": endDate,
	"selectedTab": selectedTab
};

 

Copyright © 2020- Temenos Headquarters SA

Published on :
Monday, May 2, 2022 5:08:51 PM IST

Feedback
x