Added support for flex-ignore@ to hide all the nested fields in the blueprint

This commit is contained in:
Matias Griese 2022-09-02 19:36:22 +03:00
parent dbca0b451c
commit 3f10c05840
3 changed files with 12 additions and 5 deletions

View File

@ -3,6 +3,7 @@
1. [](#new)
* Added `authorize-*@:` support for Flex blueprints, e.g. `authorize-disabled@: not delete` disables the field if user does not have access to delete object
* Added support for `flex-ignore@` to hide all the nested fields in the blueprint
# v1.7.35
## 08/04/2022

View File

@ -515,7 +515,7 @@ class Blueprint extends BlueprintForm
$success = $this->resolveActions($user, $actions);
}
if (!$success) {
$this->addPropertyRecursive($field, 'validate', ['ignore' => true]);
static::addPropertyRecursive($field, 'validate', ['ignore' => true]);
}
}
@ -566,7 +566,7 @@ class Blueprint extends BlueprintForm
}
if ($matches) {
$this->addPropertyRecursive($field, 'validate', ['ignore' => true]);
static::addPropertyRecursive($field, 'validate', ['ignore' => true]);
return;
}
}
@ -577,7 +577,7 @@ class Blueprint extends BlueprintForm
* @param mixed $value
* @return void
*/
protected function addPropertyRecursive(array &$field, $property, $value)
public static function addPropertyRecursive(array &$field, $property, $value)
{
if (is_array($value) && isset($field[$property]) && is_array($field[$property])) {
$field[$property] = array_merge_recursive($field[$property], $value);
@ -587,7 +587,7 @@ class Blueprint extends BlueprintForm
if (!empty($field['fields'])) {
foreach ($field['fields'] as $key => &$child) {
$this->addPropertyRecursive($child, $property, $value);
static::addPropertyRecursive($child, $property, $value);
}
}
}

View File

@ -920,7 +920,13 @@ class FlexDirectory implements FlexDirectoryInterface
if (is_array($value) && isset($field[$property]) && is_array($field[$property])) {
$value = $this->mergeArrays($field[$property], $value);
}
$field[$property] = $not ? !$value : $value;
$value = $not ? !$value : $value;
if ($property === 'ignore' && $value) {
Blueprint::addPropertyRecursive($field, 'validate', ['ignore' => true]);
} else {
$field[$property] = $value;
}
}
}