Skip to content

Commit

Permalink
current state for deleting a relation from model
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Kuhlmay committed Jan 30, 2024
1 parent 7813ab6 commit 98c01fa
Show file tree
Hide file tree
Showing 13 changed files with 4,600 additions and 123 deletions.
4 changes: 2 additions & 2 deletions Build/Sources/components/ActionButtonsComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const ActionButtonsComponent = (props) => {
"rows": property.rows || "10",
"minItems": property.minItems || "",
"maxItems": property.maxItems || "",
"uid": uuidv4()
"uid": property.uuid || uuidv4()
}
);
});
Expand All @@ -110,7 +110,7 @@ export const ActionButtonsComponent = (props) => {
"relationType": relation.relationType || "anyToMany",
"relationWire": "[wired]",
"renderType": "selectSingle",
"uid": uuidv4()
"uid": relation.uid || uuidv4()
}
);
});
Expand Down
139 changes: 26 additions & 113 deletions Build/Sources/components/ReactFlow/CustomModelNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,114 +12,30 @@ import relationTypes from "./customModelNode/relationTypes";
import { faArrowUp, faArrowDown, faTrash } from '@fortawesome/free-solid-svg-icons'

import {AdvancedOptionsContext, RemoveEdgeContext } from "../../App";
import { v4 as uuidv4 } from 'uuid';
import modelProperty from "../../initialValues/modelProperty";


