Skip to content

Commit ccc8afd

Browse files
authored
Updating formatting examples (#418)
1 parent c1a9f46 commit ccc8afd

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

Samples-Typescript/Formatting/formatting.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,34 @@ import * as ReactDOM from 'react-dom';
1414
}
1515

1616
private async Render() {
17+
if (tableau.extensions.environment.workbookFormatting) {
18+
await this.RenderFormatting();
19+
} else {
20+
await this.RenderInfoMissing();
21+
}
22+
}
23+
24+
private async RenderFormatting() {
1725
const tooltipClassNames = 'tooltiptext ' + tableau.ClassNameKey.Tooltip;
1826

1927
ReactDOM.render(<>
2028
<h2 className={tableau.ClassNameKey.WorksheetTitle}>Subheader, using tableau-worksheet-title class</h2>
21-
<text className={tableau.ClassNameKey.Worksheet}>Text, using worksheet class</text>
29+
<text className={tableau.ClassNameKey.Worksheet}>Text, using tableau-worksheet class</text>
2230
<h3 className='tooltip-header'>Hover to see tooltip text, which is using tableau-tooltip class
2331
<span className={tooltipClassNames}>Tooltip text, using tableau-tooltip class</span>
2432
</h3>
2533
<li className={tableau.ClassNameKey.StoryTitle}>Bullet Point, using tableau-story-title class</li>
2634
<text className={tableau.ClassNameKey.DashboardTitle}>Text, using tableau-dashboard-title class</text>
2735
</>, document.getElementById('formattingExample'));
2836
}
37+
38+
private async RenderInfoMissing() {
39+
const message = 'Tableau formatting information for extensions is missing from this version of Tableau.';
40+
41+
ReactDOM.render(<>
42+
<div style={{color: 'blue'}}>{message}</div>
43+
</>, document.getElementById('formattingExample'));
44+
}
2945
}
3046

3147
console.log('Initializing Formatting extension.');

Samples/Formatting/formatting.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<h1>Tableau Formatting Sample</h1>
5959
<button id="initTableauButton" class="btn btn-primary">Click to Initialize the Extension</button>
6060
<h2 class="tableau-worksheet-title">Subheader, using tableau-worksheet-title class</h2>
61-
<text class="tableau-worksheet">Text, using worksheet class</text>
61+
<text class="tableau-worksheet">Text, using tableau-worksheet class</text>
6262
<h3 class="tooltip-header">Hover to see tooltip text, which is using tableau-tooltip class
6363
<span class="tooltiptext tableau-tooltip">Tooltip text, using tableau-tooltip class</span>
6464
</h3>
@@ -77,13 +77,17 @@ <h3 class="tooltip-header">Hover to see tooltip text, which is using tableau-too
7777
<script>
7878
$("#initTableauButton").click(function () {
7979
tableau.extensions.initializeAsync().then(function () {
80-
console.log("Done!!!");
80+
console.log("initializeAsync finished");
8181
console.log(tableau.extensions.dashboardContent.dashboard);
82-
console.log(tableau.extensions.environment.workbookFormatting.formattingSheets);
82+
if (tableau.extensions.environment.workbookFormatting) {
83+
console.log(tableau.extensions.environment.workbookFormatting.formattingSheets);
84+
$('#initializeExtensionComment').hide();
85+
} else {
86+
$('#initializeExtensionComment').text('Tableau formatting information for extensions is missing from this version of Tableau');
87+
}
8388
$('#initTableauButton').text('Extension Initialized');
84-
$('#initializeExtensionComment').hide();
8589
}, function (err) {
86-
console.log("Error!!!: " + err);
90+
console.error("Error during initializeAsync: " + err);
8791
});
8892
})
8993
function toggleClassAndText(newClass) {
@@ -93,11 +97,11 @@ <h3 class="tooltip-header">Hover to see tooltip text, which is using tableau-too
9397
$('#toggleFormattingButton').text('Currently ' + newClass + ' below');
9498
}
9599
$('#toggleFormattingButton').click(function () {
96-
if ($('#toggleFormattingButton').text().includes('tableau-worksheet-title')) {
97-
toggleClassAndText('tableau-dashboard-title');
100+
if ($('#toggleFormattingButton').text().includes(tableau.ClassNameKey.WorksheetTitle)) {
101+
toggleClassAndText(tableau.ClassNameKey.DashboardTitle);
98102
}
99103
else {
100-
toggleClassAndText('tableau-worksheet-title');
104+
toggleClassAndText(tableau.ClassNameKey.WorksheetTitle);
101105
}
102106
})
103107
</script>

lib/tableau.extensions.1.latest.js

Lines changed: 8 additions & 7 deletions
Large diffs are not rendered by default.

lib/tableau.extensions.1.latest.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)