-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
409 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
demos/webpack-app/public/assets/placement-restrictions.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
html, | ||
body, | ||
#designer { | ||
margin: 0; | ||
padding: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
overflow: hidden; | ||
} | ||
body, | ||
input, | ||
textarea { | ||
font: 14px/1.3em Arial, Verdana, sans-serif; | ||
} | ||
.sqd-global-editor { | ||
padding: 10px; | ||
line-height: 1.3em; | ||
box-sizing: border-box; | ||
} | ||
a { | ||
color: #000; | ||
text-decoration: underline; | ||
} | ||
a:hover { | ||
text-decoration: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>🎯 Placement Restrictions - Sequential Workflow Editor</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> | ||
<link rel="icon" href="./assets/favicon.ico" /> | ||
<script src="./builds/placement-restrictions.js" defer></script> | ||
<link rel="stylesheet" href="./assets/placement-restrictions.css" /> | ||
</head> | ||
<body> | ||
<div id="designer"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { EditorProvider } from 'sequential-workflow-editor'; | ||
import { SocketStep, definitionModel } from './definition-model'; | ||
import { Designer, Uid } from 'sequential-workflow-designer'; | ||
|
||
import 'sequential-workflow-designer/css/designer.css'; | ||
import 'sequential-workflow-designer/css/designer-light.css'; | ||
import 'sequential-workflow-editor/css/editor.css'; | ||
|
||
export class App { | ||
public static create() { | ||
const placeholder = document.getElementById('designer') as HTMLElement; | ||
|
||
const editorProvider = EditorProvider.create(definitionModel, { | ||
uidGenerator: Uid.next | ||
}); | ||
|
||
const definition = editorProvider.activateDefinition(); | ||
const loop = editorProvider.activateStep('socket') as SocketStep; | ||
loop.sequence.push(editorProvider.activateStep('writeSocket')); | ||
const break_ = editorProvider.activateStep('writeSocket'); | ||
definition.sequence.push(loop); | ||
definition.sequence.push(break_); | ||
|
||
Designer.create(placeholder, definition, { | ||
controlBar: true, | ||
editors: { | ||
globalEditorProvider: () => { | ||
const editor = document.createElement('div'); | ||
editor.innerHTML = | ||
'This example shows how to restrict the placement of steps. The write socket step can only be placed inside a socket step. <a href="https://github.com/nocode-js/sequential-workflow-editor">GitHub</a>'; | ||
return editor; | ||
}, | ||
stepEditorProvider: editorProvider.createStepEditorProvider() | ||
}, | ||
validator: { | ||
step: editorProvider.createStepValidator(), | ||
root: editorProvider.createRootValidator() | ||
}, | ||
steps: { | ||
iconUrlProvider: () => './assets/icon-task.svg' | ||
}, | ||
toolbox: { | ||
groups: editorProvider.getToolboxGroups(), | ||
labelProvider: editorProvider.createStepLabelProvider() | ||
} | ||
}); | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', App.create, false); |
59 changes: 59 additions & 0 deletions
59
demos/webpack-app/src/placement-restrictions/definition-model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
createDefinitionModel, | ||
createNumberValueModel, | ||
createSequentialStepModel, | ||
createStepModel, | ||
createStringValueModel | ||
} from 'sequential-workflow-editor-model'; | ||
import { SequentialStep } from 'sequential-workflow-model'; | ||
|
||
export interface SocketStep extends SequentialStep { | ||
type: 'socket'; | ||
componentType: 'container'; | ||
properties: { | ||
ip: string; | ||
port: number; | ||
}; | ||
} | ||
|
||
export interface WriteSocketStep extends SequentialStep { | ||
type: 'writeSocket'; | ||
componentType: 'task'; | ||
properties: { | ||
data: string; | ||
}; | ||
} | ||
|
||
export const definitionModel = createDefinitionModel(model => { | ||
model.root(() => { | ||
// | ||
}); | ||
model.steps([ | ||
createSequentialStepModel<SocketStep>('socket', 'container', step => { | ||
step.property('ip').value( | ||
createStringValueModel({ | ||
defaultValue: '127.0.0.1' | ||
}) | ||
); | ||
step.property('port').value( | ||
createNumberValueModel({ | ||
defaultValue: 5000 | ||
}) | ||
); | ||
}), | ||
createStepModel<WriteSocketStep>('writeSocket', 'task', step => { | ||
step.property('data').value( | ||
createStringValueModel({ | ||
defaultValue: 'Hello World!' | ||
}) | ||
); | ||
|
||
step.validator({ | ||
validate(context) { | ||
const parentTypes = context.getParentStepTypes(); | ||
return parentTypes.includes('socket') ? null : 'The write socket step must be inside a socket.'; | ||
} | ||
}); | ||
}) | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.