diff --git a/include/rawpheno.upload.excel.inc b/include/rawpheno.upload.excel.inc index e339424..e25f707 100755 --- a/include/rawpheno.upload.excel.inc +++ b/include/rawpheno.upload.excel.inc @@ -15,10 +15,11 @@ * @param $job_id * The tripal job id. */ -function rawpheno_load_spreadsheet($fid, $plantprop_headers, $job_id) { +function rawpheno_load_spreadsheet($arr_newheaders, $fid, $plantprop_headers, $job_id) { // Unserialize and remove formating for the headers that should be saved as // plant properties rather than measurements. $plantprop_headers = unserialize($plantprop_headers); + $arr_newheaders = unserialize($arr_newheaders); // First we load the file. $file = file_load($fid); @@ -154,7 +155,16 @@ function rawpheno_load_spreadsheet($fid, $plantprop_headers, $job_id) { // Get the column header of a cell. $cell_colheader = str_replace(array("\n", "\r", " "), ' ', $header[$cell_index]); - + + // Determine if user wants to save this trait. + if (count($arr_newheaders) > 0 AND array_key_exists($cell_colheader, $arr_newheaders)) { + if ($arr_newheaders[$cell_colheader] == 0) { + // Skip this cell if it is a new column header and user does not want to save + // this new trait; + continue; + } + } + // We always want to strip flanking white space. // FYI: This is done when the data is validated as well. $cell_entry = trim($cell_entry); diff --git a/include/rawpheno.upload.form.inc b/include/rawpheno.upload.form.inc index a7b1ff1..9c59b6d 100755 --- a/include/rawpheno.upload.form.inc +++ b/include/rawpheno.upload.form.inc @@ -479,12 +479,19 @@ function rawpheno_submit_review($form, &$form_state) { // Read variable that holds new column headers. $new_header = $form_state['multistep_values']['new_headers']; + // Create an array of new hearders with flag/status if user wants to save it. + // This array will be passed to rawpheno_load_spreadsheet. + $arr_newheaders = array(); + // Determine if there is new header. if (count($new_header) > 0) { // Read each column header. foreach($new_header as $i => $header) { - + + $flag = ($form_state['values']['chk_' . $i] == 1) ? 1 : 0; + $arr_newheaders[$header] = $flag; + // Determine if the form in review traits has been filled out and checkbox // has been checked by user. If it has been chcked then save the trait. if ($form_state['values']['chk_' . $i] == 1) { @@ -571,6 +578,7 @@ function rawpheno_submit_review($form, &$form_state) { 'rawpheno', 'rawpheno_load_spreadsheet', array( + serialize($arr_newheaders), $form_state['multistep_values']['fid'], serialize($plantprop_headers) ), diff --git a/theme/js/rawpheno.rawdata.script.js b/theme/js/rawpheno.rawdata.script.js index 561ffc3..638c8e3 100755 --- a/theme/js/rawpheno.rawdata.script.js +++ b/theme/js/rawpheno.rawdata.script.js @@ -49,6 +49,7 @@ d3.json(file, function(error, data) { if (error) { // Error reading JSON + throw error; } else if(data == 0) { // No data. @@ -64,7 +65,7 @@ } else { // Generate Chart. - initializeChart(data) + initializeChart(data); } });