A free open source IT asset/license management system
Merge branch 'develop' into features/import_models
snipe220902a8b444
diff --cc app/Livewire/Importer.phpindex 5ffd3b1f4d,bffb3d763c..1296dbd106--- a/app/Livewire/Importer.php+++ b/app/Livewire/Importer.php@@@ -117,39 -107,38 +117,39 @@@ class Importer extends Componenpublic function updatingTypeOfImport($type){- // go through each header, find a matching field to try and map it to.+++ // go through each header, find a matching field to try and map it to.foreach ($this->headerRow as $i => $header) {- // do we have something mapped already?- if (array_key_exists($i, $this->field_map)) {- // yes, we do. Is it valid for this type of import?- // (e.g. the import type might have been changed...?)+ // do we have something mapped already?+ if (array_key_exists($i, $this->field_map)) {+ // yes, we do. Is it valid for this type of import?+ // (e.g. the import type might have been changed...?)if (array_key_exists($this->field_map[$i], $this->columnOptions[$type])) {- //yes, this key *is* valid. Continue on to the next field.- continue;- } else {- //no, this key is *INVALID* for this import type. Better set it to null- // and we'll hope that the $aliases_fields or something else picks it up.- $this->field_map[$i] = null; // fingers crossed! But it's not likely, tbh.- } // TODO - strictly speaking, this isn't necessary here I don't think.- }- // first, check for exact matches+ //yes, this key *is* valid. Continue on to the next field.+ continue;+ } else {+ //no, this key is *INVALID* for this import type. Better set it to null+ // and we'll hope that the $aliases_fields or something else picks it up.+ $this->field_map[$i] = null; // fingers crossed! But it's not likely, tbh.+ } // TODO - strictly speaking, this isn't necessary here I don't think.+ }+ // first, check for exact matchesforeach ($this->columnOptions[$type] as $v => $text) {- if (strcasecmp($text, $header) === 0) { // case-INSENSITIVe on purpose!+ if (strcasecmp($text, $header) === 0) { // case-INSENSITIVe on purpose!$this->field_map[$i] = $v;- continue 2; //don't bother with the alias check, go to the next header- }+ continue 2; //don't bother with the alias check, go to the next header}- // if you got here, we didn't find a match. Try the $aliases_fields- foreach ($this->aliases_fields as $key => $alias_values) {- foreach ($alias_values as $alias_value) {- if (strcasecmp($alias_value, $header) === 0) { // aLsO CaSe-INSENSitiVE!- // Make *absolutely* sure that this key actually _exists_ in this import type -- // you can trigger this by importing accessories with a 'Warranty' column (which don't exist- // in "Accessories"!)+ }+ // if you got here, we didn't find a match. Try the $aliases_fields+ foreach ($this->aliases_fields as $key => $alias_values) {+ foreach ($alias_values as $alias_value) {+ if (strcasecmp($alias_value, $header) === 0) { // aLsO CaSe-INSENSitiVE!+ // Make *absolutely* sure that this key actually _exists_ in this import type -+ // you can trigger this by importing accessories with a 'Warranty' column (which don't exist+ // in "Accessories"!)if (array_key_exists($key, $this->columnOptions[$type])) {- $this->field_map[$i] = $key;- continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header- }+ $this->field_map[$i] = $key;+ continue 3; // bust out of both of these loops; as well as the surrounding one - e.g. move on to the next header}}}diff --cc app/Livewire/SlackSettingsForm.phpindex 7678387896,725bffa249..8d330bafbe--- a/app/Livewire/SlackSettingsForm.php+++ b/app/Livewire/SlackSettingsForm.php@@@ -113,10 -113,11 +113,13 @@@ class SlackSettingsForm extends Componeif($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){$this->webhook_channel = '#NA';}-+ }+ public function updatedwebhookEndpoint() {+ $this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');}+ public function updatedwebhookEndpoint() {+ $this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');+ }private function isButtonDisabled() {if (empty($this->webhook_endpoint)) {diff --cc database/factories/ImportFactory.phpindex ca6608a804,0b0f79aa44..e7f8d692ea--- a/database/factories/ImportFactory.php+++ b/database/factories/ImportFactory.php@@@ -143,25 -143,4 +143,26 @@@ class ImportFactory extends Factorreturn $attributes;});}+++++ /**+ * Create an asset model import type.+ *+ * @return static+ */+ public function assetmodel()+ {+ return $this->state(function (array $attributes) {+ $fileBuilder = Importing\AssetModelsImportFileBuilder::new();++ $attributes['name'] = "{$attributes['name']} Asset Model";+ $attributes['import_type'] = 'assetmodel';+ $attributes['header_row'] = $fileBuilder->toCsv()[0];+ $attributes['first_row'] = $fileBuilder->firstRow();++ return $attributes;+ });+ }+}