Class: DialogManagerClient

Dialog Manager Client (Finsemble Flow)

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.

Methods

checkIfWindowIsDialog
(cb)

Checks to see whether the window is a dialog.

Name Type Description
cb Function optional

The callback to be invoked after the method completes successfully.

getParametersFromInDialog
()

Called from within dialog window to get the parameters passed in spawnDialog as "inputParams". For example, if your dialog has a configurable title, you would pass it in to spawnDialog, and retrieve the value using getParametersFromInDialog.

hideModal
()

Hides the dialog's modal.

open
(type, options, onUserInput)

Retrieves an available dialog. If none are found, one will be created with the options passed.

Name Type Description
type string

Component type to open. The type must be a key in the finsemble.components configuration object.

options any

Options to pass into the opened window.

onUserInput Function

Callback to be invoked when the user interacts with the dialog.

registerDialogCallback
(callback)

Used by the window that is opening a dialog. This method sets up a query/responder that the opened dialog will invoke when the user has interacted with the dialog.

Name Type Description
callback any

Callback to be invoked after the user interacts with the dialog. Any data sent back from the dialog will be passed in as the 2nd parameter to this callback.

registerModal
()

Registers a window as a modal with the global dialog management store.

registerWithStore
(callback)

Registers the window as a dialog with the global store. If the component is incapable of being used as a dialog (this is set in the component's config), the callback is immediately invoked.

Note: This method will check to see whether the calling window is a dialog.

Name Type Description
callback Function

The callback to be invoked after the method completes successfully.

respondAndExitFromInDialog
(responseParameters)

Called within the dialog window to pass back a dialog response. This results in the spawnDialog callback function (i.e., dialogResponseCallback) being invoked with responseParameters passed in.

Name Type Description
responseParameters any

The parameters returned to parent (i.e., window that spawned the dialog).

respondToOpener
(data)

Sends data back to the window that opened the dialog. Will hide the modal unless { hideModalOnClose: false } is passed in as the first argument.

Name Type Description
data any

Data desired to be handed back to the window that requested the dialog.

sendQueryToDialog
(identifier, options, onUserInput)

Function to initialize and open a dialog.

Name Type Description
identifier WindowIdentifier

The window identifier of the dialog.

options any

Any data to send to the dialog for its initialization.

onUserInput any

Callback to be invoked after the user interacts with the dialog.

showDialog
()

Broadcasts a message to the window that opened the dialog saying "I'm ready, please show me."

showModal
(cb)

Shows a semi-transparent black modal behind the dialog.

Name Type Description
cb Function optional

The callback to be invoked after the method completes successfully.

spawnDialog
(params, inputParams, dialogResponseCallback, cb)

Spawns a dialog window.

parameters passed here in >params.inputParams can be retrieved in the dialog window by calling getParametersFromInDialog.

Name Type Description
params SpawnParams

The parameters passed to Launcher.Spawn.

For properties duplicated between the top-level and `options`, `options` takes precedence.

Name Type Description
addToWorkspace boolean optional

Defaults to false. Whether to add the new component to the workspace. The addToWorkspace config value set at the component level overwrites this value.

affinity string optional

Set a process affinity flag. This allows windows to grouped together under a single process (a.k.a. Application). This flag is only available when your container is Electron.

alias string optional

Used when windowType is "native" or "assimilation". Specifies the alias of a bundled asset.

arguments any optional

Used when windowType is "native" or "assimilation". Specifies the arguments to be sent to the application. This is used in conjunction with path. Arguments should be separated by spaces: `--arg1 foo --arg2 bar` except when `params.argumentsAsQueryString` is true, in which case set this parameter to be single string in URI format: `arg=1&arg=2`"

argumentsAsQueryString boolean optional

For native applications launched by URI: 1) the string is passed as the "arguments" parameter if appended as a query string; and 2) the automatically generated arguments described in "path" are appended to the query string

bottom optional

A pixel value representing the distance from the top edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the top edge of the viewport relative to the viewport's height.

canGroup boolean optional

Whether the component can group with other windows.

claimMonitorSpace boolean optional

For use with permanent toolbars. The available space for other components will be reduced by the amount of space covered by the newly spawned component. This will be reflected in the `unclaimedRect` member from API calls that return monitorInfo. Users will be prevented from moving windows to a position that covers the claimed space. See `position: 'unclaimed'`.

component any optional

Type of component to spawn.

data any optional

Optional data to pass to the opening window. If set, then the spawned window can use WindowClient#getSpawnData to retrieve the data.

dockOnSpawn boolean optional

If true, will automatically dock the window with the "relative" window (dock to the parent window unless specified in params.relativeWindow). Note that you must also position the window in a valid position for docking, for example, by setting the "left" or "top" parameters to "adjacent".

dockable optional

An array of parts of the monitor that the component can dock to. Valid values are `top` and `bottom`.

docked optional

Which part of the monitor that the component will dock to on spawn. Valid options are `top` and `bottom`. Only valid if combined with the `dockable` property.

dockedHeight number optional

Currently, components can only dock to the full width of the monitor. This parameter determines what height the component will be when docked to a monitor.

env any optional

Sets environment variables for a spawned native application. Create a map (JSON) object of names to values. This is only available when running Assimilation.

ephemeral boolean optional

