diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 8af05fe9c5..f72eae9855 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -22,13 +22,15 @@ class Importer extends Component public $message; //status/error message? public $message_type; //success/error? + public $import_errors; // + protected $rules = [ 'files.*.file_path' => 'required|string', 'files.*.created_at' => 'required|string', 'files.*.filesize' => 'required|integer' ]; - protected $listeners = ['hideDetails' => 'hideDetails']; + protected $listeners = ['hideDetails' => 'hideDetails', 'importError' => 'importError']; public function mount() { @@ -43,6 +45,13 @@ class Importer extends Component $this->message=''; } + public function importError($errors) + { + \Log::info("Errors fired!!!!"); + \Log::info(" Here they are...".print_r($errors,true)); + $this->import_errors = $errors; + } + public function toggleEvent($id) { Log::error("toggled on: ".$id); diff --git a/app/Http/Livewire/ImporterFile.php b/app/Http/Livewire/ImporterFile.php index 2d8d075c85..f7f8badbd5 100644 --- a/app/Http/Livewire/ImporterFile.php +++ b/app/Http/Livewire/ImporterFile.php @@ -84,21 +84,32 @@ class ImporterFile extends Component public $customFields; public $importTypes; public $columnOptions; - public $increment; // just used to force refreshes + public $increment; // just used to force refreshes - and doesn't really work anyways public $statusType; public $statusText; public $update; public $send_welcome; public $run_backup; + public $field_map; // we need a separate variable for the field-mapping, because the keys in the normal array are too complicated for Livewire to understand protected $rules = [ 'activeFile.import_type' => 'string', 'activeFile.field_map' => 'array', //this doesn't work because I think we would have to list all the keys? + // 'activeFile.field_map.*' => 'string', // FIXME - can we do this? + 'activeFile.header_row' => 'array', + 'field_map' => 'array' ]; // protected $listeners = ['refreshComponent' => '$refresh']; - private function getColumns($type) + public function getDinglefartsProperty() // FIXME (and probably not even used at this point :((( + { + $tmp = array_combine($this->activeFile->header_row, $this->field_map); + \Log::error("tmp is: ".print_r($tmp,true)); + return json_encode($tmp); + } + + private function getColumns($type) //maybe static? { global $general, $accessories, $assets, $consumables, $licenses, $users; // TODO - why is this global? @@ -150,18 +161,11 @@ class ImporterFile extends Component $this->columnOptions[$type] = $this->getColumns($type); } $this->increment = 0; + $this->field_map = array_values($this->activeFile->field_map); } public function postSave() { - Log::error("Saving import!"); - if (!$this->activeFile->import_type) { - $this->statusType='error'; - $this->statusText= "An import type is required... "; // TODO - translate me! - return false; - } - $this->statusType = 'pending'; - $this->statusText = "Processing..."; } public function changeTypes() // UNUSED? diff --git a/resources/views/importer/import.blade.php b/resources/views/importer/import.blade.php index 0ec2137538..22dd8e7c76 100644 --- a/resources/views/importer/import.blade.php +++ b/resources/views/importer/import.blade.php @@ -16,13 +16,19 @@ THIS IS VUE STUFF ISNT IT? --}} -@livewire('importer') {{-- Yes, this is stupid - we should be able to route straight over and not have this, but Livewire doesn't work in this app that way :/ --}} + + {{-- YET ANOTHER FIXME! argh. This file shouldn't exist. --}} + + @livewire('importer') {{-- Yes, this is stupid - we should be able to route straight over and not have this, but Livewire doesn't work in this app that way :/ --}} @stop @section('moar_scripts') -{{-- --}} + + + + {{-- --}} @endsection diff --git a/resources/views/livewire/importer-file.blade.php b/resources/views/livewire/importer-file.blade.php index 2cb4916b85..e65fbdc833 100644 --- a/resources/views/livewire/importer-file.blade.php +++ b/resources/views/livewire/importer-file.blade.php @@ -1,4 +1,5 @@ {{--