-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.js
47 lines (41 loc) · 1.67 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(function () {
tableau.extensions.initializeDialogAsync().then(() => {
$("#closeButton").click(closeDialog);
const selectedParameterName = tableau.extensions.settings.get(
"selectedParameterNameKey"
);
tableau.extensions.dashboardContent.dashboard
.getParametersAsync()
.then(function (parameters) {
parameters.forEach(function (parameter) {
if (
parameter.allowableValues.type === tableau.ParameterValueType.List
) {
const listElement = $("<h3>");
$("<input />", {
type: "radio",
id: parameter.name,
name: "HorizontalRadioButtonConfig",
value: parameter.name,
checked: parameter.name === selectedParameterName,
}).appendTo(listElement);
$("<label>", {
for: parameter.name,
text: parameter.name,
}).appendTo(listElement);
$("#parameters").append(listElement);
}
});
});
});
const closeDialog = () => {
const selectedParameterName = $(`input:radio:checked`).val();
tableau.extensions.settings.set(
"selectedParameterNameKey",
selectedParameterName
);
tableau.extensions.settings.saveAsync().then(() => {
tableau.extensions.ui.closeDialog(selectedParameterName);
});
};
})();