A free open source IT asset/license management system
Possible fix for #19450 - handle “do not import” better
snipefb0ee60bf589
diff --git a/app/Livewire/Importer.php b/app/Livewire/Importer.phpindex 27f6ea8a01..3341190937 100644--- a/app/Livewire/Importer.php+++ b/app/Livewire/Importer.php@@ -211,7 +211,14 @@ class Importer extends Component$tmp = [];if ($this->activeFile) {$tmp = array_combine($this->headerRow, $this->field_map);- $tmp = array_filter($tmp);+ // Drop only nulls (columns the auto-map couldn't bind to+ // anything for this import type). Preserve empty strings,+ // which encode the user's explicit "Do not import" choice+ // in the wizard select. Bare array_filter($tmp) treats both+ // as falsy and silently loses the user selection, forcing+ // them to re-set "Do not import" every time the template+ // is reloaded (see the wizard-side companion fix for #19450).+ $tmp = array_filter($tmp, fn ($v) => $v !== null);}return json_encode($tmp);@@ -866,9 +873,18 @@ class Importer extends Component$this->field_map = null;foreach ($this->headerRow as $element) {if (isset($this->activeFile->field_map[$element])) {+ // Preserved values may be either a real target-field key+ // or the empty string "" (user's explicit "Do not import"+ // choice, persisted by generate_field_map). Push through+ // as-is; the blade side's is_null-based @continue keeps+ // "" rows visible so the user can flip them back.$this->field_map[] = $this->activeFile->field_map[$element];} else {- $this->field_map[] = null; // re-inject the 'nulls' if a file was imported with some 'Do Not Import' settings+ // Header wasn't in the saved map at all. Treat as+ // never-mapped (auto-map couldn't bind or this header+ // is new since the template was saved). Null hides the+ // row in the wizard by design.+ $this->field_map[] = null;}}diff --git a/resources/views/livewire/importer.blade.php b/resources/views/livewire/importer.blade.phpindex f4c7593866..cc181445e8 100644--- a/resources/views/livewire/importer.blade.php+++ b/resources/views/livewire/importer.blade.php@@ -515,13 +515,21 @@@php// Skip CSV columns that the auto-map// couldn't bind to any target for the- // current import type. If the user- // needs manual control they can- // pick a different import type in- // step 1 and the map re-runs.+ // current import type — those come+ // through as PHP null. Rows the USER+ // set to "Do not import" come through+ // as empty string (Livewire binds the+ // select's value="" as ""), so those+ // stay visible and the user can change+ // their mind. Previously used empty()+ // here, which conflated the two and+ // made "Do not import" rows disappear+ // from the wizard with no way to bring+ // them back short of restarting the+ // import (#19450).$currentMapping = $field_map[$index] ?? null;@endphp- @continue(empty($currentMapping))+ @continue(is_null($currentMapping))<div class="form-group col-md-12" wire:key="header-row-{{ $index }}"><label for="field_map.{{ $index }}" class="col-md-3 control-label text-right">{{ $header }}</label>