mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Display error message if import file deleted before it can be selected
This commit is contained in:
parent
439c2e095d
commit
b1199100a0
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\CustomField;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Livewire\Component;
|
||||
|
||||
use App\Models\Import;
|
||||
|
@ -161,6 +162,11 @@ class Importer extends Component
|
|||
|
||||
public function mount()
|
||||
{
|
||||
if (Session::has('error_message')) {
|
||||
$this->message = Session::get('error_message');
|
||||
$this->message_type = 'danger';
|
||||
}
|
||||
|
||||
$this->authorize('import');
|
||||
$this->progress = -1; // '-1' means 'don't show the progressbar'
|
||||
$this->progress_bar_class = 'progress-bar-warning';
|
||||
|
@ -484,8 +490,16 @@ class Importer extends Component
|
|||
|
||||
public function selectFile($id)
|
||||
{
|
||||
$this->clearMessage();
|
||||
|
||||
$this->activeFile = Import::find($id);
|
||||
|
||||
if (!$this->activeFile) {
|
||||
Session::flash('error_message', trans('admin/hardware/message.import.file_missing'));
|
||||
|
||||
return redirect()->route('imports.index');
|
||||
}
|
||||
|
||||
$this->field_map = null;
|
||||
foreach($this->activeFile->header_row as $element) {
|
||||
if(isset($this->activeFile->field_map[$element])) {
|
||||
|
@ -520,6 +534,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.
|
||||
|
|
|
@ -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',
|
||||
],
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue