Skip to content

Commit 11da2ce

Browse files
committed
add multiple dialog boxes
1 parent bf1fbd4 commit 11da2ce

6 files changed

Lines changed: 154 additions & 55 deletions

File tree

website/docs/Interaction_Guidelines/ux_controls_ui_patterns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Dropdown controls allow multiple options to be expanded from a menu. Dropdowns h
191191
| --- | --- |
192192
| **Outline** | The outline style is the primary variation that should be used. It can be used by itself, on forms, or within dialogues. |
193193
| **Line**<br/>(label optional) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Line style dropdowns are useful in areas that have cramped vertical space. This dropdown style can be stacked within panels to avoid a boxy wireframe feel. While the label is optional, we encourage using it to better inform users about the category of items. |
194-
| **Text** | This style allows the user to access options from a dropdown or flyout menu. This style works well in tool and start bars, as well as in dialogs and menus. |
194+
| **Text** | This style allows the user to access options from a dropdown or flyout menu. This style works well in tool and start bars, as well as in dialogs and menus. |
195195
| **Icon** | The icon style works best in small regions such as tool bars, and is great for switches that have several options. |
196196

197197
&nbsp;

website/docs/core/trex_configure.md

Lines changed: 109 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
2-
title: Add a Configuration Popup Dialog
2+
title: Add a Configuration Popup Dialog Box
33
description: How to add a configuration dialog box to the extension
44
---
55

6-
If you want users to be able to configure settings for your extension, you can use an optional callback function when you initialize your dashboard or viz extension. The callback function creates a configuration option that can be used to open a popup window (a modal dialog box) for your extension. You can use this popup window to allow users to set and save settings for the extension.
7-
6+
If you want users to be able to configure settings for your extension, you can use an optional callback function when you initialize your dashboard or viz extension. The callback function creates a configuration option that can be used to open a popup window (dialog box) for your extension. The Extensions API supports different dialog box styles: modal, modeless, or window. You can use the dialog box to allow users to set and save settings for the extension. Starting with Tableau 2026.1 (and the v1.16 library), you can create multiple dialog boxes and send messages between them.
87

98
## Add the context menu to the `.trex` file
109

11-
The first step is to add the `<context-menu>` option to the extension's manifest file (`.trex`). The `<context-menu>` element only contains one item: `<configure-context-menu-item />`.
10+
The first step is to add the `<context-menu>` option to the extension's manifest file (`.trex`). The `<context-menu>` element only contains one item: `<configure-context-menu-item />`.
1211

13-
* The context menu option must follow the `<icon>` and `<permissions>` elements in the manifest file in the `<dashboard-extension>` or `<worksheet-extension>` section:
12+
* The context menu option must follow the `<icon>` and `<permissions>` elements in the manifest file in the `<dashboard-extension>` or `<worksheet-extension>` section:
1413

1514
```xml
1615
<!-- add to <dashboard-extension> or <worksheet-extension> section
@@ -36,7 +35,6 @@ with adding a `<context-menu>` item to the manifest, adds a new **Format Extensi
3635

3736
When the user selects the context menu item, or selects **Format Extensions** button, the configuration function you specified is executed.
3837

39-
4038
**Dashboard extensions configuration menu**
4139

4240
![](../assets/extension_configure_menu.png)
@@ -69,7 +67,6 @@ $(document).ready(function () {
6967

7068

7169

72-
7370
function configure() {
7471
// ... code to configure the extension
7572
// for example, set up and call displayDialogAsync() to create the configuration window
@@ -82,9 +79,11 @@ $(document).ready(function () {
8279
// to be updated if the extension is deployed to a new location.
8380
const popupUrl = `${window.location.origin}/Samples/Dashboard/UINamespace/uiNamespaceDialog.html`;
8481
//
82+
// Specify the style of dialog box: modal, modeless, or window
83+
let dialogStyle = tableau.DialogStyle.Modeless;
8584
// ...
8685
// initial payload string value, `defaultIntervalInMin` set
87-
tableau.extensions.ui.displayDialogAsync(popupUrl, defaultIntervalInMin, { height: 500, width: 500 }).then((closePayload) => {
86+
tableau.extensions.ui.displayDialogAsync(popupUrl, defaultIntervalInMin, { height: 500, width: 500, dialogStyle }).then((closePayload) => {
8887
// The promise is resolved when the dialog has been expectedly closed, meaning that
8988
// the popup extension has called tableau.extensions.ui.closeDialog.
9089
// ...
@@ -136,3 +135,105 @@ In your code to close the popup window, you must pass a *non-empty* string value
136135
```
137136

