Skip to main content

Application Store

The StarterKit plugin contains a utility class called ApplicationStore which is for storing and retrieving data within your application.

This is used for:

  • Language map and translations provider
  • Date format string
  • Preferred language ID
  • Fallback language ID
  • Data

Source Code

The utility class ApplicationStore is defined in the following file:

/src/utils/data-store.ts

Usage

To use the ApplicationStore class within your components you must import it:

import { Store } from "../utils/data-store";

An instance of ApplicationStore is then available through the imported Store object. The following methods are available on the Store object:


setValue(key, value)

Description

This method will store the supplied value in the application store using the supplied key.

Parameters

ParameterTypeDescription
keystringThe key used to store the value in the application store.
valueanyThe value to be stored.

Return Value

None


getValue(key)

Description

This method will retrieve a value from the application store using the supplied key.

Parameters

ParameterTypeDescription
keystringThe key used to store the value in the application store.

Return Value

The value stored in the application store for the supplied key, or null if no value exists for the supplied key.


setDateFormat(format)

Description

This method will store the supplied date format string in the application store. This value will be automatically used by date formatting methods such as formatISODate() in the Utility class.

Parameters

ParameterTypeDescription
formatstringThe date format string to be stored in the application store.

Return Value

None


getDateFormat()

Description

This method will retrieve the date format string from the application store.

Parameters

None

Return Value

The date format string stored in the application store, or the default value "yyyy-MM-dd" if no date format string has been set.


setPermissionChecker(permissionChecker)

Description

This method will store a reference to the Temenos Explorer method used to check if the role of the logged in user has permissions for a specified action.

This method should be called only once when the application is initialised and is already handled within ApplicationStore.setPermissionChecker() method which is called from /resources/js/listeners.js:

/**
* Method to set the permission checker method within the application store
* @param permissionChecker The Temenos Explorer permission checker method
*/
setPermissionsChecker(permissionChecker): void {
Store.setPermissionChecker(permissionChecker);
}

Parameters

ParameterTypeDescription
permissionCheckerfunctionThe Temenos Explorer permission checker function.

Return Value

None


getPermissionChecker()

Description

This method will return the Temenos Explorer permission checker function stored in the application store. This can then be used to check if the role of the logged in user has permission to perform a specified action.

For example:

// Check if the logged in user has permission for the "edit" action
const canEdit = Store.getPermissionChecker().("edit");

Parameters

None

Return Value

The Temenos Explorer permission checked function.


setupLanguageMap(translations)

Description

This method will setup the langauge map and associated translations provider used to handle all translation requests by your application.

Parameters

ParameterTypeDescription
translationsobjectThe translation data in the required format. Please see the document on translations) for more information.

Return Value

None


setLanguageId(languageId)

Description

This method will set the current language ID used by the translations provider when handling translation requests. This method should be called each time the user changes the language via the Temenos Explorer settings screen, passing in the selected language ID.

Parameters

ParameterTypeDescription
languageIdstringThe language ID to use for all translation requests.

Return Value

None


getPreferredLanguageId()

Description

This method will return the current preferred language ID stored in the application store.

Parameters

None

Return Value

The current preferred language ID.


getTranslation(lookupKey, default)

Description

This method will get the translation for the specified lookup key and the current preferred language ID. If no preferred language ID is set then the default fallback language ID "en" will be used.

Parameters

ParameterTypeDescription
lookupKeystringThe key to use for looking up a translation
defaultEnglishTranslationstringThe default English translation to use (optional)

Return Value

If there is a matching entry for the specified lookup key, this will be returned.

If there is no matching entry for the specified lookup key and a default value has been provided, the default value will be returned.

If there is no matching entry for the specified lookup key and no default value has been provided, the lookup key will be returned.


getTranslationsProvider()

Description

This method will provide access to the translations provider used by the application store. To lookup translations please use the ApplicationStore.getTranslation() method instead of directly referencing the translations provider.

Parameters

None

Return Value

The translations provider.