A free open source IT asset/license management system
Add the field model_number to Accessory importer
Ivan Nieto Vivanco0f1c48cb6fe7
diff --git a/app/Importer/AccessoryImporter.php b/app/Importer/AccessoryImporter.phpindex 709b58ea3c..324d27e9e2 100644--- a/app/Importer/AccessoryImporter.php+++ b/app/Importer/AccessoryImporter.php@@ -14,7 +14,7 @@ class AccessoryImporter extends ItemImporterprotected function handle($row){parent::handle($row); // TODO: Change the autogenerated stub- $this->createAccessoryIfNotExists();+ $this->createAccessoryIfNotExists($row);}/**@@ -23,7 +23,7 @@ class AccessoryImporter extends ItemImporter* @author Daniel Melzter* @since 3.0*/- public function createAccessoryIfNotExists()+ public function createAccessoryIfNotExists($row){$accessory = Accessory::where('name', $this->item['name'])->first();if ($accessory) {@@ -33,12 +33,14 @@ class AccessoryImporter extends ItemImporter}$this->log('Updating Accessory');+ $this->item['model_number'] = $this->findCsvMatch($row, "model_number");$accessory->update($this->sanitizeItemForUpdating($accessory));$accessory->save();return;}$this->log("No Matching Accessory, Creating a new one");$accessory = new Accessory();+ $this->item['model_number'] = $this->findCsvMatch($row, "model_number");$accessory->fill($this->sanitizeItemForStoring($accessory));//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.diff --git a/resources/assets/js/components/importer/importer-file.vue b/resources/assets/js/components/importer/importer-file.vueindex f4fddcd842..83970614e5 100644--- a/resources/assets/js/components/importer/importer-file.vue+++ b/resources/assets/js/components/importer/importer-file.vue@@ -141,6 +141,9 @@{id: 'username', text: 'Username' },{id: 'department', text: 'Department' },],+ accessories:[+ {id: 'model_number', text: 'Model Number'},+ ],assets: [{id: 'asset_tag', text: 'Asset Tag' },{id: 'asset_model', text: 'Model Name' },@@ -208,7 +211,10 @@.concat(this.columnOptions.assets).concat(this.columnOptions.customFields).sort(sorter);-+ case 'accessory':+ return this.columnOptions.general+ .concat(this.columnOptions.accessories)+ .sort(sorter);case 'consumable':return this.columnOptions.general.concat(this.columnOptions.consumables)