export const CustomModelNode = (props) => {
const [properties, setProperties] = useState(props.data.properties);
const [relations, setRelations] = useState(props.data.relations);
const [relationIndex, setRelationIndex] = useState(0);

const [customActions, setCustomActions] = useState([]);

const {isAdvancedOptionsVisible} = useContext(AdvancedOptionsContext);
const {removeEdge} = useContext(RemoveEdgeContext);

// TODO: create a default property inside an empty js file and set it her.
const addEmptyProperty = () => {
setProperties([...properties, {
name: '',
type: '',
description: '',
isRequired: false,
isNullable: false,
isExcludeField: false,
isl10nModeExlude: false,
typeSelect: {
selectboxValues: "",
renderType: "selectSingle",
foreignTable: "",
},
typeText: {
enableRichtext: false,
},
typeNumber: {
enableSlider: false,
steps: 1,
setRange: false,
upperRange: 255,
lowerRange: 0,
},
typeColor: {
setValuesColorPicker: false,
colorPickerValues: '',
},
typeBoolean: {
renderType: "default",
booleanValues: "",
},
typePassword: {
renderPasswordGenerator: false,
},
typeDateTime: {
dbTypeDateTime: "",
formatDateTime: "",
},
typeFile: {
allowedFileTypes: "",
},
size: "",
minItems: "",
maxItems: "",
}]);
props.data.properties.push(
{
name: '',
type: '',
description: '',
isRequired: false,
isNullable: false,
excludeField: false,
isl10nModeExlude: false,
typeSelect: {
selectboxValues: "",
renderType: "selectSingle",
foreignTable: "",
},
typeText: {
enableRichtext: false,
},
typeNumber: {
enableSlider: false,
steps: 1,
setRange: false,
upperRange: 255,
lowerRange: 0,
},
typeColor: {
setValuesColorPicker: false,
colorPickerValues: '',
},
typeBoolean: {
renderType: "default",
booleanValues: "",
},
typePassword: {
renderPasswordGenerator: false,
},
typeDateTime: {
dbTypeDateTime: "",
formatDateTime: "",
},
typeFile: {
allowedFileTypes: "",
},
size: "",
minItems: "",
maxItems: "",
}
);
const newProperty = modelProperty;

setProperties([...properties, newProperty]);
props.data.properties.push(newProperty);
}

// TODO: uuid should not be hard coded ???
const addEmptyRelation = () => {
setRelations([...relations, {
const newRelation = {
"foreignRelationClass": "",
"lazyLoading": true,
"excludeField": true,
Expand All @@ -128,21 +44,17 @@ export const CustomModelNode = (props) => {
"relationType": "",
"relationWire": "",
"renderType": "",
"uid": "905857860343"
}]);
props.data.relations.push(
{
"foreignRelationClass": "",
"lazyLoading": true,
"excludeField": true,
"relationDescription": "",
"relationName": "",
"relationType": "",
"relationWire": "",
"renderType": "",
"uid": "905857860343"
}
);
"uid": uuidv4() // Hier wird die UUID generiert
};

setRelations([...relations, newRelation]);
props.data.relations.push(newRelation);
}

const getNewRelationIndex = () => {
setRelationIndex(relationIndex + 1);
console.log('relationIndex', relationIndex);
return relationIndex;
}

const addEmptyAction = () => {
Expand Down Expand Up @@ -259,7 +171,7 @@ export const CustomModelNode = (props) => {
><FontAwesomeIcon className="font-awesome-icon" icon="fa-solid fa-trash" /></button>
<Handle
type="target"
id={`customModelNode-${props.id}`}
id={`cmn-${props.id}`}
position={Position.Left}
onConnect={(params) => console.log('handle onConnect', params)}
style={{
Expand Down Expand Up @@ -771,7 +683,8 @@ export const CustomModelNode = (props) => {
<div className="relation">
<Handle
type="source"
id={`relation-${props.id}-${index}`}
id={`rel-${props.id}-${index}`}
/*id={`rel-${props.id}-${getNewRelationIndex}`}*/
position={Position.Left}
onConnect={(params) => console.log('handle onConnect', params)}
style={{
Expand All @@ -783,7 +696,7 @@ export const CustomModelNode = (props) => {
}}
/>
<TYPO3StyledAccordion
title={`${relation.relationName} ${relation.relationType ? `(${relation.relationType})` : ''}`}
title={`${props.id} - ${index} - ${relation.relationName} ${relation.relationType ? `(${relation.relationType})` : ''}`}
id={`nodeRelation-${props.id}-${index}`}
parentId="accordionCustomModelNodeRelations"
>
Expand Down Expand Up @@ -844,7 +757,7 @@ export const CustomModelNode = (props) => {
<button
className="btn btn-danger me-auto"
onClick={() => {
removeRelation(index, `relation-${props.id}-${index}`);
removeRelation(index, `rel-${props.id}-${index}`);
}}
>
<FontAwesomeIcon icon={faTrash}/>
Expand Down
4 changes: 2 additions & 2 deletions Build/Sources/components/views/LeftContentComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export const LeftContentComponent = (props) => {
moveModule={props.moveModule}
/>
</div>
{/*<div className="panel-group" id="accordion-left-panel-debug">
<div className="panel-group" id="accordion-left-panel-debug">
<DebugOutputAccordion
properties={props.properties}
authors={props.authors}
plugins={props.plugins}
modules={props.modules}
/>
</div>*/}
</div>
</Fragment>
)
}
47 changes: 47 additions & 0 deletions Build/Sources/initialValues/modelProperty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const modelProperty = {
name: '',
type: '',
description: '',
isRequired: false,
isNullable: false,
isExcludeField: false,
isl10nModeExlude: false,
typeSelect: {
selectboxValues: "",
renderType: "selectSingle",
foreignTable: "",
},
typeText: {
enableRichtext: false,
},
typeNumber: {
enableSlider: false,
steps: 1,
setRange: false,
upperRange: 255,
lowerRange: 0,
},
typeColor: {
setValuesColorPicker: false,
colorPickerValues: '',
},
typeBoolean: {
renderType: "default",
booleanValues: "",
},
typePassword: {
renderPasswordGenerator: false,
},
typeDateTime: {
dbTypeDateTime: "",
formatDateTime: "",
},
typeFile: {
allowedFileTypes: "",
},
size: "",
minItems: "",
maxItems: "",
}

export default modelProperty;
16 changes: 16 additions & 0 deletions Build/nachher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"source": "dndnode_0",
"sourceHandle": "relation-dndnode_0-1",
"target": "dndnode_2",
"targetHandle": "customModelNode-dndnode_2",
"id": "reactflow__edge-dndnode_0relation-dndnode_0-1-dndnode_2customModelNode-dndnode_2"
},
{
"source": "dndnode_0",
"sourceHandle": "relation-dndnode_0-0",
"target": "dndnode_1",
"targetHandle": "customModelNode-dndnode_1",
"id": "reactflow__edge-dndnode_0relation-dndnode_0-0-dndnode_1customModelNode-dndnode_1"
}
]
16 changes: 16 additions & 0 deletions Build/vorher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"source": "dndnode_0",
"sourceHandle": "relation-dndnode_0-0",
"target": "dndnode_1",
"targetHandle": "customModelNode-dndnode_1",
"id": "reactflow__edge-dndnode_0relation-dndnode_0-0-dndnode_1customModelNode-dndnode_1"
},
{
"source": "dndnode_0",
"sourceHandle": "relation-dndnode_0-1",
"target": "dndnode_2",
"targetHandle": "customModelNode-dndnode_2",
"id": "reactflow__edge-dndnode_0relation-dndnode_0-1-dndnode_2customModelNode-dndnode_2"
}
]
24 changes: 24 additions & 0 deletions Build/zwischen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"source": "dndnode_0",
"sourceHandle": "relation-dndnode_0-1",
"target": "dndnode_2",
"targetHandle": "customModelNode-dndnode_2",
"id": "reactflow__edge-dndnode_0relation-dndnode_0-1-dndnode_2customModelNode-dndnode_2"
}
]


// Oberes gelöscht


// eins neu
[
{
"source": "dndnode_0",
"sourceHandle": "relation-dndnode_0-1",
"target": "dndnode_2",
"targetHandle": "customModelNode-dndnode_2",
"id": "reactflow__edge-dndnode_0relation-dndnode_0-1-dndnode_2customModelNode-dndnode_2"
}
]
61 changes: 61 additions & 0 deletions Classes/Command/MigrateExtensionCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace EBT\ExtensionBuilder\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class MigrateExtensionCommand extends Command
{
public function __construct(
) {
parent::__construct();
}

protected function configure(): void
{
$this->addOption(
'extension',
'e',
InputOption::VALUE_OPTIONAL,
'Extension which should be migrated'
);
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
// get all given parameters
$extension = $input->getOption('extension');

// first check, if all given parameters are valid
if ($extension === null || $extension === '') {
$output->writeln('<error>No extension key is give. You must provide an extension key for migration.</error>');
return Command::INVALID;
}
// Get a list of all available extensions

// compare the list, if the given extension is available

// if yes, then migrate the extension

// if succeeded, then show a success message
return Command::SUCCESS;
}
}
Loading

0 comments on commit 98c01fa

Please sign in to comment.