diff --git a/js/source/legacy/CXGN/BreedersToolbox/AddTrial.js b/js/source/legacy/CXGN/BreedersToolbox/AddTrial.js index b893c31d89..672358b4e9 100644 --- a/js/source/legacy/CXGN/BreedersToolbox/AddTrial.js +++ b/js/source/legacy/CXGN/BreedersToolbox/AddTrial.js @@ -651,6 +651,13 @@ jQuery(document).ready(function ($) { //console.log(greenhouse_num_plants); } + var num_rows_per_plot = $('#trial_create_rows_per_plot').val(); + var num_cols_per_plot = $('#trial_create_cols_per_plot').val(); + if ($('#trial_create_rows_and_columns_to_plants').prop('checked') && ($('#add_plant_entries').val() > num_rows_per_plot * num_cols_per_plot || num_rows_per_plot * num_cols_per_plot < Math.max(... greenhouse_num_plants.map(Number))) || num_rows_per_plot * num_cols_per_plot < num_plants_per_treatment) { + alert("You specified in-plot coordinates, but the number of plants per plot is greater than the number of positions available in each plot. Please decrease the number of plants per plot or increase the number of available positions. If this is a greenhouse trial, make sure no accession is specified to have more plants than the number of allowed spaces. If this is a splitplot design, please make sure that the number of plants per plot specified in section (2) matches the number of plants per treatment."); + return; + } + var use_same_layout; if ($('#use_same_layout').is(':checked')) { use_same_layout = $('#use_same_layout').val(); @@ -714,7 +721,9 @@ jQuery(document).ready(function ($) { 'plot_width': plot_width, 'plot_length': plot_length, 'use_same_layout' : use_same_layout, - 'plot_numbering_scheme' : plot_numbering_scheme + 'plot_numbering_scheme' : plot_numbering_scheme, + 'num_cols_per_plot' : num_cols_per_plot, + 'num_rows_per_plot' : num_rows_per_plot }, success: function (response) { $('#working_modal').modal("hide"); @@ -2339,7 +2348,9 @@ jQuery(document).ready(function ($) { Workflow.complete('#new_trial_confirm_submit'); Workflow.focus("#trial_design_workflow", -1); //Go to success page Workflow.check_complete("#trial_design_workflow"); - add_plants_per_plot(); + if (design_type != "greenhouse" && design_type != "splitplot") { + add_plants_per_plot(); + } } }, error: function () { diff --git a/lib/CXGN/Trial/TrialDesign.pm b/lib/CXGN/Trial/TrialDesign.pm index 4311b90635..b2661e32ef 100644 --- a/lib/CXGN/Trial/TrialDesign.pm +++ b/lib/CXGN/Trial/TrialDesign.pm @@ -65,6 +65,10 @@ has 'block_size' => (isa => 'Int', is => 'rw', predicate => 'has_block_size', cl has 'greenhouse_num_plants' => (isa => 'ArrayRef[Int]', is => 'rw', predicate => 'has_greenhouse_num_plants', clearer => 'clear_greenhouse_num_plants'); +has 'num_rows_per_plot' => (isa => 'Int', is => 'rw', predicate => 'has_num_rows_per_plot', clearer => 'clear_num_rows_per_plot'); + +has 'num_cols_per_plot' => (isa => 'Int', is => 'rw', predicate => 'has_num_cols_per_plot', clearer => 'clear_num_cols_per_plot'); + has 'maximum_block_size' => (isa => 'Int', is => 'rw', predicate => 'has_maximum_block_size', clearer => 'clear_maximum_block_size'); has 'plot_name_prefix' => (isa => 'Str', is => 'rw', predicate => 'has_plot_name_prefix', clearer => 'clear_plot_name_prefix'); diff --git a/lib/CXGN/Trial/TrialDesign/Plugin/greenhouse.pm b/lib/CXGN/Trial/TrialDesign/Plugin/greenhouse.pm index ac362e30b3..1fa0716fdb 100644 --- a/lib/CXGN/Trial/TrialDesign/Plugin/greenhouse.pm +++ b/lib/CXGN/Trial/TrialDesign/Plugin/greenhouse.pm @@ -33,12 +33,25 @@ sub create_design { %greenhouse_design = %{$self->_build_plot_names(\%greenhouse_design)}; foreach my $plot_num (keys %greenhouse_design) { + my @plant_coords = (); + if ($self->get_num_rows_per_plot && $self->get_num_cols_per_plot){ + foreach my $row (1..$self->get_num_rows_per_plot) { + foreach my $col (1..$self->get_num_cols_per_plot) { + push @plant_coords, "$row,$col"; + } + } + } my @plant_names; my $plot_name = $greenhouse_design{$plot_num}->{'plot_name'}; my $stock_name = $greenhouse_design{$plot_num}->{'stock_name'}; for my $n (1..$num_accession_hash{$stock_name}) { + my $coord_pair = ""; + if (@plant_coords) { + $coord_pair = shift(@plant_coords); + $coord_pair = "_COORDS{$coord_pair}"; + } my $plant_name = $plot_name."_plant_$n"; - push @plant_names, $plant_name; + push @plant_names, $plant_name.$coord_pair; } $greenhouse_design{$plot_num}->{'plant_names'} = \@plant_names; } diff --git a/lib/CXGN/Trial/TrialDesignStore/AbstractTrial.pm b/lib/CXGN/Trial/TrialDesignStore/AbstractTrial.pm index 3168539ce5..f33cd2cc52 100644 --- a/lib/CXGN/Trial/TrialDesignStore/AbstractTrial.pm +++ b/lib/CXGN/Trial/TrialDesignStore/AbstractTrial.pm @@ -913,13 +913,25 @@ sub store { if ($plant_names) { my $plant_index_number = 1; foreach my $plant_name (@$plant_names) { - + # TODO: EXTRACT COORDS FROM PLANT NAME + my $plant_row; + my $plant_col; + print STDERR "\nCREATING $plant_name\n"; + if ($plant_name =~ m/_COORDS\{(?\d+),(?\d+)\}/) { + $plant_row = $+{ROW}; + $plant_col = $+{COL}; + } + $plant_name =~ s/_COORDS\{\d+,\d+\}//; my @plant_stock_props = ( { type_id => $self->get_plant_index_number_cvterm_id, value => $plant_index_number }, { type_id => $self->get_replicate_cvterm_id, value => $rep_number }, { type_id => $self->get_block_cvterm_id, value => $block_number }, { type_id => $self->get_plot_number_cvterm_id, value => $plot_number } ); + if ($plant_row && $plant_col) { + push @plant_stock_props, {type_id => $self->get_row_number_cvterm_id, value => $plant_row}; + push @plant_stock_props, {type_id => $self->get_col_number_cvterm_id, value => $plant_col}; + } if ($is_a_control) { push @plant_stock_props, { type_id => $self->get_is_control_cvterm_id, value => $is_a_control }; } diff --git a/lib/SGN/Controller/AJAX/Trial.pm b/lib/SGN/Controller/AJAX/Trial.pm index b0d9f498f4..f5eeba0d38 100644 --- a/lib/SGN/Controller/AJAX/Trial.pm +++ b/lib/SGN/Controller/AJAX/Trial.pm @@ -211,6 +211,8 @@ sub generate_experimental_design_POST : Args(0) { my $number_of_unreplicated_stocks = scalar(@unreplicated_stocks); my $greenhouse_num_plants = $c->req->param('greenhouse_num_plants'); + my $num_rows_per_plot = $c->req->param('num_rows_per_plot'); + my $num_cols_per_plot = $c->req->param('num_cols_per_plot'); my $use_same_layout = $c->req->param('use_same_layout'); my $number_of_checks = scalar(@control_names_crbd); @@ -311,7 +313,7 @@ sub generate_experimental_design_POST : Args(0) { $trial_design->set_backend($c->config->{backend}); $trial_design->set_submit_host($c->config->{cluster_host}); $trial_design->set_temp_base($c->config->{cluster_shared_tempdir}); - $trial_design->set_plot_numbering_scheme($plot_numbering_scheme); + $trial_design->set_plot_numbering_scheme($plot_numbering_scheme); my $design_created = 0; if ($use_same_layout) { @@ -384,6 +386,10 @@ sub generate_experimental_design_POST : Args(0) { my $json = JSON::XS->new(); $trial_design->set_greenhouse_num_plants($json->decode($greenhouse_num_plants)); } + if ($num_rows_per_plot && $num_cols_per_plot) { + $trial_design->set_num_rows_per_plot($num_rows_per_plot); + $trial_design->set_num_cols_per_plot($num_cols_per_plot); + } if ($westcott_check_1){ $trial_design->set_westcott_check_1($westcott_check_1); } diff --git a/mason/breeders_toolbox/trial/trial_plants.mas b/mason/breeders_toolbox/trial/trial_plants.mas index 0b7300d1aa..d846c2e4b2 100644 --- a/mason/breeders_toolbox/trial/trial_plants.mas +++ b/mason/breeders_toolbox/trial/trial_plants.mas @@ -59,6 +59,7 @@ jQuery(document).ready(function () { ordering: true, info: true, scrollY: '250px', + scrollX : true, scrollCollapse: true }); var lo = new CXGN.List(); diff --git a/mason/breeders_toolbox/trial/trial_plots.mas b/mason/breeders_toolbox/trial/trial_plots.mas index 806c5443db..403ff9f20f 100644 --- a/mason/breeders_toolbox/trial/trial_plots.mas +++ b/mason/breeders_toolbox/trial/trial_plots.mas @@ -60,6 +60,7 @@ jQuery(document).ready(function () { ordering: true, info: true, scrollY: '250px', + scrollX : true, scrollCollapse: true }); diff --git a/mason/breeders_toolbox/trial/trial_subplots.mas b/mason/breeders_toolbox/trial/trial_subplots.mas index d513333018..a3fb04c1e4 100644 --- a/mason/breeders_toolbox/trial/trial_subplots.mas +++ b/mason/breeders_toolbox/trial/trial_subplots.mas @@ -59,6 +59,7 @@ jQuery(document).ready(function () { ordering: true, info: true, scrollY: '250px', + scrollX : true, scrollCollapse: true });