Skip to content

Commit

Permalink
Current state
Browse files Browse the repository at this point in the history
  • Loading branch information
PKuhlmay committed Jun 28, 2024
1 parent 4fdf974 commit 3568217
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 102 deletions.
13 changes: 9 additions & 4 deletions Build/Sources/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import defaultAuthor from "./initialValues/author";
import defaultModule from "./initialValues/module";
import defaultPlugin from "./initialValues/plugin";
import convertModulesToNodes from "./helper/converter/convertModulesToNodes";
import convertRelationsToReactFlowRelations from "./helper/converter/convertRelationsToReactFlowRelations";

export const NodesContext = createContext([]);
export const EdgesContext = createContext([]);
Expand Down Expand Up @@ -259,14 +260,18 @@ function App() {
// let modules = convertModuleToNode(working.modules);
let modules = convertModulesToNodes(working.modules);
// Check if nodes or edges are available, and update them.
console.log("modules");
console.log(modules);
console.log(working.nodes);
let edges = convertRelationsToReactFlowRelations(working.wires);

console.log("41:" + JSON.stringify(working.modules, null, 2));
console.log("42:" + JSON.stringify(working.edges, null, 2));

setNodes(modules ? modules: []);
setEdges(working.edges ? working.edges : []);

console.log("modulesLength: " + (modules ? modules.length : 0))
console.log("edgesLength: " + (working.edges ? working.edges.length : 0))
// Set the custom model node index depending on the amount of nodes.
setCustomModelNodeIndex(working.nodes ? working.nodes.length : 0);
setCustomModelNodeIndex(modules ? modules.length : 0);
}


