Skip to content

Commit

Permalink
04.05.2016 - Fixed new trait error
Browse files Browse the repository at this point in the history
  • Loading branch information
reynoldtan committed Apr 5, 2016
1 parent f20c545 commit 7bdd37a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
14 changes: 12 additions & 2 deletions include/rawpheno.upload.excel.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion include/rawpheno.upload.form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
),
Expand Down
3 changes: 2 additions & 1 deletion theme/js/rawpheno.rawdata.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
d3.json(file, function(error, data) {
if (error) {
// Error reading JSON
throw error;
}
else if(data == 0) {
// No data.
Expand All @@ -64,7 +65,7 @@
}
else {
// Generate Chart.
initializeChart(data)
initializeChart(data);
}
});

Expand Down

0 comments on commit 7bdd37a

Please sign in to comment.