Merge pull request #9856 from inietov/bug/ch15413/model_number_is_not_on_accessory_import_dropdown

Fixes: Model Number is not on the Accessory import dropdown of mappable fields [ch15413]
This commit is contained in:
snipe 2021-07-24 01:05:26 -07:00 committed by GitHub
commit 75d4a46fff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -14,7 +14,7 @@ class AccessoryImporter extends ItemImporter
protected 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.

View file

@ -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)