Skip to content

Conversation

@lbrendanl
Copy link
Contributor

First sample. Please be as nitpicky as possible since this is sample code.

This sample is fairly simple, and just allows you to set some setting values. Should it do more? We could add delete but to me that felt like an extraneous amount of extra UI code for little API instruction.

Are there any JS best practices I am missing that we should try and promote?

@lbrendanl
Copy link
Contributor Author

Should probably scrub all the ES6 syntax for compatibility

@lbrendanl lbrendanl changed the title Added Settings Sample WIP: V1 Samples Oct 3, 2017
@lbrendanl lbrendanl closed this Oct 3, 2017
@lbrendanl lbrendanl reopened this Oct 3, 2017
// To get dataSource info, first get the dashboard.
const dashboard = tableau.extensions.dashboardContent.dashboard;

// Then loop through each worksheet and get its datasources, save promise for later.
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] looks like you are using "dataSources" in other places, should probably be consistent.

});
}, function (err) {
// Something went wrong in initialization.
console.log('Error while Initializing: ' + err.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

we might want to consider using err.message() here. to string returns the error prefix as well ("Error: ") which is a bit redundant with what you have.

// Refreshes the a given dataSource.
function refreshDataSource (dataSource) {
dataSource.refreshAsync().then(function () {
console.log(dataSource.name + ': Refreshed Successfully');
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't ran the sample, so I don't know what it looks like. Are there any UI indications showing the refresh succeeded? If not, creating a popup/alert might be better for demo purposes.

@jz-huang
Copy link
Contributor

jz-huang commented Oct 4, 2017

just some minor comments. everything else looks good to me.

@lbrendanl
Copy link
Contributor Author

@jz-huang Thanks for the comments, all good and will address each one.

Would you mind looking at the recently pushed filters samples? You are the filter expert on our team :) That one is a reading filterInfo and clearing all filters sample. I thought about doing applying filters as well, but decided we should leave that for another sample as the first one was getting pretty long already.

@jz-huang
Copy link
Contributor

jz-huang commented Oct 5, 2017

@lbrendanl definitely. But I don't see the filtering updates. is it in this pr? I still see todo in filtering.js

testbrendan and others added 2 commits October 4, 2017 19:32
* 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
@lbrendanl
Copy link
Contributor Author

@jz-huang sorry it should be there now.

  • @RussTheAerialist for review.

Still TODO on here that I already know of:

  1. Update my creation of UI elements to use jquery style API like Russ's sample
  2. Add the initialization and no rows state like Russ's Sample

});

function fetchFilters () {
unregisterHandlerFunctions.forEach(function (unregisterHandlerFunction) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] it's not obvious at first glance what this does. maybe add comment clarifying.

Everything else looks good to me. Thanks for adding these!

Copy link

@graysonarts graysonarts left a comment

Choose a reason for hiding this comment

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

Mostly just questions on a few things here and there.

infoSpan.className = 'glyphicon glyphicon-info-sign';

let showModalFunction = function () { showModal(dataSource); };
infoSpan.addEventListener('click', showModalFunction);

Choose a reason for hiding this comment

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

I think splitting the function out of the addEventListener makes this more confusing, especially since all you are doing is calling a single function.

infoSpan.addEventListener('click', function () { showModal(dataSource); });

I think that reads better (at least to my eye...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree now that you mention it, will fix, thanks!

});

function fetchFilters () {
unregisterHandlerFunctions.forEach(function (unregisterHandlerFunction) {

Choose a reason for hiding this comment

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

Yeah I think it would be good to have an explanation of what you are unregistering and why.

unregisterHandlerFunctions.push(unregisterHandlerFunction);
});

Promise.all(filterFetchPromises).then(function (fetchResults) {

Choose a reason for hiding this comment

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

I think I need to update my sample to use this pattern.

function buildFiltersTable (filters) {
// Clear the table first.
$('#filtersTable > tbody tr').remove();
const filtersTable = document.getElementById('filtersTable').getElementsByTagName('tbody')[0];

Choose a reason for hiding this comment

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

Why do you fall back to DOM access rather than jquery here?

$('#filtersTable > tbody:first')  // This should work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No good reason :) will fix.

switch (filter.filterType) {
case 'categorical':
filter.appliedValues.forEach(function (value) {
filterValues += value.formattedValue + ', ';

Choose a reason for hiding this comment

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

// Something to this effect:  Not sure if that's more readable or not, but it avoids a bunch of string copying
filterValues = filter.appliedValues.map(function (v) { return v.formattedValue) }).join(', ');

dashboard.worksheets.forEach(function (worksheet) {
worksheet.getFiltersAsync().then(function (filtersForWorksheet) {
filtersForWorksheet.forEach(function (filter) {
worksheet.clearFilterAsync(filter.fieldName);

Choose a reason for hiding this comment

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

Do you need to wait for these to finish?

sdesmond46 and others added 4 commits October 5, 2017 17:10
* 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
@lbrendanl lbrendanl merged commit f403070 into dev Oct 6, 2017
@lbrendanl lbrendanl deleted the V1Samples branch October 6, 2017 21:42
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.

7 participants