Skip to content

A free open source IT asset/license management system

Added byod to backend

snipeaec7af6fc6fd
diff --git a/app/SyncAdapters/MappingTargets.php b/app/SyncAdapters/MappingTargets.php
index fa257aa998..23121337c4 100644
--- a/app/SyncAdapters/MappingTargets.php
+++ b/app/SyncAdapters/MappingTargets.php
@@ -154,6 +154,14 @@ class MappingTargets
}
}
+ // Boolean-typed extras only have one native column that matches
+ // (assets.byod). Admin-defined boolean extras stay custom-only
+ // because arbitrary tenant-labeled toggles don't have a
+ // universal semantic mapping to native columns.
+ if ($type === 'boolean' && ! $adminDefined) {
+ $options['native:byod'] = trans('admin/settings/sync_adapters.target_native_byod');
+ }
+
$customFields = match ($type) {
'boolean' => self::checkboxCustomFields(),
default => self::textLikeCustomFields(),
diff --git a/app/SyncAdapters/SyncHostFromAdapter.php b/app/SyncAdapters/SyncHostFromAdapter.php
index 7d63b7aeb0..64cd7d0c6f 100644
--- a/app/SyncAdapters/SyncHostFromAdapter.php
+++ b/app/SyncAdapters/SyncHostFromAdapter.php
@@ -11,8 +11,6 @@ use App\Models\Statuslabel;
use App\Models\SyncAdapterConfig;
use App\Models\SyncAdapterInstance;
use App\Models\User;
-use App\SyncAdapters\SyncAdapter;
-use App\SyncAdapters\MappingTargets;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use RuntimeException;
@@ -710,6 +708,16 @@ class SyncHostFromAdapter
$asset->model_id = self::resolveModelIdByName((string) $value, $instance, $record);
}
break;
+ case 'byod':
+ // Boolean extras arrive here stringified to '1' or '0'
+ // by stringifyExtra(). Convert back to the model's
+ // boolean shape so the column stores the right type.
+ // Empty string means the vendor didn't send a value on
+ // this sync cycle, so skip rather than false-blank.
+ if ($value !== null && $value !== '') {
+ $asset->byod = ($value === '1');
+ }
+ break;
}
}
diff --git a/tests/Feature/SyncAdapters/SyncAdapterDeleteTest.php b/tests/Feature/SyncAdapters/SyncAdapterDeleteTest.php
index 6a31029d5c..4e03431189 100644
--- a/tests/Feature/SyncAdapters/SyncAdapterDeleteTest.php
+++ b/tests/Feature/SyncAdapters/SyncAdapterDeleteTest.php
@@ -90,7 +90,7 @@ class SyncAdapterDeleteTest extends TestCase
);
// Help pane is present and rendered active.
$this->assertMatchesRegularExpression(
- '/id="adapter-pane-_help"[^>]*class="[^"]*active in/',
+ '/id="adapter-pane-help"[^>]*class="[^"]*active in/',
$html,
);
// The type catalog surfaces at least one shipped adapter so
@@ -113,7 +113,7 @@ class SyncAdapterDeleteTest extends TestCase
->assertOk()
->getContent();
- $this->assertStringContainsString('id="adapter-pane-_help"', $html);
+ $this->assertStringContainsString('id="adapter-pane-help"', $html);
$this->assertStringContainsString(
trans('admin/settings/sync_adapters.help_tab_label'),
$html,