-
Notifications
You must be signed in to change notification settings - Fork 2
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
Creates rawphenotypes germplasm field #88
Conversation
For step #7: downloaded file contains germplasm, location and trait applied, but misses experiment. An additional trait, # of Seeds Planted (count), is always included by default. |
I am now able to see the experiment column on my new dev fresh, PR works as expected. Great job 👍 |
$summary['experiments'] = count(array_unique($cache_exp)); | ||
$summary['locations'] = count(array_unique($cache_loc)); | ||
|
||
$entity->{$field_name}['und'][0]['value']['NCIT:Raw Data'] = array( |
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.
I don't think the value should not be keyed by the field name. Also, you should always use the new array notation: [ ]
rather than the old style for PHP compatibility reasons.
$entity->{$field_name}['und'][0]['value']['NCIT:Raw Data'] = array( | |
$entity->{$field_name}['und'][0]['value'] = array( |
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.
All of the keys exposed through the value should be cvterms and should only represent data. The icons feel out of place here as it relates to the format, not the data. All sub-keys as well so the counts in the summary should also have cvterms as keys.
if ($trait_set) { | ||
foreach($trait_set as $trait_id => $trait_name) { | ||
// Trait id, project id and name + location: | ||
$trait_experiment_location[ $trait_id . '_' . $trait_name ][] = $trait_id . '#' . $item->project_id . '#' . $item->name . '#' . $item->location; |
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.
This feels very pre-formatted for what you want in the formatter. It should likely be broken out into a nested array with cvterm keys and then compiled to this format in the formatter.
// Create markup. | ||
// Refer to this ID for CSS styling. | ||
$id = 'rawphenotypes-germplasm-raw-phenotypes-field'; | ||
$markup = ' |
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.
It feels very weird to see this much HTML in PHP strings... perhaps this should be in a template?
rawpheno.module
Outdated
* Implements hook_field_group_build_pre_render_alter(). | ||
* Apply css and js. | ||
*/ | ||
function rawpheno_field_group_build_pre_render_alter(&$element) { |
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.
won't this add these resources indiscriminately?
excellent documentation Co-authored-by: Lacey-Anne Sanderson <las166@mail.usask.ca>
Revised field formatter to use template file for the markup. I have kept all array construct - array() since it is used throughout the module and I have checked off item My code follows the code style of this project above. In my recent work of the module for Drupal 8/9 all instances of this array have been converted to the short array syntax. |
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.
Code Review
- hook_field_group_build_pre_render_alter() removed and resources added in formatter
- html moved into template file
- formatting removed from the field class
- Keys of values array should all be cvterms
The keys are still incorrect…
// # SUMMARY COUNT:
$summary = array();
$summary['traits'] = count($trait_experiment_location);
$summary['experiments'] = count(array_unique($cache_exp));
$summary['locations'] = count(array_unique($cache_loc));
$entity->{$field_name}['und'][0]['value'] = array(
'user' => $current_user,
'germplasm' => $germplasm,
'summary' => $summary,
'traits' => $trait_experiment_location,
);
All of the array keys should be cvterms! Even the nested ones. This is needed to work with web services.
Here is an example of what I mean:
https://github.com/tripal/trpfancy_fields/blob/master/includes/TripalFields/ChadoChartField.inc#L234-L237
$entity->{$field_name}['und'][0]['value']['hydra:member'][] = array(
'rdfs:label' => $r->{$label_column},
'local:count' => $r->{$count_column},
);
We use the hydra:member
term to indicate an array of data such as your trait locations. This array should not be associative (i.e. keys should be simple iterative numbers) but that should not be a problem in your case as you don't access them by key anyway?
Then you need to create local terms for each associative key. Specifically, the following keys should all be cvterms:
- user
- permission
- experiments
- germplasm
- id
- name
- summary
- traits
- experiments
- locations
- traits
- trait_id
- project_id
- project_name
- location
Revised the field instance and formatter to use cvterms as array keys. I have setup a cv name and named it in the same way as other cvs used by rawphenotypes (ie phenotype_measurement_units, phenotype_measurement_types etc.). I chose the name phenotype_customfield_terms and created the cv terms experiment, id, name, location, summary, experiment, user_experiment and trait to be used as keys. This cv will hold other terms in the future should raw phenotype custom field require other more terms. |
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.
✅ Code looks good with the most recent changes 🎉
On to testing! The field seems to work as intended except for the download functionality. I select a location/experiment for the # Nodes on Primary Stem at R1 (1st; count)
and then click download but the resulting file does not have that trait. I used CDC Robin AGL to test.
I'm also wondering a bit about the design... I'm worried that Kirstin would be most likely to want all locations for a given experiment or even all data for that trait in general. Maybe you add some "ALL" options in the select list?
On it, I will setup the ALL option in the next commit 👍 |
I have added a filter by switch to allow export of phenotypes by either experiment or location + experiment. In addition to this option, users can download everything (all experiment user has permission to) in a trait + germplasm using the download all button preceding each trait. I also add expand table view and search trait to make finding a trait of interest less painful 😄 . Tested
|
I'm loving the new "Export everything in a trait + germplasm" button! Did a quick review on the new code since the last review and I think this is good :-) I'm going to merge now but we won't update KP until July so nothing goes wrong right before the workshop ;-p |
This PR will create a Custom Tripal Field that will add raw phenotypes download functionality to germplasm page.
Metadata
Documentation:
Description
Dependencies
Testing?
Setup
A. A group titled Raw Phenotypes and set the format to Tripal Pane
B. Under this group add an item clicking the + symbol preceding Germplasm Raw Phenotypes Field
NOTE: at the moment the cog icon to update id, classes and visibility option is causing an AJAX error leaving this field to be hidden by default (hide = yes).
The Interface