Skip to content

Commit

Permalink
413 Map options for selectbox into own object in JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Kuhlmay committed Jan 12, 2024
1 parent 549ebaf commit 88646b7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
8 changes: 5 additions & 3 deletions Build/Sources/components/ActionButtonsComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ export const ActionButtonsComponent = (props) => {
"propertyIsRequired": property.isRequired,
"propertyName": property.name,
"propertyType": property.type,
"selectboxValues": property.selectboxValues || "",
"renderType": property.renderType || "selectSingle",
"foreignTable": property.foreignTable || "",
"typeSelect": {
"selectboxValues": property.typeSelect?.selectboxValues || "",
"renderType": property.typeSelect?.renderType || "selectSingle",
"foreignTable": property.typeSelect?.foreignTable || "",
},
"size": property.size || "",
"minItems": property.minItems || "",
"maxItems": property.maxItems || "",
Expand Down
24 changes: 17 additions & 7 deletions Build/Sources/components/ReactFlow/CustomModelNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@ export const CustomModelNode = (props) => {
}

const updateProperty = (index, property, value) => {
properties[index][property] = value;
const pathParts = property.split(".");
let currentProperty = properties[index];

for (let i = 0; i < pathParts.length - 1; i++) {
if (!currentProperty[pathParts[i]]) {
currentProperty[pathParts[i]] = {};
}
currentProperty = currentProperty[pathParts[i]];
}
currentProperty[pathParts[pathParts.length - 1]] = value;

setProperties([...properties]);
props.data.properties = properties;
}
Expand Down Expand Up @@ -367,27 +377,27 @@ export const CustomModelNode = (props) => {
label="Values for Select-Box"
placeholder="label;value separated by new line"
identifier="selectboxValues"
initialValue={property.selectboxValues}
initialValue={property.typeSelect?.selectboxValues}
onChange={(value) => {
updateProperty(index, "selectboxValues", value);
updateProperty(index, "typeSelect.selectboxValues", value);
}}
/>)}
{property.type === 'Select' &&(<SelectComponent
label="Render Type"
identifier="renderType"
options={['selectSingle','selectSingleBox','selectCheckBox','selectMultipleSideBySide']}
initialValue={property.renderType}
initialValue={property.typeSelect?.renderType}
onChange={(value) => {
updateProperty(index, "renderType", value);
updateProperty(index, "typeSelect.renderType", value);
}}
/>)}
{property.type === 'Select' &&<InputComponent
label="Foreign table (will override values)"
placeholder="Foreign table"
identifier="foreignTable"
initialValue={property.foreignTable}
initialValue={property.typeSelect?.foreignTable}
onChange={(value) => {
updateProperty(index, "foreignTable", value);
updateProperty(index, "typeSelect.foreignTable", value);
}}
/>}
{property.type === 'Select' &&<InputComponent
Expand Down
12 changes: 6 additions & 6 deletions Classes/Service/ObjectSchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ public static function buildProperty(array $propertyJsonConfiguration): Abstract
if ($property->isFileReference() && !empty($propertyJsonConfiguration['maxItems'])) {
$property->setMaxItems((int)$propertyJsonConfiguration['maxItems']);
}
if (isset($propertyJsonConfiguration['selectboxValues'])) {
$property->setSelectboxValues($propertyJsonConfiguration['selectboxValues']);
if (isset($propertyJsonConfiguration['typeSelect']['selectboxValues'])) {
$property->setSelectboxValues($propertyJsonConfiguration['typeSelect']['selectboxValues']);
}
if (isset($propertyJsonConfiguration['foreignTable'])) {
$property->setForeignTable($propertyJsonConfiguration['foreignTable']);
if (isset($propertyJsonConfiguration['typeSelect']['foreignTable'])) {
$property->setForeignTable($propertyJsonConfiguration['typeSelect']['foreignTable']);
}
if (isset($propertyJsonConfiguration['renderType'])) {
$property->setRenderType($propertyJsonConfiguration['renderType']);
if (isset($propertyJsonConfiguration['typeSelect']['renderType'])) {
$property->setRenderType($propertyJsonConfiguration['typeSelect']['renderType']);
}
if (isset($propertyJsonConfiguration['size'])) {
$property->setSize((int)$propertyJsonConfiguration['size']);
Expand Down

0 comments on commit 88646b7

Please sign in to comment.