Expand Down
6 changes: 2 additions & 4 deletions Build/Sources/components/ActionButtonsComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,11 @@ export const ActionButtonsComponent = (props) => {
return {
"src": {
"moduleId": modules.findIndex(node => node.name === nodes[sourceIndex].data.label),
"moduleName": nodes[sourceIndex].data.label,
"terminal": `relationWire_${relationIndex}`,
"uid": edge.id
},
"tgt": {
"moduleId": modules.findIndex(node => node.name === nodes[targetIndex].data.label),
"moduleName": nodes[targetIndex].data.label,
"terminal": "SOURCES",
"uid": edge.source
}
Expand Down Expand Up @@ -223,9 +221,9 @@ export const ActionButtonsComponent = (props) => {
"plugins": props.plugins,
"vendorName": props.properties.vendorName
},
"wires": wires,
"wires": wires
/*"nodes": nodes,*/
"edges": edges
/*"edges": edges*/
};

let payload = {
Expand Down
97 changes: 6 additions & 91 deletions Build/Sources/helper/converter/convertModulesToNodes.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,13 @@
function convertModulesToNodes(modules) {
// needed for the node
/*
{
id,
type,
position: {
x,
y
},
data: {
label,
objectType,
isAggregateRoot,
enableSorting,
addDeletedField,
addHiddenField,
addStarttimeEndtimeFields,
enableCategorization,
description,
mapToExistingTable,
extendExistingModelClass,
actions: {
actionIndex,
actionList,
actionShow,
actionNewCreate,
actionEditUpdate,
actionDelete
},
customActions -> Array,
properties -> Array,
relations -> Array
},
positionAbsolute: {
x,
y
}
}
*/

for (let i = 0; i < modules.length; i++) {
console.log(`Element ${i}:`, modules[i]);
// console.log(`Element ${i}:`, modules[i]);
// Hier kannst du auf einzelne Eigenschaften des aktuellen Objekts zugreifen, z.B.:
console.log(`Name: ${modules[i].name}`);
// console.log(`Name: ${modules[i].name}`);
// Und weitere Verarbeitungen für jedes Objekt im Array durchführen...
}

console.log('convertModuleToNodes');
console.log(modules);
// console.log('convertModuleToNodes');
// console.log(modules);

let result = modules.map((item, index) => ({
id: `dndnode_${index}`,
Expand Down Expand Up @@ -93,8 +53,8 @@ function convertModulesToNodes(modules) {
dragging: false
}));

console.log('result');
console.log(result);
// console.log('result');
// console.log(result);

return result;
}
Expand All @@ -112,48 +72,3 @@ function getModelName(item) {
}

export default convertModulesToNodes;

/*
{
"id": "dndnode_0",
"type": "customModel",
"position": {
"x": 550,
"y": 131
},
"data": {
"label": "Testmodule",
"objectType": "",
"isAggregateRoot": true,
"enableSorting": false,
"addDeletedField": true,
"addHiddenField": true,
"addStarttimeEndtimeFields": true,
"enableCategorization": false,
"description": "",
"mapToExistingTable": "",
"extendExistingModelClass": "",
"actions": {
"actionIndex": true,
"actionList": true,
"actionShow": false,
"actionNewCreate": false,
"actionEditUpdate": false,
"actionDelete": false
},
"customActions": [],
"properties": [],
"relations": []
},
"dragHandle": ".drag-handle",
"draggable": true,
"width": 300,
"height": 257,
"selected": true,
"positionAbsolute": {
"x": 550,
"y": 131
},
"dragging": false
}
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// from
// "wires": [
// {
// "src": {
// "moduleId": 0, ➡️ array Index von Modul innerhalb von modules
// "terminal": "relationWire_0", ➡️ irrelevant
// "uid": "reactflow__edge-dndnode_0rel-dndnode_0-364bc27b-ad04-42e3-a548-792a8e54efcf-dndnode_1cmn-dndnode_1"
// },
// "tgt": {
// "moduleId": 1, ➡️ array Index von Modul innerhalb von modules
// "terminal": "SOURCES", ➡️ irrelevant
// "uid": "dndnode_0"
// }
// }
// ]

// to
// "edges": [
// {
// "source": "dndnode_0",
// "sourceHandle": "rel-dndnode_0-364bc27b-ad04-42e3-a548-792a8e54efcf",
// "target": "dndnode_1",
// "targetHandle": "cmn-dndnode_1",
// "id": "reactflow__edge-dndnode_0rel-dndnode_0-364bc27b-ad04-42e3-a548-792a8e54efcf-dndnode_1cmn-dndnode_1"
// }
function convertRelationsToReactFlowRelations(wires) {

console.log("relations", wires);

const edges = wires.map(wire => {
console.log("wire", wire);

if (!wire.src || !wire.tgt) {
console.error('Fehler: Einige Wire-Objekte haben keine vollständigen src oder tgt Daten.', wire);
return null;
}

// Extraktion der Source-Informationen
const srcUidParts = wire.src.uid?.split("-");
const sourceMatch = srcUidParts[0].match(/dndnode_\d+/);
const source = sourceMatch ? sourceMatch[0] : null;
const sourceHandle = srcUidParts.slice(1, 3).join('-');

// Extraktion der Target-Informationen
const targetMatch = wire.tgt.uid?.match(/dndnode_\d+/);
const target = targetMatch ? targetMatch[0] : null;
const targetHandle = wire.tgt.terminal?.toLowerCase();

// Generierung der Edge-Id aus der Quell-UID
const edgeId = wire.src.uid;

// Überprüfen, ob alle benötigten Daten vorhanden sind
if (!source || !target || !sourceHandle || !targetHandle || !edgeId) {
console.error('Fehler: Nicht alle erforderlichen Daten konnten aus dem Wire-Objekt extrahiert werden.', wire);
return null;
}

// Erstellen des Edge-Objekts
return {
id: edgeId,
source: source,
sourceHandle: sourceHandle,
target: target,
targetHandle: targetHandle
};
});

console.log("edges from method", edges);
return edges.filter(edge => edge !== null);
}

export default convertRelationsToReactFlowRelations;
55 changes: 55 additions & 0 deletions Documentation/ChangeLog/12-0-0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
Version 12.0.0
==============

Superfluous dashes in the settings.yaml
^^^^^^^^^^

Because of some important changes it could be necessary to update your :file:`EXT:my_extension/Configuration/ExtensionBuilder/settings.yaml` file manually.

Please remove the dashes, as they could cause some problems while saving the extension.
Expand All @@ -30,3 +33,55 @@ Please remove the dashes, as they could cause some problems while saving the ext
.. note::

We haven't implemented an Upgrade wizard for this. This might change in the future. Feel free to open an Pull-Request on `GitHub <https://github.com/FriendsOfTYPO3/extension_builder/pulls>`__ for this.

.. versionchanged:: v12.0.0-beta.3

Converting propertyIsExcludeField to excludeField
^^^^^^^^^^

If you used a version prior to v12.0.0-beta.3, you might need to change the property `propertyIsExcludeField` to `excludeField` in your TCA ExtensionBuilder.json file manually.

Converting propertyIsExcludeField to excludeField
^^^^^^^^^^

If you used a version prior to `v12.0.0-beta.3`, you might need to change the property `propertyIsExcludeField` for relations to `excludeField` in your TCA ExtensionBuilder.json file manually.

Example:

.. code-block:: json
:caption: EXT:your_ext/Configuration/ExtensionBuilder/settings.yaml
.. code-block:: json
:caption: from:
{
"nodes": [
{
"data": {
"relations": [
{
"propertyIsExcludeField": true
}
]
}
}
]
}
.. code-block:: json
:caption: to:
{
"nodes": [
{
"data": {
"relations": [
{
"excludeField": true
}
]
}
}
]
}
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/main.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# See http://www.yaml.org/spec/1.2/spec.html
#

---

########### Overwrite settings ###########
#
# These settings only apply, if the roundtrip feature of the extension builder
Expand Down

0 comments on commit 3568217

Please sign in to comment.