Skip to main content

Module: DialogManagerClient

The Dialog Manager Client simplifies interacting with dialog windows by spawning them and getting data back from them. In this context, a dialog window is simply a child window spawned to interact with the user, such as a confirmation dialog. Functions are provided here for both the parent-window side and the dialog/child-window side.

FSBL.Clients.DialogManager is always pre-initialized with one instance of the Dialog Manager in the Finsemble Library (making it essentially, a singleton when referenced in the same window). This means when developing Finsemble components, you directly access the Dialog Manager without using the constructor (e.g., FSBL.Clients.DialogManager.spawnDialog(...);). The constructor is not exposed to components.

Functions​

getParametersFromInDialog​

▸ getParametersFromInDialog(): Promise<any>

Called from within a dialog window to get the inputParams passed by the originating window when it called spawnDialog().

var dialogData = await FSBL.Clients.DialogManager.getParametersFromInDialog();

Returns​

Promise<any>


hideModal​

▸ hideModal(): Promise<null | string>

deprecated Hides the dialog's modal.

Returns​

Promise<null | string>


open​

▸ open(type, options, onUserInput): Promise<null | string>

Opens an existing dialog that is registered under the requested type. If no dialog is found then one will be spawned (with the options passed as the second parameter).

Resolves to an error string if the dialog could not be opened, or null if it was successfully opened.

Parameters​

NameTypeDescription
typestringComponent type to open. The type must be a key in the finsemble.components configuration object. If "yesNo" or "singleInput" are provided (legacy component names) then these will be converted to "YesNoDialog" and "SingleInputDialog" (current component names).
optionsanyOptions to pass into the opened window. See the Dialogs tutorial for more info about the options that you can pass to the "YesNoDialog" and the "SingleInputDialog".
onUserInputStandardErrorCallback<any>Callback to be invoked when the user interacts with the dialog.

Returns​

Promise<null | string>


registerDialogCallback​

▸ registerDialogCallback(cb?): Promise<void>

Dialog windows must run this method so that results can be sent back to originating windows. This method must only be run once in any given dialog window.

FSBL.Clients.DialogManager.registerDialogCallback((err, request) => {
if (err) return;
console.log("Originating window sent", request.data);
request.sendQueryResponse("your response");
FSBL.System.Window.getCurrent().hide();
});

Parameters​

NameType
cb?StandardErrorCallback<ResponderMessage<any, any>>

Returns​

Promise<void>


registerModal​

▸ registerModal(): Promise<null | string>

deprecated Registers this window as a modal that can be used by the dialog manager. This will set the window as a "scrim" – taking up the entire size of the monitor and being invisible or lightly opaque.

Sometimes, clicking anywhere on this window will dismiss the modal.

Returns​

Promise<null | string>


respondAndExitFromInDialog​

▸ respondAndExitFromInDialog(responseParameters): Promise<void>

Called within a dialog to pass a response back to the originating window. This will invoke the originating window's callback function that it passed to spawnDialog().

FSBL.Clients.DialogManager.respondAndExitFromInDialog({ choice: response });

Parameters​

NameTypeDescription
responseParametersanyData to be returned to the originating window's callback

Returns​

Promise<void>


respondToOpener​

▸ respondToOpener(data?): Promise<void>

Dialogs may call this to respond to the originating window (instead of responding directly to callbacks from registerDialogCallback()). The main advantage of using this method is that it automatically hides the dialog.

Parameters​

NameTypeDescription
data?anyData to be passed back to the originating window.

Returns​

Promise<void>


showDialog​

▸ showDialog(): Promise<void>

Must be called by the dialog window when it is ready to be displayed.

Returns​

Promise<void>


showModal​

▸ showModal(cb?): Promise<null | string>

deprecated Shows a semi-transparent black modal behind the dialog.

Parameters​

NameTypeDescription
cb?(error?: string) => voidThe callback to be invoked after the method completes successfully.

Returns​

Promise<null | string>


spawnDialog​

▸ spawnDialog(params, inputParams, dialogResponseCallback, cb?): StandardPromise<SpawnResponse>

Spawns an app or url in "dialog mode". The app's window will not be dockable. The app does not need to be explicitly coded as a dialog.

Parameters passed as params.inputParams can be retrieved in the dialog window by calling FSBL.Clients.DialogManager.getParametersFromInDialog().

FSBL.Clients.DialogManager.spawnDialog(
{
name: "dialogTemplate",
height: 300,
width: 400,
url: "http://localhost/components/system/dialogs/dialog1.html",
},
{
someData: 12345,
},
(error, responseParameters) => {
if (!error) {
console.log(
">>>> spawnDialog response: " + JSON.stringify(responseParameters),
);
}
},
);

Parameters​

NameTypeDescription
paramsSpawnParamsParameters. Same as LauncherClient.spawn() with the following exceptions.
inputParamsanyObject or any data type needed by your dialog.
dialogResponseCallbackStandardErrorCallback<any>called when response received back from dialog window (typically on dialog completion). responseParameters is defined by the dialog.
cb?StandardErrorCallback<SpawnResponse>Returns response from LauncherClient.spawn()

Returns​

StandardPromise<SpawnResponse>