-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render trait display names everywhere #472
Render trait display names everywhere #472
Conversation
Fixes rendering error if tags list is shorter than other columns (height-wise)
…store-multiple-name-fields
Replaces ad-hoc object construction with a structured query. This is the same query we run to fill out the offcanvas sidebar. Removes `data-description` and `data-species` fields from table rows, since we're now looking this information up in the database directly.
Store as Jinja dict linked to tool bp name. Rendered with macros.
Adds new class method for `PhenotypeReport` to recompute all cached names.
- Replace `trait_{n}_name` with `trait_{n}_name_caendr` - Compute display name(s) when creating new report & in the recompute function - Now use `trait_{n}_name_display` directly to render report page
… trait in selector properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. See inline comments.
src/modules/site-v2/templates/tools/phenotype_database/submit-traits.html
Show resolved
Hide resolved
}); | ||
} | ||
} | ||
// function filter_by_species(species) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can remove commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. See inline comments
.fail((error) => { | ||
// If an error message was received, display it, otherwise use a fallback message | ||
console.error(error); | ||
const resp = error.responseJSON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if throwing from line 144
, will the property .responseJSON
be present in the error
object?
Also, it might be helpful to document the expected shape of the error.responseJSON
structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this would be an API call error, not a JS error from the success block.
As far as I can tell, error objects always have a responseJSON
property, although I do check in the next line to make sure the object exists (if (resp ...
)
// If an error message was received, display it, otherwise use a fallback message | ||
console.error(error); | ||
const resp = error.responseJSON | ||
if (resp && resp.message && false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we clarify the intention here? assuming resp
is object/null, resp.message
is undefined/string/object then using false
appears to convolute the intention with mixed types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I think I threw false
in here because I wanted to keep this structure (which I use elsewhere for error handling) but I only want to flash the default message? Usually it's if (resp && resp.message)
, to just check if the message
field exists. Definitely weird though, I'll clean it up.
Updates all pages/widgets that deal with traits to use the full trait display names. This includes:
Notes:
PhenotypeReport
objects cache the display name, so we can render them in the My Reports page without having to ping the database 1~2x for every report. I've added a DbOp that re-computes these cached names, just in casedisplay_name_1
field. If we wanted to, we could try to split these names up based on the columns in the sheet.