138137
To better understand how to use the context menu or configuration window, and to see it in action, check out the [UINamespace](https://github.com/tableau/extensions-api/tree/master/Samples/Dashboard/UINamespace?=target="_blank") sample.
138+
139+
## Create multiple popup dialog boxes or windows
140+
141+
Starting with Tableau 2026.1, you can create more than one popup window or dialog box for your extension. In addition to the optional configuration popup that you can create when you initialize the extension, you can have your extension open other dialog boxes, by adding buttons and controls to your extension. If you are creating multiple dialog boxes, you need to consider how you want them to interact with each other and the user. You can control whether the popup windows are modal or modeless, and whether they need to share information and payloads. If you have multiple popup windows, you'll need to track which popup window is active, so you can control their interactions.
142+
143+
### The default configuration window
144+
145+
By design, there can be only one context configuration item. For dashboard extensions, this is the popup dialog box that appears when users select the **Configure..** option from the context menu. For viz extensions, this is the dialog box that appears when users select the **Format Extension** button on the Marks card.
146+
147+
The configuration item is specified in the `.trex` file for the extension.
148+
149+
```xml
150+
<!-- add to <dashboard-extension> or <worksheet-extension> section
151+
after <icon></icon>
152+
and <permissions></permissions> -->
153+
154+
<context-menu>
155+
<configure-context-menu-item />
156+
</context-menu>
157+
158+
```
159+
160+
And by specifying a callback function (`configure()`) that gets called when the `'configure'` option is specified in the call to initialize the extension (`initializeAsync()`).
161+
162+
```javascript
163+
$(document).ready(function () {
164+
tableau.extensions.initializeAsync({'configure': configure}).then(function() {
165+
// When the user clicks the Configure... context menu item,
166+
// or Format Extension, the configure() function specified
167+
// as the argument here is executed.
168+
//
169+
});
170+
171+
```
172+
173+
If you are creating additional popup windows, you'll need to call those popup windows from other methods, and you'll need to add controls to call those methods. For example, you could add a button or toolbar item in the main extension window, and use that button to open another popup window. The content and logic of the dialog boxes or windows are typically in HTML and JavaScript files that are separate from the main extension files.
174+
175+
### Create additional popup windows
176+
177+
Starting in Tableau 2026.1, you can create multiple popup windows. While you can't display these additional dialog boxes or windows when the user selects the configure context item, you can display them when users click buttons and controls in your extension.
178+
179+
* Determine how you want the pop windows to interact (if at all). Should they be modal or modeless? Do they need to share information or content?
180+
181+
* To create additional dialog boxes or popup windows, add controls (buttons, toolbars) to your extension.
182+
183+
* Create the HTML and JavaScript code that define the content and features of your additional popup windows.
184+
185+
* In your extension JavaScript or TypeScript code, define your popup windows: the `popupURL`, the dialog style, and dimensions, and any initial payload you want to send to the popup window. Pass in these values when you call the `displayDialogAsync()` method.
186+
187+
Like the configuration popup, the URL of the additional popup windows must belong to the same domain as the parent extension. The relative paths must resolve to the directory, or a child directory, of the extension. Root-relative paths are not allowed. For example, `./config.html` or `config.html` are allowed, but not the root-relative path `/config.html`.
188+
189+
For example, you could add another dialog box to the uiNamespace sample that lets users set the background color of the extension. In the `uiNamespace.html` file, you could add a button to display the popup window. When the user clicks the button, a color formatting dialog opens. The user can select the background color. When the user clicks a Save button, it calls the `closeDialog()` method and closes the popup window, which returns the new background color as the payload and it is applied.
190+
191+
```html
192+
<button id="openColorDialog" class="btn btn-secondary" style="margin-top: 10px; margin-left: 6px">Set Background Color</button>
193+
```
194+
195+
In the `uiNamespace.js` file, you would add code to set the default background color and then call the `displayDialogAsync()`. You would need to create the HTML and Javascript code for the popup window (for example, uiNamespaceColorDialog.html and uiNamespaceColorDialog.js).
196+
197+
```javascript
198+
199+
/**
200+
* Sets the default background color
201+
* Sets the current color to match as the initial payload
202+
*/
203+
204+
const defaultBgColor = '#FFFFFF';
205+
let currentBgColor = defaultBgColor;
206+
207+
/**
208+
* Opens the background color picker dialog (always modal).
209+
* Passes the current background color as the initial payload so the dialog
210+
* can pre-select it. The closePayload returned is the chosen hex color,
211+
* which is then applied to the extension body.
212+
*/
213+
214+
function openColorDialog () {
215+
const popupUrl = new URL('uiNamespaceColorDialog.html', window.location.href).href;
216+
217+
tableau.extensions.ui
218+
.displayDialogAsync(popupUrl, currentBgColor, { height: 500, width: 360, dialogStyle: tableau.DialogStyle.Modal })
219+
.then((closePayload) => {
220+
currentBgColor = closePayload;
221+
$('body').css('background-color', currentBgColor);
222+
})
223+
.catch((error) => {
224+
if (error.errorCode === tableau.ErrorCodes.DialogClosedByUser) {
225+
console.log('Color dialog was closed by user');
226+
} else {
227+
console.error(error.message);
228+
}
229+
});
230+
}
231+
```
232+
233+
234+
235+
236+
237+
238+
239+
## Send messages between configuration windows and the extension

website/docs/dashext/trex_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To create a Tableau extension you need the following components.
1717

1818
### What you need to get started
1919

20-
These instructions assume that you already have cloned or download the Extensions API SDK. For information about setting up your environment and the Tableau requirements, see [Installation](../installation.md) and [Get Started with Dashboard Extensions](trex_getstarted.md).
20+
These instructions assume that you already have cloned or downloaded the Extensions API SDK. For information about setting up your environment and the Tableau requirements, see [Installation](../installation.md) and [Get Started with Dashboard Extensions](trex_getstarted.md).
2121

2222
For convenience, you might want to create a folder for your "Hello World" dashboard extension in the same location where you installed or cloned the GitHub repository (for example, `HelloDemo` under `/extensions-api`). That way, you can use the same web server (`http-server`) that is used for the samples.
2323

0 commit comments

Comments
 (0)