Skip to content

Commit

Permalink
adding tissue sample search on wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
chris263 committed Feb 4, 2025
1 parent 98b9e8b commit fb9361c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions js/source/entries/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const types = {
"locations": "Locations",
"plots": "Plots",
"plants": "Plants",
"tissue_sample": "Tissue Samples",
"seedlots": "Seedlots",
"trait_components": "Trait Components",
"traits": "Traits",
Expand All @@ -40,6 +41,7 @@ function makeURL(target, id) {
case "accessions":
case "plants":
case "plots":
case "tissue_sample":
return document.location.origin + `/stock/${id}/view`;
break;
case "seedlots":
Expand Down Expand Up @@ -115,10 +117,17 @@ export function WizardSetup(main_id) {
credentials: 'include',
body: formData
}).then(resp => resp.json())
.then(json => {
return json.list.map(d => ({ id: d[0], name: d[1], url: makeURL(target, d[0]) }))
})
})
.then(json => {
if (!json.list) {
return []; // Return an empty array to avoid breaking the code
}
if (!Array.isArray(json.list)) {
console.error("json.list is not an array:", json.list);
return [];
}
return json.list.map(d => ({ id: d[0], name: d[1], url: makeURL(target, d[0]) }));
});
})
// Function which returns the list contents for a given listID
// // Returns type and list of of unique names or objects with a "name" key
// {"type":"typeID","items":["name","name",...]|[{"name":"example"},...]}
Expand Down
4 changes: 2 additions & 2 deletions lib/SGN/Controller/AJAX/BreederSearch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ sub get_data : Path('/ajax/breeder/search') Args(0) {
print STDERR "Validating criteria_list\n";
foreach my $select (@criteria_list) { #ensure criteria list arguments are one of the possible categories
chomp($select);
if (! any { $select eq $_ } ('accessions', 'breeding_programs', 'genotyping_protocols', 'genotyping_projects', 'locations', 'plants', 'plots', 'seedlots', 'trait_components', 'traits', 'trials', 'trial_designs', 'trial_types', 'years', undef)) {
$error = "Valid keys are accessions, breeding_programs, genotyping_protocols, genotyping_projects, locations, plants, plots, seedlots, trait_components, traits, trials, trial_designs, trial_types and years or undef";
if (! any { $select eq $_ } ('accessions', 'breeding_programs', 'genotyping_protocols', 'genotyping_projects', 'locations', 'plants', 'plots', 'tissue_sample','seedlots', 'trait_components', 'traits', 'trials', 'trial_designs', 'trial_types', 'years', undef)) {
$error = "Valid keys are accessions, breeding_programs, genotyping_protocols, genotyping_projects, locations, plants, plots, tissue_sample, seedlots, trait_components, traits, trials, trial_designs, trial_types and years or undef";
$c->stash->{rest} = { error => $error };
return;
}
Expand Down

0 comments on commit fb9361c

Please sign in to comment.