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 eventstring handlerFunction -
checkIfWindowIsDialog(cb)
-
Checks to see whether the window is a dialog.
Name Type Description cbFunction optional The callback to be invoked after the method completes successfully.
-
getParametersFromInDialog()
-
Called from within dialog window to get the parameters passed in
spawnDialogas"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 typestring Component type to open. The
typemust be a key in the finsemble.components configuration object.optionsany Options to pass into the opened window.
onUserInputFunction 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 callbackany 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 callbackFunction The callback to be invoked after the method completes successfully.
-
removeEventListener(event, handler)
-
Removes an event listener added by addEventListener
Name Type Description eventany An event that was used with addEventListener to add a listener
handlerany 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
spawnDialogcallback function (i.e.,dialogResponseCallback) being invoked withresponseParameterspassed in.Name Type Description responseParametersany 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 dataany 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 identifierWindowIdentifier Name Type Description componentTypestring optional The type of component
uuidstring optional Optional uuid of a particular application process
windowNamestring The name of the physical HTML window, or a reference to a native window that was launched with Assimilation service
windowTypestring optional optionsany Any data to send to the dialog for its initialization.
onUserInputany 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 cbFunction 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.inputParamscan be retrieved in the dialog window by callinggetParametersFromInDialog.Name Type Description paramsSpawnParams The parameters passed to Launcher.Spawn.
For properties duplicated between the top-level and `options`, `options` takes precedence.
Name Type Description addToWorkspaceboolean 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.
affinitystring 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.
aliasstring optional Used when windowType is "native" or "assimilation". Specifies the alias of a bundled asset.
argumentsany 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`"
argumentsAsQueryStringboolean 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
bottomoptional 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.
canGroupboolean optional Whether the component can group with other windows.
claimMonitorSpaceboolean 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.
closeComponentsTogetherboolean optional Defaults to false. Whether to close all components within a launchGroup at the same time.
componentany optional Type of component to spawn.
dataany optional Optional data to pass to the opening window. If set, then the spawned window can use WindowClient#getSpawnData to retrieve the data.
dockOnSpawnboolean 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".
dockableoptional An array of parts of the monitor that the component can dock to. Valid values are `top` and `bottom`.
dockedoptional 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.
dockedHeightnumber 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.
envany 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.
ephemeralboolean 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.
forceOntoMonitoroptional If true, will attempt to make the window have no edges outside the monitor boundary.
groupNamestring 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.
groupOnSpawnboolean optional Groups the window to the `relativeWindow` based on their adjacent position.
heightoptional A pixel or percentage value.
launchingWindowany optional Where the spawn request is coming from.
leftoptional 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.
maxHeightnumber optional Maximum height window can be resized to.
maxWidthnumber optional Maximum width window can be resized to.
minHeightnumber optional Minimum height window can be resized to.
minWidthnumber optional Minimum width window can be resized to.
monitoroptional 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.
namestring optional Name to give the component. If not provided, a random one will be generated.
nativeboolean optional optionsany 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.pathstring 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.
positionPositionTypes optional Defines a "viewport" for the spawn, with one of the Position Types:
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:0will place the component overlapping the toolbar.relative - Positioned relative to the relativeWindow. For instance,
left:0;top:0will join the top left corner of the new component with the top left corner of the relative window.virtual - Deprecated. Positioned against coordinates on the virtual screen. The virtual screen is the full viewing area of all monitors combined into a single theoretical monitor.
absolute - Positioned using native operating system coordinates. Only available with showWindow, not with spawn.
relativeWindowidentifier optional The window to use when calculating any relative launches. If not set then the window from which spawn() was called.
rightoptional 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.
setBoundsOnlyboolean optional If true, then visibility of window will not be changed. In otherwords, a hidden window will not be made visible.
slaveboolean 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.
spawnedByWorkspaceServiceboolean optional staggerPixelsnumber optional Number of pixels to stagger (default when neither left, right, top or bottom are set).
toSpawnoptional 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'.
topoptional 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.
urlstring optional Optional url to launch. Overrides what is passed in "component".
widthoptional A pixel or percentage value.
windowIdentifieridentifier 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.
windowTypeWindowTypes 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.
inputParamsany Object or any data type needed by your dialog.
dialogResponseCallbackany called when response received back from dialog window (typically on dialog completion). `responseParameters` is defined by the dialog.
cbStandardCallback 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)); } });