Skip to content

Commit

Permalink
Store custom actions and more
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Kuhlmay committed Jul 11, 2023
1 parent 969c1b5 commit 42f4dee
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 55 deletions.
39 changes: 25 additions & 14 deletions Build/Sources/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ const initialNodes = [];
const initialEdges = [];

function App() {
// Nodes for ReactFlow
const [nodes, setNodes] = useState([]);

const onNodesChanged = (nodes) => {
// Dont use prev
setNodes(nodes);
}

// Zustand für das Ein- und Ausklappen der linken Spalte
const [isLeftColumnVisible, setLeftColumnVisible] = useState(true);

Expand Down Expand Up @@ -142,22 +150,22 @@ const updatePluginHandler = (pluginId, field, value) => {
});
}

const updateModuleHandler = (moduleId, field, value) => {
setModules((prevModules) => {
return prevModules.map((module) => {
if (module.id === moduleId) {
if (field.includes('.')) {
const [parentKey, childKey] = field.split('.');
return {...module, [parentKey]: {...module[parentKey], [childKey]: value}};
const updateModuleHandler = (moduleId, field, value) => {
setModules((prevModules) => {
return prevModules.map((module) => {
if (module.id === moduleId) {
if (field.includes('.')) {
const [parentKey, childKey] = field.split('.');
return {...module, [parentKey]: {...module[parentKey], [childKey]: value}};
} else {
return {...module, [field]: value};
}
} else {
return {...module, [field]: value};
return module;
}
} else {
return module;
}
});
});
});
}
}

const removeAuthorHandler = (authorId) => {
// TODO Testen !!!
Expand Down Expand Up @@ -280,6 +288,7 @@ const updateModuleHandler = (moduleId, field, value) => {
authors={authors}
plugins={plugins}
modules={modules}
nodes={nodes}
addNewAuthorHandler={addNewAuthorHandler}
addNewModuleHandler={addNewModuleHandler}
addNewPluginHandler={addNewPluginHandler}
Expand All @@ -299,7 +308,9 @@ const updateModuleHandler = (moduleId, field, value) => {
</div>
<div style={{left: isLeftColumnVisible ? '400px' : '0', width: isLeftColumnVisible ? 'calc(100vw - 400px)' : '100vw'}} id="right-column" className="no-padding full-height">
<div >
<RightContentComponent />
<RightContentComponent
onNodesChanged={onNodesChanged}
/>
</div>
</div>
</div>
Expand Down
101 changes: 84 additions & 17 deletions Build/Sources/components/ActionButtonsComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,82 @@ export const ActionButtonsComponent = (props) => {
console.log(props);
console.log("----------")

// modules => nodes from react flow
let modules = [];

// For each props.nodes, create a module object
props.nodes.forEach((node) => {
console.log("Node");
console.log(node);
let customActions = [];
node.data.customActions.map((action) => {
customActions.push(action);
});
console.log("Custom Actions");
console.log(customActions);

let module = {
"config": {
"position": [
node.position.x,
node.position.y
]
},
"name": node.data.label,
"value": {
"actionGroup": {
"_default0_index": node.data.actions.actionIndex,
"_default1_list": node.data.actions.actionList,
"_default2_show": node.data.actions.actionShow,
"_default3_new_create": node.data.actions.actionNewCreate,
"_default4_edit_update": node.data.actions.actionEditUpdate,
"_default5_delete": node.data.actions.actionDelete,
"customActions": customActions
},
"name": node.data.label,
"objectsettings": {
"addDeletedField": node.data.addDeletedField,
"addHiddenField": node.data.addHiddenField,
"addStarttimeEndtimeFields": node.data.addStarttimeEndtimeFields,
"aggregateRoot": node.data.isAggregateRoot,
"categorizable": node.data.enableCategorization,
"description": node.data.description,
"mapToTable": node.data.mapToExistingTable,
"parentClass": node.data.extendExistingModelClass,
"sorting": node.data.enableSorting,
"type": "Entity",
"uid": "1173301976935"
},
"propertyGroup": {
"properties": [
{
"allowedFileTypes": "",
"maxItems": "1",
"propertyDescription": "",
"propertyIsExcludeField": true,
"propertyIsL10nModeExclude": false,
"propertyIsNullable": false,
"propertyIsRequired": false,
"propertyName": "titel",
"propertyType": "String",
"uid": "1357067104948"
}
]
},
"relationGroup": {
"relations": []
}
}
};
modules.push(module);
});

console.log("-Nodes-")
console.log(props.nodes);
console.log("-Nodes END-")

let working = {
"modules": [],
"modules": modules,
"properties": {
"backendModules": props.modules,
"description": props.properties.description || "",
Expand All @@ -30,9 +104,9 @@ export const ActionButtonsComponent = (props) => {
"dependsOn": props.properties.emConf.dependsOn || "",
"disableLocalization": props.properties.emConf.disableLocalization || false,
"disableVersioning": props.properties.emConf.disableVersioning || false,
"generateDocumentationTemplate": props.properties.emConf.generateDocumentationTemplate || true,
"generateEditorConfig": props.properties.emConf.generateEditorConfig || true,
"generateEmptyGitRepository": props.properties.emConf.generateEmptyGitRepository || true,
"generateDocumentationTemplate": props.properties.emConf.generateDocumentationTemplate || false,
"generateEditorConfig": props.properties.emConf.generateEditorConfig || false,
"generateEmptyGitRepository": props.properties.emConf.generateEmptyGitRepository || false,
"sourceLanguage": props.properties.emConf.sourceLanguage || "en",
"state": props.properties.emConf.state || "alpha",
"targetVersion": `${props.properties.emConf.targetVersion}.0-${props.properties.emConf.targetVersion}.99` || "12.4.0",
Expand Down Expand Up @@ -61,6 +135,7 @@ export const ActionButtonsComponent = (props) => {
};
console.log("----------")
console.log("payload");
console.log(payload);
console.log("----------")

// TYPO3 will be available in the global scope
Expand All @@ -74,8 +149,12 @@ export const ActionButtonsComponent = (props) => {
.then(function (response) {
console.log("Successfull saved");
console.log(response.data.success);
if(response.data.success === null || response.data.success === undefined) {
top.TYPO3.Modal.confirm('Successfull saved but ...', '... Something went wrong on server side');
} else {
top.TYPO3.Modal.confirm('Successfull saved', response.data.success);
}
// eslint-disable-next-line no-restricted-globals,no-undef
top.TYPO3.Modal.confirm('Successfull saved', response.data.success);
setSuccess(response);
})
.catch(function (error) {
Expand Down Expand Up @@ -106,18 +185,6 @@ export const ActionButtonsComponent = (props) => {
id="eb-btn-save"
><FontAwesomeIcon className="me-1" icon="fa-solid fa-folder" />Open</button>
</div>
{/* <button
type="button"
className="btn btn-secondary me-2"
id="eb-btn-demo"
onClick={handleDemoInput}
>Demo Input</button>*/}

{/* <button
type="button"
className="btn btn-danger"
id="eb-btn-close"
>Close</button>*/}
</div>
)
}
14 changes: 12 additions & 2 deletions Build/Sources/components/ReactFlow/CustomModelNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export const CustomModelNode = (props) => {
props.data.label = value;
}

const updateCustomAction = (index, value) => {
props.data.customActions[index] = value;
console.log(props.data);
}

return (
<div className="custom-model-node">
<div className="drag-handle"></div>
Expand Down Expand Up @@ -228,10 +233,15 @@ export const CustomModelNode = (props) => {
><FontAwesomeIcon className="font-awesome-icon" icon="fa-solid fa-plus" /></button>
</div>
{
customActions.map((action) => {
customActions.map((action, index) => {
return (
<div className="custom-model-node__action-wrapper">
<input type="text" name="actionName" placeholder="Action name" />
<input type="text" name="actionName" placeholder="Action name"
onChange={(e) => {
// Store custom Action to props.data.actions.customActions
updateCustomAction(index, e.target.value);
}}
/>
</div>
)
})
Expand Down
1 change: 0 additions & 1 deletion Build/Sources/components/ReactFlow/ReactFlowComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export const ReactFlowComponent = (props) => {
actionDelete: false,
},
customActions: [

],
properties: [],
relations: [],
Expand Down
4 changes: 2 additions & 2 deletions Build/Sources/components/views/RightContentComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ReactFlowComponent} from "../ReactFlow/ReactFlowComponent";

export const RightContentComponent = () => {
export const RightContentComponent = (props) => {
return (
<ReactFlowComponent

{...props}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getSettings(?array $typoscript = null): array
if (empty($settings['publicResourcesPath'])) {
$settings['publicResourcesPath'] = ExtensionManagementUtility::extPath('extension_builder') . 'Resources/Public/';
$settings['codeTemplateRootPaths'][] = ExtensionManagementUtility::extPath('extension_builder') . 'Resources/Private/CodeTemplates/Extbase/';
$settings['codeTemplatePartialPaths'][] = ExtensionManagementUtility::extPath('extension_builder') . 'Resources/Private/Partials/';
$settings['codeTemplatePartialPaths'][] = ExtensionManagementUtility::extPath('extension_builder') . 'Resources/Private/CodeTemplates/Extbase/Partials/';
}
return $settings;
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Validator/ExtensionValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public function validateConfigurationFormat(array $configuration): array
$propertyNames = [];
if (isset($domainObjectConfiguration['value']['propertyGroup']['properties'])) {
foreach ($domainObjectConfiguration['value']['propertyGroup']['properties'] as $property) {
if (in_array($property['propertyName'], $propertyNames, true)) {
if (in_array($property['propertyName'] ?? '', $propertyNames, true)) {
$this->validationResult['errors'][] = new ExtensionException(
'Property "' . $property['propertyName'] . '" of Model "' . $domainObjectConfiguration['value']['name'] . '" exists twice.',
self::ERROR_PROPERTY_DUPLICATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

return [<f:for each="{extension.backendModules}" as="backendModule">
'{backendModule.key}' => [
'parent' => '{backendModule.mainModule}',
'position' => ['bottom'],
'access' => 'user',
'workspaces' => 'live',
'path' => '/module/{extension.vendorName}/{backendModule.key}',
'labels' => 'LLL:EXT:{extension.extensionKey}/Resources/Private/Language/locallang_{backendModule.key}.xlf',
'extensionName' => '{extension.extensionName}',
'controllerActions' => [
ModuleController::class => [
'flash','tree','clipboard','links','fileReference','fileReferenceCreate',
],
'parent' => '{backendModule.mainModule}',
'position' => ['bottom'],
'access' => 'user',
'workspaces' => 'live',
'path' => '/module/{extension.vendorName}/{backendModule.key}',
'labels' => 'LLL:EXT:{extension.extensionKey}/Resources/Private/Language/locallang_{backendModule.key}.xlf',
'extensionName' => '{extension.extensionName}',
'controllerActions' => [
ModuleController::class => [
'flash','tree','clipboard','links','fileReference','fileReferenceCreate',
],
'routes' => [
'_default' => [
'target' => 'test',
],
],
'routes' => [
'_default' => [
'target' => 'test',
],
],
</f:for>
],
</f:for>
];
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/main.js

Large diffs are not rendered by default.

0 comments on commit 42f4dee

Please sign in to comment.