Merge pull request #13638 from marcusmoore/bug/sc-20704

Fixed exception being thrown when selected import was deleted
This commit is contained in:
snipe 2023-09-26 15:00:35 +01:00 committed by GitHub
commit 660abeca9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View file

@ -484,8 +484,17 @@ class Importer extends Component
public function selectFile($id)
{
$this->clearMessage();
$this->activeFile = Import::find($id);
if (!$this->activeFile) {
$this->message = trans('admin/hardware/message.import.file_missing');
$this->message_type = 'danger';
return;
}
$this->field_map = null;
foreach($this->activeFile->header_row as $element) {
if(isset($this->activeFile->field_map[$element])) {
@ -520,6 +529,12 @@ class Importer extends Component
}
}
public function clearMessage()
{
$this->message = null;
$this->message_type = null;
}
public function render()
{
$this->files = Import::orderBy('id','desc')->get(); //HACK - slows down renders.

View file

@ -51,6 +51,7 @@ return [
'success' => 'Your file has been imported',
'file_delete_success' => 'Your file has been been successfully deleted',
'file_delete_error' => 'The file was unable to be deleted',
'file_missing' => 'The file selected is missing',
'header_row_has_malformed_characters' => 'One or more attributes in the header row contain malformed UTF-8 characters',
'content_row_has_malformed_characters' => 'One or more attributes in the first row of content contain malformed UTF-8 characters',
],

View file

@ -303,6 +303,7 @@
};
data.process().done( function () {data.submit();});
@this.progress = 0;
@this.clearMessage();
},
progress: function(e, data) {
@this.progress = parseInt((data.loaded / data.total * 100, 10));