package SGN::View::Mason::Commands;
use strict;
use vars qw($m $c);
HTML::Mason::Component::FileBased->new(
'code' => sub {
use utf8; local $SGN::View::Mason::Commands::m = $HTML::Mason::Commands::m;
HTML::Mason::Exception::Params->throw
    ( error =>
      "Odd number of parameters passed to component expecting name/value pairs"
    ) if @_ % 2;
my ( $trial_id, $trial_name, $trial_stock_type );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }

    foreach my $arg ( qw( trial_id ) )
    {
        HTML::Mason::Exception::Params->throw
            ( error => "no value sent for required parameter '$arg'" )
                unless exists $pos{$arg};
    }
#line 3 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
    $trial_id = $_[ $pos{'trial_id'} ];
#line 4 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
     $trial_name = exists $pos{'trial_name'} ? $_[ $pos{'trial_name'} ] :  undef;
#line 5 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
     $trial_stock_type = exists $pos{'trial_stock_type'} ? $_[ $pos{'trial_stock_type'} ] :  undef;
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 1 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print( '
' );
#line 7 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print( '

<div class="modal fade" id="download_datacollector_dialog" name="download_datacollector_dialog" tabindex="-1" role="dialog" aria-labelledby="downloadDatacollectorDialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="downloadDatacollectorDialog">Download Datacollector for ' );
#line 14 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print(  $trial_name  );
#line 14 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print( '</h4>
      </div>
      <div class="modal-body">
        <div class="container-fluid">

	       <form class="form-horizontal" role="form" method="post" >
	        <div class="form-group">
                <label class="col-sm-3 control-label">Trait List: </label>
                <div class="col-sm-9" >
                    <div id ="trait_list_dc">
                    </div>
                </div>
	        </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">Data Level: </label>
                <div class="col-sm-9" >
                    <select class="form-control" id="download_datacollector_data_level">
                        <option value="plots">Plots</option>
                        <option value="plants">Plants</option>
                    </select>
                </div>
	        </div>
	       </form><br/>

        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" name="download_datacollector_cancel_button" id="download_datacollector_cancel_button" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" name="create_DataCollector_submit_button" id="create_DataCollector_submit_button" title="Submit">Submit</button>
      </div>
    </div>
  </div>
</div>

<script>

jQuery(document).ready(function() {

  jQuery(\'#create_DataCollector_link\').click( function () {
    jQuery(\'#download_datacollector_dialog\').modal("show");
    var list = new CXGN.List();
    jQuery("#trait_list_dc").html(list.listSelect("trait_list_dc", [ \'traits\' ], undefined, undefined, undefined));
  });

  jQuery(\'#create_DataCollector_submit_button\').click( function () {
    create_DataCollector();
  });

});


function create_DataCollector() {
    var list = new CXGN.List();
    var trait_list_id = jQuery(\'#trait_list_dc_list_select\').val();
    var trait_list;
    if (! trait_list_id == "") {
        trait_list = JSON.stringify(list.getList(trait_list_id));
    }
    else {
        alert("You must select a Trait List first");
        return;
    }
    var trial_stock_type = "' );
#line 76 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print(  $trial_stock_type  );
#line 76 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print( '";

    jQuery.ajax({
        type: \'POST\',
        url: \'/ajax/phenotype/create_DataCollector\',
        dataType: "json",
        data: {
            \'trial_id\': ' );
#line 83 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print(  $trial_id  );
#line 83 "/home/production/cxgn/sgn/mason/breeders_toolbox/trial/create_datacollector_dialog.mas"
$m->print( ',
            \'trait_list\': trait_list,
            \'data_level\': jQuery("#download_datacollector_data_level").val(),
            \'trial_stock_type\': trial_stock_type, 
        },
        beforeSend: function() {
            jQuery(\'#working_modal\').modal("show");
        },
        success: function (response) {
            jQuery(\'#working_modal\').modal("hide");

            if (response.error) {
                alert("Error: "+response.error);
                jQuery(\'#download_datacollector_dialog\').modal("hide");
            } else {
                //alert("success: "+response.filename);
                jQuery(\'#download_datacollector_dialog\').modal("hide");
                jQuery(\'#working_modal\').modal("hide");
                window.location.href = "/download/"+response.filename;
            }
        },
        error: function () {
            jQuery(\'#working_modal\').modal("hide");
            alert(\'An error occurred creating a DataCollector file.\');
            jQuery(\'#download_datacollector_dialog\').modal("hide");
        }
    });
}


</script>
' );
;return;
},
'declared_args' => {
  '$trial_id' => { default => undef },
  '$trial_name' => { default => ' undef' },
  '$trial_stock_type' => { default => ' undef' }
},
'load_time' => 1763102299,

)
;