mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 15:07:49 +00:00
feat: add support for configuration field multi_string
This commit is contained in:
parent
b18d561361
commit
583d8b2440
2 changed files with 85 additions and 0 deletions
|
|
@ -839,6 +839,15 @@ HTML;
|
||||||
</flux:select>
|
</flux:select>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@elseif($field['field_type'] === 'multi_string')
|
||||||
|
<flux:input
|
||||||
|
label="{{ $field['name'] }}"
|
||||||
|
description="{{ $field['description'] ?? '' }}"
|
||||||
|
descriptionTrailing="{{ $field['help_text'] ?? 'Enter multiple values separated by commas' }}"
|
||||||
|
wire:model="configuration.{{ $fieldKey }}"
|
||||||
|
value="{{ $currentValue }}"
|
||||||
|
placeholder="{{ $field['placeholder'] ?? 'value1,value2' }}"
|
||||||
|
/>
|
||||||
@else
|
@else
|
||||||
<flux:callout variant="warning">Field type "{{ $field['field_type'] }}" not yet supported</flux:callout>
|
<flux:callout variant="warning">Field type "{{ $field['field_type'] }}" not yet supported</flux:callout>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
|
|
@ -268,3 +268,79 @@ test('hasMissingRequiredConfigurationFields returns false when required xhrSelec
|
||||||
|
|
||||||
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
|
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('hasMissingRequiredConfigurationFields returns true when required multi_string field is missing', function (): void {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$configurationTemplate = [
|
||||||
|
'custom_fields' => [
|
||||||
|
[
|
||||||
|
'keyname' => 'tags',
|
||||||
|
'field_type' => 'multi_string',
|
||||||
|
'name' => 'Tags',
|
||||||
|
'description' => 'Enter tags separated by commas',
|
||||||
|
// Not marked as optional, so it's required
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$plugin = Plugin::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'configuration_template' => $configurationTemplate,
|
||||||
|
'configuration' => [], // Empty configuration
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('hasMissingRequiredConfigurationFields returns false when required multi_string field is set', function (): void {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$configurationTemplate = [
|
||||||
|
'custom_fields' => [
|
||||||
|
[
|
||||||
|
'keyname' => 'tags',
|
||||||
|
'field_type' => 'multi_string',
|
||||||
|
'name' => 'Tags',
|
||||||
|
'description' => 'Enter tags separated by commas',
|
||||||
|
// Not marked as optional, so it's required
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$plugin = Plugin::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'configuration_template' => $configurationTemplate,
|
||||||
|
'configuration' => [
|
||||||
|
'tags' => 'tag1, tag2, tag3', // Required field is set with comma-separated values
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($plugin->hasMissingRequiredConfigurationFields())->toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('hasMissingRequiredConfigurationFields returns true when required multi_string field is empty string', function (): void {
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$configurationTemplate = [
|
||||||
|
'custom_fields' => [
|
||||||
|
[
|
||||||
|
'keyname' => 'tags',
|
||||||
|
'field_type' => 'multi_string',
|
||||||
|
'name' => 'Tags',
|
||||||
|
'description' => 'Enter tags separated by commas',
|
||||||
|
// Not marked as optional, so it's required
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$plugin = Plugin::factory()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'configuration_template' => $configurationTemplate,
|
||||||
|
'configuration' => [
|
||||||
|
'tags' => '', // Empty string
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect($plugin->hasMissingRequiredConfigurationFields())->toBeTrue();
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue