Skip to content

Commit

Permalink
Редактирование цвета перехода от начального элемента (#387)
Browse files Browse the repository at this point in the history
Co-authored-by: L140-beep <[email protected]>
  • Loading branch information
Roundabout1 and L140-beep authored Aug 14, 2024
1 parent 35cd3d8 commit f7ee916
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@electron-toolkit/utils": "^1.0.2",
"@floating-ui/react": "^0.26.9",
"@floating-ui/react-dom": "^2.0.8",
"@kruzhok-team/cyberiadaml-js": "^1.1.0",
"@kruzhok-team/cyberiadaml-js": "^1.1.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-switch": "^1.0.3",
"@tweenjs/tween.js": "^23.1.1",
Expand Down
22 changes: 19 additions & 3 deletions src/renderer/src/components/NodeModal/TransitionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const TransitionModal: React.FC = () => {
source: State | ChoiceState;
target: State | ChoiceState | FinalState;
} | null>();
const [isInitialTransition, setIsInitialTransition] = useState<boolean>(false);

// Данные формы
const trigger = useTrigger(false);
Expand All @@ -41,6 +42,18 @@ export const TransitionModal: React.FC = () => {
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();

if (isInitialTransition && transition) {
editor.controller.transitions.changeTransition({
id: transition.id,
sourceId: transition.source.id,
targetId: transition.target.id,
color,
});

close();
return;
}

const { selectedComponent, selectedMethod } = trigger;

if (showTrigger && (!selectedComponent || !selectedMethod)) {
Expand Down Expand Up @@ -153,6 +166,7 @@ export const TransitionModal: React.FC = () => {

setTransition(null);
setNewTransition(null);
setIsInitialTransition(false);
};

useEffect(() => {
Expand Down Expand Up @@ -182,6 +196,8 @@ export const TransitionModal: React.FC = () => {
setColor(initialData.color);

setTransition(target);

setIsInitialTransition(initialData.label == undefined);
open();
};

Expand All @@ -205,9 +221,9 @@ export const TransitionModal: React.FC = () => {
onAfterClose={handleAfterClose}
>
<div className="flex flex-col gap-4">
{showTrigger && <Trigger {...trigger} />}
<Condition {...condition} />
<Events {...events} />
{!isInitialTransition && showTrigger && <Trigger {...trigger} />}
{!isInitialTransition && <Condition {...condition} />}
{!isInitialTransition && <Events {...events} />}
<ColorField label="Цвет линии:" value={color} onChange={setColor} />
</div>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export class TransitionsController extends EventEmitter<TransitionsControllerEve
};

handleConditionDoubleClick = (transition: Transition) => {
if (!transition.data.label) return;
this.emit('changeTransition', transition);
};

Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/lib/data/GraphmlBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ function serializeNotes(notes: { [id: string]: Note }): { [id: string]: CGMLNote
text: note.text,
position: note.position,
type: 'informal',
unsupportedDataNodes: [],
};
}
return cgmlNotes;
Expand All @@ -313,6 +314,7 @@ function serializeComponents(components: { [id: string]: Component }): {
type: component.type,
parameters: component.parameters,
order: component.order,
unsupportedDataNodes: [],
};
}
return cgmlComponents;
Expand Down

0 comments on commit f7ee916

Please sign in to comment.