Skip to content

Conversation

@graysonarts
Copy link

No description provided.

@graysonarts graysonarts force-pushed the parameters-sample-vanilla-js branch from 84a9d9a to a455a6d Compare October 4, 2017 19:57
@graysonarts graysonarts changed the title WIP: Parameters sample no REACT. Parameters sample no REACT. Oct 4, 2017

tableau.extensions.initializeAsync().then(function () {
tableau.extensions.dashboardContent.dashboard.getParametersAsync().then(function (parameters) {
parameters.forEach(processParameter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add something to the HTML page if there are no parameters found? Something like "No parameters found. Add some parameters to this dashboard to see this work."

# Project Frelard

![Image of T-Flex the T-Rex](./assets/tflx.png)
![Image of Flex the T-Rex](./assets/flex.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good :)

const table = $('#parameterTable');
const tableBody = table.children('tbody');

let onParameterChange = function (evt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we standardizing in our samples on 'evt' for event? fine if so just want to make sure we're consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say it's something we necessarily need to standardize on. I've been using fooEvent , i.e. filterEvent. No preference though.

const tableBody = table.children('tbody');

let onParameterChange = function (evt) {
evt.getParameterAsync().then(function (param) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to handle the case where there are no parameters present

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this would go for all the samples. I can go through and update them all after we get the base stuff merged in if you'd prefer @RussTheAerialist. Like his sample my tables all are just empty when the object in question is missing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add something simple.

};

let column = function (value) {
const row = $('<td>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confusing to call (a table 'cell') a row

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

names are hard. It should be cell :)

return row;
};

let allowableValues = function (value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have a comment for this function to explain what it's doing...e.g. 'this will format the text and show the allowed values that can be set for the given filter'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I would second adding more comments in general, a lot of our developers aren't always javascript savvy so I've tried to go a bit heady on the comment side of things.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I'll do a commenting pass this morning.

};

let processParameter = function (p) {
p.addEventListener('parameter-changed', onParameterChange);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the enum value here, tableau.TableauEventType.ParameterChanged

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I didn't know that existed. I was basing this off of the React sample and it used the string. I'll switch to the enum.

@@ -1 +1,64 @@
//TODO
$(document).ready(function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention Samm and I have been following has been to wrap the whole extension inside an anonymous function, leaving our function definitions outside of the document ready branch. I don't know enough about JavaScript to say which way is better but we should probably do to the same thing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an example of what you mean here?

const table = $('#parameterTable');
const tableBody = table.children('tbody');

let onParameterChange = function (evt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note, we are using different function declaration styles. I would lean towards function foo () { }; syntax because I think it's more approachable to non-JS developers (which I'd bundle most Tableau developers into).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I don't have a preference one way or the other for either of those two points.

};

let textColumn = function (value) {
const row = $('<td>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much cleaner syntax than I've been using, I was using the dom API not jquery, so I'll go through and update my samples.

Also if you have time pleas give mine a looksy because I'm sure there are plenty of places I can tidy up :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

@lbrendanl
Copy link
Contributor

This looks sharp thanks again for making. Just a few areas we should sync up on so that our sample code looks more uniform.

@lbrendanl lbrendanl merged commit ec67975 into tableau:V1Samples Oct 5, 2017
lbrendanl added a commit that referenced this pull request Oct 6, 2017
* Added Settings Sample

* added datasource sample

* cleanup

* moved from innerHTML to jquery.text()

* added missing gitignore and removed nod_modules

* Added semistandard linter

* Fixed tslint errors for settings and datasources

* added 0.6.1 with parameter id change

* updating to use 0.6.1

* added filtering sample

* Parameters sample no REACT. (#16)

* removing old images and updating Flex

* Fetching is complete

* Fix style issues

* parity with original demo, but uglier

* Address code review feedback

* moving to wrapping everything into an anonymous function

* Initial tutorial (#17)

* Initial checkin

* Initial react checkin

* Progressing along

* Paste in old readme

* React progress

* Eventing

* Complete functionality

* Switch to modal

* Add loading screens

* readme updates

* Part 0 with links

* Part 1 readme

* Fix links

* More tutorials

* Part 3 readme

* Full res gif

* Part 4

* Part 5

* Part 6 and a complete manfiest

* Clean up initial readme

* Better screenshot for part 3

* Completed screenshot

* Delete unused test stuff

* Cleanup

* Add note about the react version

* first round of feedback responses

* Lint errors for tutorial

* bug fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants