Configurator State Manager Util
This library provides a set of predefined tools to manage the Configurator input states.
The util uses a hidden configurator to save the states (last values, init status, …) of the managed inputs. Then, the states can be used in the configurator logic.
The util allows creating a custom input state.
This util works in the configurator logic context only.
Setup
You need to add a context parameter that you want to manage by using:
libs.SharedAccLib.ConfiguratorStateManager.setContextParameter(contextParameter)
Then, you need to register the state handler, so the input state can be generated.
libs.SharedAccLib.ConfiguratorStateManager
.registerValueStateProvider()
.registerInitializationStateProvider()
.saveRegisteredInputStates()
In the last element of the configurator logic, return the hidden input of the state manager:
return libs.SharedAccLib.ConfiguratorStateManager.getStateHiddenInput()
Predefined State Provider
Previous Value
The value state provider should first be registered:
libs.SharedAccLib.ConfiguratorStateManager
.registerValueStateProvider()
The state provider gets the value of the managed input and saves it to the hidden input.
Then, you can access the input previous value by using:
libs.SharedAccLib.ConfiguratorStateManager
.getPreviousInputValue(inputName)
This will get the input value saved in the state, then return the value. It should be helpful in case you want to revert the previous input data.
Input Value Update State
The value state provider should first be registered:
The state provider gets the value of the managed input and saves it to the hidden input.
Then, you can check if an input value is updated or not by using:
This will compare the value from api.input(inputName)
and the previous input value from the state. It should be helpful in case you want to do some action based on the input value update, e.g., reload option input B if input A value is updated.
Input Initialization State
The input initialization state should first be registered:
This saves an initialization flag to the state for each input [inputName: true]
.
Then, you can check if an input is initialized:
This will check if the initialization flag is saved in the state, then you know whether the input is initialized or not. It should be helpful in case you want to do some action based on the input initialization state, e.g., validate input A value only if it is initialized.
Input Present State
The value state provider should first be registered:
The state provider gets the value of the managed input and saves it to the hidden input.
Then, you can check if an input value is presented in the state or not by using:
This will check if the previous input state contains the input name as the key.