fix(custom-fields) : persist machineContextOnly in structure save and clone
- SkeletonStructureService: read and write machineContextOnly on create/update - normalizeCustomFieldData: pass machineContextOnly through both payload formats - cloneCustomFields: copy machineContextOnly flag on machine clone Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -191,6 +191,7 @@ class MachineStructureController extends AbstractController
|
|||||||
$newCf->setDefaultValue($cf->getDefaultValue());
|
$newCf->setDefaultValue($cf->getDefaultValue());
|
||||||
$newCf->setOptions($cf->getOptions());
|
$newCf->setOptions($cf->getOptions());
|
||||||
$newCf->setOrderIndex($cf->getOrderIndex());
|
$newCf->setOrderIndex($cf->getOrderIndex());
|
||||||
|
$newCf->setMachineContextOnly($cf->isMachineContextOnly());
|
||||||
$newCf->setMachine($target);
|
$newCf->setMachine($target);
|
||||||
$this->entityManager->persist($newCf);
|
$this->entityManager->persist($newCf);
|
||||||
|
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ class SkeletonStructureService
|
|||||||
$existingField->setOptions($normalized['options']);
|
$existingField->setOptions($normalized['options']);
|
||||||
$existingField->setDefaultValue($normalized['defaultValue']);
|
$existingField->setDefaultValue($normalized['defaultValue']);
|
||||||
$existingField->setOrderIndex($normalized['orderIndex']);
|
$existingField->setOrderIndex($normalized['orderIndex']);
|
||||||
|
$existingField->setMachineContextOnly($normalized['machineContextOnly']);
|
||||||
$processedIds[$existingField->getId()] = true;
|
$processedIds[$existingField->getId()] = true;
|
||||||
} else {
|
} else {
|
||||||
// Create new field
|
// Create new field
|
||||||
@@ -243,6 +244,7 @@ class SkeletonStructureService
|
|||||||
$cf->setOptions($normalized['options']);
|
$cf->setOptions($normalized['options']);
|
||||||
$cf->setDefaultValue($normalized['defaultValue']);
|
$cf->setDefaultValue($normalized['defaultValue']);
|
||||||
$cf->setOrderIndex($normalized['orderIndex']);
|
$cf->setOrderIndex($normalized['orderIndex']);
|
||||||
|
$cf->setMachineContextOnly($normalized['machineContextOnly']);
|
||||||
|
|
||||||
match ($category) {
|
match ($category) {
|
||||||
ModelCategory::COMPONENT => $cf->setTypeComposant($modelType),
|
ModelCategory::COMPONENT => $cf->setTypeComposant($modelType),
|
||||||
@@ -265,7 +267,7 @@ class SkeletonStructureService
|
|||||||
/**
|
/**
|
||||||
* Normalize frontend custom field data to a common shape.
|
* Normalize frontend custom field data to a common shape.
|
||||||
*
|
*
|
||||||
* @return array{name: string, type: string, required: bool, options: ?array, defaultValue: ?string, orderIndex: int}
|
* @return array{name: string, type: string, required: bool, options: ?array, defaultValue: ?string, orderIndex: int, machineContextOnly: bool}
|
||||||
*/
|
*/
|
||||||
private function normalizeCustomFieldData(array $fieldData, int $index): array
|
private function normalizeCustomFieldData(array $fieldData, int $index): array
|
||||||
{
|
{
|
||||||
@@ -274,23 +276,25 @@ class SkeletonStructureService
|
|||||||
$value = $fieldData['value'];
|
$value = $fieldData['value'];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $fieldData['key'],
|
'name' => $fieldData['key'],
|
||||||
'type' => $value['type'] ?? 'text',
|
'type' => $value['type'] ?? 'text',
|
||||||
'required' => (bool) ($value['required'] ?? false),
|
'required' => (bool) ($value['required'] ?? false),
|
||||||
'options' => $value['options'] ?? null,
|
'options' => $value['options'] ?? null,
|
||||||
'defaultValue' => $value['defaultValue'] ?? null,
|
'defaultValue' => $value['defaultValue'] ?? null,
|
||||||
'orderIndex' => $index,
|
'orderIndex' => $index,
|
||||||
|
'machineContextOnly' => (bool) ($value['machineContextOnly'] ?? false),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// PIECE/PRODUCT format: {name, type, required, options?, orderIndex?, defaultValue?}
|
// PIECE/PRODUCT format: {name, type, required, options?, orderIndex?, defaultValue?}
|
||||||
return [
|
return [
|
||||||
'name' => $fieldData['name'] ?? '',
|
'name' => $fieldData['name'] ?? '',
|
||||||
'type' => $fieldData['type'] ?? 'text',
|
'type' => $fieldData['type'] ?? 'text',
|
||||||
'required' => (bool) ($fieldData['required'] ?? false),
|
'required' => (bool) ($fieldData['required'] ?? false),
|
||||||
'options' => $fieldData['options'] ?? null,
|
'options' => $fieldData['options'] ?? null,
|
||||||
'defaultValue' => $fieldData['defaultValue'] ?? null,
|
'defaultValue' => $fieldData['defaultValue'] ?? null,
|
||||||
'orderIndex' => $fieldData['orderIndex'] ?? $index,
|
'orderIndex' => $fieldData['orderIndex'] ?? $index,
|
||||||
|
'machineContextOnly' => (bool) ($fieldData['machineContextOnly'] ?? false),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user