Skip to content

Dataviewer bugfixes, multisort - #6785

Merged
jmcphers merged 5 commits into
masterfrom
bugfix/datatables-infobar-sorting
May 1, 2020
Merged

jmcphers merged 5 commits into
masterfrom
bugfix/datatables-infobar-sorting

Conversation

@adamconroy

@adamconroy adamconroy commented Apr 30, 2020 •

Copy link
Copy Markdown
Contributor

Commit 5d4b8db and 4264064
Fixes #4517
Fixes #3465

Commit ff3e2f8
Fixes #3888

Commit faec964
Fixes #1691

@adamconroy
adamconroy requested a review from jmcphers April 30, 2020 20:24
@adamconroy

Copy link
Copy Markdown
Contributor Author

One minute, need to add a polyfill for Element.closest because of course IE11 doesn't support it...

@gtritchie

Copy link
Copy Markdown
Member

One minute, need to add a polyfill for Element.closest because of course IE11 doesn't support it...

At some point should we add a build step that consolidates our increasing number of polyfills into a single script to reduce downloads when starting up?

@adamconroy

Copy link
Copy Markdown
Contributor Author

We should definitely add a generic polyfill step like babel core eventually. Unfortunately our setup is so funky (this polyfill for the dataviewer wouldn't be encapsulated in a normal build step because it's iframed in) that making it generic and consistent without a big overhaul will be tricky.

{
nTr = nTrIn || document.createElement('tr');
nTr.setAttribute("data-row", iRow);
nTr.setAttribute("data-row", iRow + oSettings._iDisplayStart);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Found that if you made the window small enough such that it was AJAXing data in constantly the row number would be off here as iRow doesn't encapsulate the data pagination.

@adamconroy

Copy link
Copy Markdown
Contributor Author

Found a couple small bugs in the code that I fixed and added the polyfill. This is now ready for review.

idx <- cols[[i]]
if (length(x[[idx]]) > 0)
{
if (dirs[[i]] == "asc")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Because of R's wonky comparison semantics, use identical(x, y) to compare strings instead of == (for pretty much the same reasons === is generally preferred over == in JS)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The most famous example:

> x <- NULL
> y <- "foo"
> if (x == y) message("Equality achieved")
Error in if (x == y) message("Equality achieved") : 
  argument is of length zero

std::string ordercolstr = "order[" + std::to_string(orderIdx) + "][column]";
std::string orderdirstr = "order[" + std::to_string(orderIdx) + "][dir]";
ordercol = http::util::fieldValue<int>(fields, ordercolstr, -1);
orderdir = http::util::fieldValue<std::string>(fields, orderdirstr, "asc");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
orderdir = http::util::fieldValue<std::string>(fields, orderdirstr, "asc");
orderdir = http::util::fieldValue<std::string>(fields, orderdirstr, "asc");

@jmcphers
jmcphers merged commit 90d4f2a into master May 1, 2020
@valerie-rstudio
valerie-rstudio deleted the bugfix/datatables-infobar-sorting branch January 21, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants