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
-
addEventListener(event, handler)
-
Name Type Description event
string handler
Function -
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 tospawnDialog
, and retrieve the value usinggetParametersFromInDialog
.Example
var dialogData = FSBL.Clients.DialogManager.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.
-
removeEventListener(event, handler)
-
Removes an event listener added by addEventListener
Name Type Description event
any An event that was used with addEventListener to add a listener
handler
any The handler that was used with addEventListener for the event
-
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 withresponseParameters
passed in.Name Type Description responseParameters
any The parameters returned to parent (i.e., window that spawned the dialog).
Example
FSBL.Clients.DialogManager.respondAndExitFromInDialog({ choice: response });
-
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 Name Type Description componentType
string optional The type of component
uuid
string optional Optional uuid of a particular application process
windowName
string The name of the physical HTML window, or a reference to a native window that was launched with Assimilation service
windowType
string optional 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 callinggetParametersFromInDialog
.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. Users will be prevented from moving windows to a position that covers the claimed space.
closeComponentsTogether
boolean optional Defaults to false. Whether to close all components within a composite component at the same time.
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
PositionTypes optional Defines a "viewport" for the spawn, with one of the
Position Types
values.relativeWindow
identifier 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.
setBoundsOnly
boolean optional If true, then visibility of window will not be changed. In otherwords, a hidden window will not be made visible.
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).
toSpawn
optional An array of objects defining the components to spawn. Each entry may either represent a single component in the form `{componentType, spawnOptions}` or a tabbed window of components in the form `{components, spawnOptions}`, where `components` is an array of single component definitions (again in the form `{componentType, spawnOptions}`). Most arguments that are normally passed to `LauncherClient.spawn` are supported, although positioning will be interpreted as relative to the group's coordinates and dimensions for single components and ignored for tabbed components (as these use the position specified in the group's spawnOptions). Note - This param will only be taken into account if the {@see windowType} param is 'composite'.
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
identifier 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).
composite - A component made of other components, usually group together. See {@see toSpawn} property.
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 The callback to be invoked if the method fails.
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)); } });