Skip to content

Commit 7e388d8

Browse files
committed
0.2.2.
1 parent b76c4b7 commit 7e388d8

7 files changed

+45
-16
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.2
2+
3+
Added the `notifyChildrenChanged()` method to the `StepEditorContext` interface.
4+
15
## 0.2.1
26

37
Support undo and redo. This feature is disabled by default. To enable it add the below config.

examples/assets/fullscreen.js

+27-7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ function toolboxGroup(name) {
4848
};
4949
}
5050

51+
function appendCheckbox(root, label, isChecked, onClick) {
52+
const item = document.createElement('div');
53+
item.innerHTML = '<div><h5></h5> <input type="checkbox" /></div>';
54+
const h5 = item.getElementsByTagName('h5')[0];
55+
h5.innerText = label;
56+
const input = item.getElementsByTagName('input')[0];
57+
input.checked = isChecked;
58+
input.addEventListener('click', () => {
59+
onClick(input.checked);
60+
});
61+
root.appendChild(item);
62+
}
63+
5164
let designer;
5265
const configuration = {
5366
undoStackSize: 20,
@@ -83,15 +96,22 @@ const configuration = {
8396

8497
stepEditorProvider: (step, editorContext) => {
8598
const root = document.createElement('div');
86-
root.innerHTML = '<h5></h5> <p>is invalid: <input type="checkbox" /></p>';
87-
const title = root.getElementsByTagName('h5')[0];
88-
title.innerText = step.name;
89-
const input = root.getElementsByTagName('input')[0];
90-
input.checked = !!step.properties['isInvalid'];
91-
input.addEventListener('click', () => {
92-
step.properties['isInvalid'] = !!input.checked;
99+
100+
appendCheckbox(root, 'Is invalid', !!step.properties['isInvalid'], (checked) => {
101+
step.properties['isInvalid'] = checked;
93102
editorContext.notifyPropertiesChanged();
94103
});
104+
105+
if (step.type === 'if') {
106+
appendCheckbox(root, 'Catch branch', !!step.branches['catch'], (checked) => {
107+
if (checked) {
108+
step.branches['catch'] = [];
109+
} else {
110+
delete step.branches['catch'];
111+
}
112+
editorContext.notifyChildrenChanged();
113+
});
114+
}
95115
return root;
96116
}
97117
}

package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sequential-workflow-designer",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"main": "./lib/designer.js",
55
"types": "./lib/designer.d.ts",
66
"repository": {

src/designer-configuration.ts

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface EditorsConfiguration {
4444
export interface StepEditorContext {
4545
notifyNameChanged(): void;
4646
notifyPropertiesChanged(): void;
47+
notifyChildrenChanged(): void;
4748
}
4849

4950
export type StepEditorProvider = (step: Step, context: StepEditorContext) => HTMLElement;

src/designer-state.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface DefinitionChangedEvent {
1010
export enum DefinitionChangeType {
1111
stepNameChanged = 1,
1212
stepPropertyChanged,
13+
stepChildrenChanged,
1314
stepDeleted,
1415
stepMoved,
1516
stepInserted,

src/smart-editor/step-editor.ts

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export class StepEditor implements Editor {
1313
},
1414
notifyNameChanged: () => {
1515
context.state.notifyDefinitionChanged(DefinitionChangeType.stepNameChanged, step.id);
16+
},
17+
notifyChildrenChanged: () => {
18+
context.state.notifyDefinitionChanged(DefinitionChangeType.stepChildrenChanged, step.id);
1619
}
1720
};
1821

0 commit comments

Comments
 (0)