Merge pull request #14319 from snipe/fixes/RB-17889

Check for activeFile before trying to get header on import
This commit is contained in:
snipe 2024-02-23 08:19:21 +00:00 committed by GitHub
commit 3271d020e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,12 +59,21 @@ class Importer extends Component
'field_map' => 'array'
];
/**
* This is used in resources/views/livewire/importer.blade.php, and we kinda shouldn't need to check for
* activeFile here, but there's some UI goofiness that allows this to crash out on some imports.
*
* @return string
*/
public function generate_field_map()
{
\Log::debug("header row is: ".print_r($this->activeFile->header_row,true));
\Log::debug("Field map is: ".print_r($this->field_map,true));
$tmp = array_combine($this->activeFile->header_row, $this->field_map);
return json_encode(array_filter($tmp));
$tmp = array();
if ($this->activeFile) {
$tmp = array_combine($this->activeFile->header_row, $this->field_map);
$tmp = array_filter($tmp);
}
return json_encode($tmp);
}