Fix and improve styling for links in the datagrids.
Review Request #9080 — Created July 15, 2017 and submitted — Latest diff uploaded
Our datagrids were rendering with extra, unwanted
<a>
tags for some
columns. Part of this was due to an old change that regressed the
link=False
semantics, causing this flag to just result inlink_func
being ignored rather than disabling linking. Another part was due to the
usage of<div>
within<a>
, which isn't legal and caused the browser
to do odd things that easily resulted in duplicate tags. Still another
was the need for rendering custom<a>
tags as part of the cell data
when in need of a custom CSS class (which often resulted in extra tags
given thelink=False
breakage).Now,
link=False
is respected. When provided, links will not be
generated for the row's object in the data automatically. Similarly, if
link_func
fails, the URL won't fall back to the URL for the row's
object.The
<a>
tags no longer contain a<div>
. Instead, we just assign
display: block
to the<a>
. The cell also gained ahas-link
CSS
class to help with styling, so that there's no impact on custom<a>
tags within the cell.Columns can now accept a
link_css_class
attribute, which specifies the
CSS class names (or a function returning them) to apply to the<a>
,
reducing the work that a column has to do and reducing the amount of
data that must be cached.This shouldn't outright break any consumers unless they're using
link=False
and still expecting links to show up (which wasn't really
ever the intended behavior). However, they can now take advantage of
link_css_class
to reduce the data they must render.
Tested with Review Board, both the current upstream and with a change
that takes advantage of the newlink_css_class
.