Indicates that this window is ephemeral. An ephemeral window is a dialog, menu, or other window that is temporarily displayed but usually hidden. Ephemeral windows automatically have the following settings assigned: resizable: false, showTaskbarIcon: false, alwaysOnTop: true. Note: Use `options:{autoShow: false}` to prevent an ephemeral widow from showing automatically.

forceOntoMonitor boolean optional

If true, will attempt to make the window have no edges outside the monitor boundary.

groupName string optional

Optional group name. Adds windows to a group (unrelated to docking or linking) that is used for window management functions. If the group does not exist it will be created.

groupOnSpawn boolean optional

Groups the window to the `relativeWindow` based on their adjacent position.

height optional

A pixel or percentage value.

launchingWindow any optional

Where the spawn request is coming from.

left optional

A pixel value representing the distance from the left edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the left edge of the viewport relative to the viewport's width.

"adjacent" will snap to the right edge of the spawning or relative window.

"center" will center the window

If neither left nor right are provided, then the default will be to stagger the window based on the last spawned window.

maxHeight number optional

Maximum height window can be resized to.

maxWidth number optional

Maximum width window can be resized to.

minHeight number optional

Minimum height window can be resized to.

minWidth number optional

Minimum width window can be resized to.

monitor optional

Which monitor to place the new window.

"mine" - Place the window on the same monitor as the calling window.

Integer value from 0-n (0 being the primary monitor).

"primary" indicates the user's primary monitor.

"all" - Put a copy of the component on all monitors.

name string optional

Name to give the component. If not provided, a random one will be generated.

native boolean optional
options any optional

Properties to merge with the default windowDescriptor. Any value set here will be sent directly to the WebWindow, and will override the effect of relevant parameters to spawn(). By default, all Finsemble windows are frameless. FEA Permissions and window properties (such as always on top) are provided here.

path string optional

Used when windowType is "native" or "assimilation". Specifies the path to the application. The path can be: The name of an exe that is on the system path (e.g., notepad.exe). The full path to an executable on the user's machine (e.g., C:\Program Files\app.exe). A system installed URI (e.g., myuri://advancedapplauncher).

When windowType is "native" then additional arguments will be automatically appended to the path or the URI. These arguments can be captured by the native application in order to tie it to Finsemble's window tracking. When building an application with finsemble.dll, this is handled automatically. Those arguments are:

uuid - A generated UUID that uniquely identifies this window.

left - The x coordinate of the new window

top - The y coordinate of the new window

width - The width of the new window

height - The height of the new window

finsembleWindowName - The name of the window in the Finsemble config

componentType - The component type in the Finsemble config

A common troublesome problem is when a native application needs to be launched from an intermediary application (such as a launcher or batch script). That intermediary application can pass these parameters which will allow the final application to connect back to Finsemble.

position string optional

Defines a "viewport" for the spawn, with one of the following values:

"unclaimed" (the default) Positioned based on the monitor space excluding space "claimed" by other components (such as toolbars). For instance, `top:0` will place the new component directly below the toolbar.

"available" Positioned according to the coordinates available on the monitor itself, less space claimed by the operating system (such as the windows toolbar). For instance, bottom:0 will place the new component with its bottom flush against the windows toolbar.

"monitor" Positioned according to the absolute size of the monitor. For instance, top:0 will place the component overlapping the toolbar.

"relative" Positioned relative to the relativeWindow. For instance, left:0;top:0 will join the top left corner of the new component with the top left corner of the relative window.

"virtual" Positioned against coordinates on the virtual screen. The virtual screen is the full viewing area of all monitors combined into a single theoretical monitor.

relativeWindow WindowIdentifier optional

The window to use when calculating any relative launches. If not set then the window from which spawn() was called.

right optional

A pixel value representing the distance from the right edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the right edge of the viewport relative to the viewport's width.

slave boolean optional

If true then the new window will act as a slave to the relativeWindow (or the launching window if relativeWindow is not specified). Slave windows will automatically close when their parent windows close.

spawnedByWorkspaceService boolean optional
staggerPixels number optional

Number of pixels to stagger (default when neither left, right, top or bottom are set).

top optional

A pixel value representing the distance from the right edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the bottom edge of the viewport relative to the viewport's width.

url string optional

Optional url to launch. Overrides what is passed in "component".

width optional

A pixel or percentage value.

windowIdentifier WindowIdentifier optional

Component instances are often referred to in Finsemble API calls via a windowIdentifier. A windowIdentifier is an object with both windowName and componentType properties.

windowType WindowTypes optional

Optional. Describes which type of component to spawn.

WebWindow - A normal HTML window.

assimilation - A window that is managed by the Finsemble assimilation process (usually a native window without source code access). Requires "path" to be specified, which may be the name of an executable on the system path, a system file path or system installed URI.

native - A native window that has implemented finsemble.dll. Requires "path" to be specified.

application - A standalone application. This launch a component in its own browser process (splintered, giving it dedicated CPU and memory). This can also point to a standalone web application (such as from a third party).

inputParams any

Object or any data type needed by your dialog.

dialogResponseCallback any

called when response received back from dialog window (typically on dialog completion). `responseParameters` is defined by the dialog.

cb StandardCallback optional

Returns response from LauncherClient#spawn

Example
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));
	}
});