Skip to content

Commit

Permalink
prep refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed May 13, 2024
1 parent b65a7f1 commit 25ec5f8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Fields/FieldTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ private static function inlineTabField(array $submitted)
{
$fieldtype = FieldtypeRepository::find($submitted['fieldtype'] ?? $submitted['config']['type']);

$defaultConfig = Field::commonFieldOptions()->all()
->merge($fieldtype->configFields()->all())
->map->defaultValue()->filter();
$fields = Field::commonFieldOptions()->all()
->merge($fieldtype->configFields()->all());

$field = collect($submitted['config'])
->reject(function ($value, $key) use ($defaultConfig) {
->reject(function ($value, $key) use ($fields) {
if (in_array($key, ['isNew', 'icon', 'duplicate'])) {
return true;
}
Expand All @@ -46,7 +45,11 @@ private static function inlineTabField(array $submitted)
return true;
}

return $defaultConfig->has($key) && $defaultConfig->get($key) === $value;
if (! $field = $fields->get($key)) {
return false;
}

return $field->defaultValue() === $value;
})
->map(function ($value, $key) {
if ($key === 'sets') {
Expand Down

0 comments on commit 25ec5f8

Please sign in to comment.