Giter VIP home page Giter VIP logo

nocode-js / sequential-workflow-designer Goto Github PK

View Code? Open in Web Editor NEW
891.0 16.0 95.0 2.15 MB

Customizable no-code component for building flow-based programming applications. 0 external dependencies.

Home Page: https://nocode-js.com/

License: MIT License

TypeScript 90.56% JavaScript 2.09% HTML 0.10% SCSS 5.34% Shell 0.07% Svelte 1.85%
flowchart lowcode nocode workflow designer flow-based-programming workflow-designer component javascript typescript

sequential-workflow-designer's Introduction

Sequential Workflow Designer

Sequential Workflow Designer

Build Status License: MIT View this project on NPM

Sequential workflow designer with 0 external dependencies for web applications. It's written in pure TypeScript and uses SVG for rendering. This designer is not associated with any workflow engine. It's full generic. You may create any kind application by this, from graphical programming languages to workflow builders.

Features:

  • 0 external dependencies,
  • fully generic and configurable,
  • use light/dark themes or customize easily,
  • compatible with modern browsers and mobile devices,
  • the definition is stored as JSON,
  • supports Angular, React and Svelte.

๐Ÿ“ Check the documentation for more details.

๐Ÿคฉ Don't miss the pro version.

๐Ÿ‘€ Examples

Pro:

๐Ÿ‘ฉโ€๐Ÿ’ป Integrations

๐Ÿš€ Installation

To use the designer you should add JS/TS files and CSS files to your project.

NPM

Install this package by NPM command:

npm i sequential-workflow-designer

To import the package:

import { Designer } from 'sequential-workflow-designer';

If you use css-loader or similar, you can add CSS files to your bundle:

import 'sequential-workflow-designer/css/designer.css';
import 'sequential-workflow-designer/css/designer-light.css';
import 'sequential-workflow-designer/css/designer-dark.css';

To create the designer write the below code:

// ...
Designer.create(placeholder, definition, configuration);

CDN

Add the below code to your head section in HTML document.

<head>
...
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/designer.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/designer-light.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/designer-dark.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.umd.js"></script>

Call the designer by:

sequentialWorkflowDesigner.Designer.create(placeholder, definition, configuration);

๐ŸŽฌ Usage

Check examples directory.

import { Designer } from 'sequential-workflow-designer';

const placeholder = document.getElementById('placeholder');

const definition = {
  properties: {
    'myProperty': 'my-value',
    // root properties...
  },
  sequence: [
    // steps...
  ]
};

const configuration = {
  theme: 'light', // optional, default: 'light'
  isReadonly: false, // optional, default: false
  undoStackSize: 10, // optional, default: 0 - disabled, 1+ - enabled

  steps: {
    // all properties in this section are optional

    iconUrlProvider: (componentType, type) => {
      return `icon-${componentType}-${type}.svg`;
    },

    isDraggable: (step, parentSequence) => {
      return step.name !== 'y';
    },
    isDeletable: (step, parentSequence) => {
      return step.properties['isDeletable'];
    },
    isDuplicable: (step, parentSequence) => {
        return true;
    },
    canInsertStep: (step, targetSequence, targetIndex) => {
      return targetSequence.length < 5;
    },
    canMoveStep: (sourceSequence, step, targetSequence, targetIndex) => {
      return !step.properties['isLocked'];
    },
    canDeleteStep: (step, parentSequence) => {
      return step.name !== 'x';
    }
  },

  validator: {
    // all validators are optional

    step: (step, parentSequence, definition) => {
      return /^[a-z]+$/.test(step.name);
    },
    root: (definition) => {
      return definition.properties['memory'] > 256;
    }
  },

  toolbox: {
    isCollapsed: false,
    groups: [
      {
        name: 'Files',
        steps: [
          // steps for the toolbox's group
        ]
      },
      {
        name: 'Notification',
        steps: [
          // steps for the toolbox's group
        ]
      }
    ]
  },

  editors: {
    isCollapsed: false,
    rootEditorProvider: (definition, rootContext, isReadonly) => {
      const editor = document.createElement('div');
      // ...
      return editor;
    },
    stepEditorProvider: (step, stepContext, definition, isReadonly) => {
      const editor = document.createElement('div');
      // ...
      return editor;
    }
  },

  controlBar: true,
  contextMenu: true,
};

const designer = Designer.create(placeholder, definition, configuration);
designer.onDefinitionChanged.subscribe((newDefinition) => {
  // ...
});

You can hide default UI components by setting the corresponding configuration property to false.

const configuration = {
  toolbox: false,
  editors: false,
  controlBar: false,
  contextMenu: false,
  // ...
}

๐Ÿ’ก License

This project is released under the MIT license.

sequential-workflow-designer's People

Contributors

b4rtaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sequential-workflow-designer's Issues

Customization of drop positions and styling

We really like the sequential workflow designer and it's possibilities but are holded back in usage because of the limited styling and drag and drop UX.

Would it be possible to make the drag and drop more user friendly by not just showing all possible drop areas, which on large actions can be very confusing when you see hundreds of placeholders appearing, to be more consistent like modern drag and drop solutions where a blue line as placeholder appear only when you get in the neighborhood of the element.

So when you hover with your drag on top of step box the blue line appear on top or bottom of the box.

A bit like:

https://spectrum.adobe.com/page/tree-view/#Collapse-and-expand

That will be really a great improvement.

Also styling the connecting lines and giving more options about the besier curves will be great.

And lastly incorporating help or info tooltips per box will be also a great addition to show comments.

Support for angular 12

Hi, I am running an existing application with angular 12 and I wish to integrate this with my angular project.

However I see there is some error during compilation stating :

image

Is there currently no support for angular 12? Or is there any workaround I can use?

Thanks in advance :)

Parallel Gateway for two or more paths

Hi, very nice application. I want to run some steps in parallel, like a BPMN Gateway instead of a switched choice. Is this possible? Any recommendation?

BPMN Gateway
Decision point that can adjust the path based on conditions or events. They are shown as diamonds. They can be exclusive or inclusive, parallel, complex, or based on data or events.

Cannot use sequential-workflow-designer-react with React 17 and lower

Steps to Reproduce:

  1. Install the package in a project that uses React 17 or lower versions.
  2. Import and use the package components in a React component.
  3. Attempt to build or run the project.

Expected Behavior:
I expect the package to work seamlessly with React 17 and lower versions without encountering any errors related to 'react-dom/client.'

Actual Behavior:

Module not found: Can't resolve 'react-dom/client' in '.../node_modules/sequential-workflow-designer-react/lib/esm'

The error message mentioned above is preventing me from using the package effectively with React 17 and lower versions.

Additional Information:
I have tried the following troubleshooting steps, but the issue persists:

  • Checked for the presence of 'react' and 'react-dom' in my project's dependencies.
  • Ensured that my webpack configuration is correctly set up to resolve React and ReactDOM.
  • Restarted my development server.

Please let me know if there are any specific configurations or changes I can make to resolve this issue, or if an update to the package is needed to support React 17 and lower versions.

Thank you for your assistance.

Change detection is not working correctly in editor within angular

I would like to suggest a change in the editor provider. I run into some issues, when I tried to use AngularMaterial in the editor - change detection was not working correctly which led to misbehaviour of components. However, when I attached the view to Application Ref everything seems to be working fine.

In designer.component.ts I added one more parameter to constructor:

private appRef: ApplicationRef

and in in editorProvider

this.appRef.attachView(this.lastEmbeddedView);

instead of

this.lastEmbeddedView?.detectChanges();

Could you kindly assess whether incorporating this change into the official repository would be beneficial?

Property value of dynamically rendered component in designer isnt updating immediately

Hey @b4rtaz ,

I have a component that I am using in the designers html , which accepts the an @input() property "reset".

When I change the value of this property , it doesnt seem to call the ngOnChanges of my component.

I need to select outside the step of the designer and click on the step again, for the new value to reflect

I'm pretty sure i am missing something. Would appreciate your help.

<ng-template` #stepEditor let-editor>
    <h2 class='step-header'>Step {{editor.step.name}}</h2>
      <ng-container *ngIf="editor.step.type === 'task'">
        <h3>Input parameters</h3>
        <ng-container *ngIf="editor.step.properties.input_parameters.length > 0">
            <div *ngFor="let element of editor.step.properties.input_parameters;let i = index">
              <div *ngIf="element?.inputType==='file'" class="upload-container">
                    <file-upload
                        (selectionChange)="onFileUploadUpdate($event,element,editor,i,designer,element.name)"
                        allowedFileExtensions=".xlsx, .xls, .pdf, .doc"
                        [resetFile]=resetFile>
                    </file-upload>
              </div>
            </div>
        </ng-container>
      </ng-container>
    </h2>
</ng-template>

I am setting the value of resetFile to false initially and then to true later in my ts file.

Scroll assist

I notice when i have very long workflow then i have to move to the exact position to drop the step

Can we have something like a Scroll assist enable so that when i begin drag the step and move its around then the workflow able to move up,down, left, right

I can imagine if i move the step to the bottom of the svg then we can move up the workflow and vice versa

Its would be really cool to have that because all the workflow libs i found dont have this fearture

Like in this video

2023-06-14.15-19-14.mp4

Undo/Redo - Customize Control Bar

Hello,

Thank you very much for this tool it's very customizable and does the job!

However what is really missing is an undo/redo button preferably you can add custom buttons to the control bar just like how you can customize the toolbox.

Kind regards,

Ravindre

Copy/Paste for steps

Hi,
it would be nice to be able to reuse an already configured step in a different
place in the same flow.
This could be either a copy/paste action or something like /drag.
It'll also be useful to have like an onDuplicate callback for steps to be able to
e.g. make copies of child steps if the copied one is a container or switch.
Are there any plans to support this ?

Thank you and great job btw.
Tilo

Bug: Step drag&drop doesn't work properly with window scroll

We're trying to build a bit more complex ui than is shown on demo. Faced with such problem:
bug-workflow-designer

Seems like window scroll offset isn't included in step element position calculation

Package version:
"sequential-workflow-designer": "0.10.0",
"sequential-workflow-designer-react": "0.10.0",

Start from a specific step

Hello, firstly thank you for great product.

How can i start directly from a specific step to execute like below ?

`My code:

const executeStep = async (step: Step) => {
    const task = taskTypes[step.type];
    await task.execute(step, (sequence: Sequence) => {
        if (sequence?.length) {
            sequence.forEach(async nextStep => {
                await executeStep(nextStep);
            });
        }
    });
}

workflow.sequence.forEach(async (step: Step) => {
    await executeStep(step);
})`

image

How to hide the globar editor on default

Hi i want to when open the page i can auto hide the global editor
here is my code

editors: {
		globalEditorProvider: definition => {
			const root = document.createElement('div');
			root.innerHTML = '<textarea style="width: 100%; border: 0;" rows="50"></textarea>';
			const textarea = root.getElementsByTagName('textarea')[0];
			textarea.value = JSON.stringify(definition, null, 2);
			return root;
		},

		stepEditorProvider: (step, editorContext) => {
			const root = document.createElement('div');
			console.clear();
			// console.log(step.properties)
			console.log(editorContext.notifyPropertiesChanged());
			return root;
		}
	},

Is there a way to toggle the global the editor on start

thanks

Query: adding constraints on drag and drop

Hello,

How can I enforce constraint on drag and drop area for a particular step type.
Say I want the particular task step (identified by step.type) to be added only at the end of switch node branches and nowhere else then how can such constraint be enforced?

Thanks!

the controlbar customize & event listen

  1. how can i put an extend control icon into controlbar๏ผŒand then it can do something else like save action ๏ผ›
  2. an event-listen is in need ๏ผŒsuch as the remove control bar๏ผŒ when i use the remove bar for delete a sequence cmp๏ผŒit can get which cmp had been removed๏ผ›

Single/Multi select is not supported in editors

Hi, I wanted to express my appreciation for this excellent library you've created!

However, I have encountered a situation where I must include a single/multi-select dropdown in the step editor. I attempted to use mat-select and mat-option to display the dropdown in the user interface. While the dropdown is visible, the data is not binding properly, and the dropdown is not populating with any values.

image

image

image

Is there something I'm missing ?

Switch to a previous step

Hello,

I was exploring this library for a flowchart builder I am trying to make.

I am just wondering if there is a way to connect switch to existing steps, instead of redefining steps again?

I am trying to use it kind of multi outcome loop, until a specific condition is met.

Please let me know if this is possible.

Thanks!

public mutation events and pragmatically create actions

is it possible to listen to mutation events of the workflow designer, like:

  • ready - when flow is is fully rendered
  • selected - when a step is selected
  • move - when step is moved, with from parents to new parents/position
  • delete - when step is deleted
  • rename - when title is changed

on the other hand can we pragmatically create new steps or delete/move existing. A public api for this will be very useful

How to know is finished ?

Hello, how to know is finished ?

`Is this code correct ?

const machine = builder.build(workflow);
const interpreter = machine.create({ init: () => state });

interpreter.onChange(() => { });
interpreter.onDone(() => {
    const snapshot = interpreter.getSnapshot();
    if (snapshot.statePath.includes('FINISHED')) {
        // correct ?
    }
});
interpreter.start();`

image

Svelte Support for Sequential Workflow Designer

Hello,

I appreciate the work on sequential-workflow-designer. It's been great for React and Angular projects. Given Svelte's growing popularity, it would be beneficial to have similar support for it.

If direct Svelte support is in the pipeline, could you guide us on integrating the JavaScript version into Svelte projects in the meantime?

Thank you for considering this. Looking forward to future updates!

How to get parent id of steps?

Hi,
I want to get the parent id of each step in the sequence. Like in this example sequence :

{
  "properties": {},
  "sequence": [
    {
      "id": "3e3c74a32774273fa5fbbe9ee2467be0",
      "componentType": "largeTask",
      "type": "welcome-new-subscriber",
      "name": "Welcome new subscriber",
      "properties": {
        "draggable": false,
        "deletable": true,
        "type": "trigger"
      }
    },
    {
      "id": "28429992da9bc6f5902a440b69fe1743",
      "componentType": "switch",
      "type": "if",
      "name": "Open email ?",
      "branches": {
        "yes": [
          {
            "id": "bd10bcc08104adec84b821dca3697e9b",
            "componentType": "largeTask",
            "type": "add-tag",
            "name": "Add tag",
            "properties": {
              "draggable": true,
              "deletable": true,
              "type": "action"
            }
          }
        ],
        "no": []
      },
      "properties": {
        "draggable": true,
        "type": "condition"
      }
    }
  ]
}

is there any built in function to get the parent id and convert the json into this

{
  "properties": {},
  "sequence": [
    {
      "id": "3e3c74a32774273fa5fbbe9ee2467be0",
      "componentType": "largeTask",
      "type": "welcome-new-subscriber",
      "name": "Welcome new subscriber",
      "properties": {
        "draggable": false,
        "deletable": true,
        "type": "trigger"
      },
      "child" : "28429992da9bc6f5902a440b69fe1743"
    },
    {
      "id": "28429992da9bc6f5902a440b69fe1743",
      "componentType": "switch",
      "type": "if",
      "name": "Open email ?",
      "branches": {
        "yes": [
          {
            "id": "bd10bcc08104adec84b821dca3697e9b",
            "componentType": "largeTask",
            "type": "add-tag",
            "name": "Add tag",
            "properties": {
              "draggable": true,
              "deletable": true,
              "type": "action"
            }
          }
        ],
        "no": []
      },
      "properties": {
        "draggable": true,
        "type": "condition"
      },
      "child" : null
    }
  ]
}

have the properties child corresponding for each step
thanks

[react] Throw exception on undo action

Reproduce:

  1. Access the demo page for react: https://nocode-js.github.io/sequential-workflow-designer/react-app/
  2. In the designer, I add the step to workflow
  3. Click undo button, throw bellow exception:
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
    at e.value (https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:170191)
    at https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:170856
    at e.handler (https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:170872)
    at e.value (https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:155447)
    at e.value (https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:155616)
    at https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:155934
    at https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:154814
    at Array.forEach (<anonymous>)
    at e.value (https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:154786)
    at https://nocode-js.github.io/sequential-workflow-designer/react-app/static/js/main.63aec97b.js:2:155093

Peek 2023-10-25 16-31

user defined number of branches for the switch

Currently the switch component allows only predefines number of branches.

When using as select/case 1/case 2/case xx it is much desirable to let the user define visually how many cases he wants. So there must be visually a possibility to add more cases.

So a new option for user defined branches will be really welcome.

Can i use google font in icon step

Hello and thanks you for the library. Its work very good
I want to ask if i can use icon step as google font like make the icon as an html

	steps: {
		iconUrlProvider: (componentType, type) => {
			return `far fa-user-plus;
		}
	},

Backspace key delete step

I have a custom input (a div editable) in a step when i try to delete the content od this with the backspace key, this delete te entry step.

Note: I use a div editable because it allow to set style to variable.
tag_input

dynamically add or remove available ( predefined ) steps in toolbox.

I have recently started exploring the sequential workflow designer, and I want to add it to my React application. In my app, any one step can only be added once, so I want to make that once a step is selected/dropped in the workspace it should be hidden in the toolbox and when I remove it, it should again reappear in the toolbox.

Does anyone know how to do like this,?

Highlight Multiple Steps

Is ist Possible to Highlight / Select Multiple steps? This would be useful if you have parallel running steps and want to show this.

Is Horizontal Workflow possible?

Good morning @b4rtaz , congratulations for your workflow.
I need to work with somewhat extensive flows.
In this case, the view of the processes only vertically will be too large. Would it be possible to add steps in the flow horizontally as well?

Example:
image

Is it possible to interact with transitions

Hi there!

1st of all congrats for your work. It looks amazing and clean!

I have a questions regarding the transitions between workflow states, that would be the lines that connect the steps in your case. I'd like to know if they could be selectable and then apply a name to them.

Imaging the following example. I have a simple approval workflow with two states (steps in your case): In "Review" and "Approved". The line connecting both states is a transition called 'approve' which I need to be reflected in the diagram and interact with it (eg: onclick, ...)

Thanks a lot for your time!

Is it possible to create a "Stop" step?

Hi, sorry about posting two issues at once.

I'm wondering how I can create a step that "stops" the flow, ie is not connected to the continued flow?

Something like this
(link redacted)

Thanks!

New step not getting focus and global editor not updated

Great job on this project!

Not sure if this is intended behavior but after dragging a new step into the workflow I expected the newly added step to have focus and the appropriate step editor rendered. Instead, the focus stays on the global editor and doesn't reflect the underlying definition change.

Steps to Repro (version 0.1.6):

  • Start with an empty definition in the fullscreen example (the global editor is shown)
  • Add a step from the toolbox (focus remains on the global editor showing the empty definition even though onDefinitionChanged is called on the designer)
  • Change focus to the newly added step and then back to the overall process (globalEditorProvider is called and the current state of the definition is now rendered)

Error while downloading dependencies

Hi,

I have tried to run below command as documentations said:

npm i sequential-workflow-designer

this command failed to below lines:

npm WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "from" argument must be of type string. Received undefined

npm ERR! A complete log of this run can be found in:
npm ERR! /home/reza/.npm/_logs/2023-04-30T22_14_52_723Z-debug-0.log

I have tried to read debug-0.log file:

7817 http fetch GET 200 https://registry.npmjs.org/eslint/-/eslint-5.12.0.tgz 37068ms (cache miss)
7818 timing reifyNode:node_modules/react-scripts/node_modules/eslint Completed in 39388ms
7819 timing reifyNode:node_modules/react-scripts/node_modules/jsdom Completed in 39571ms
7820 warn deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
7821 timing reifyNode:node_modules/react-app-polyfill/node_modules/core-js Completed in 46711ms
7822 timing reifyNode:node_modules/react-dev-utils/node_modules/rxjs Completed in 59539ms
7823 timing reifyNode:node_modules/react-scripts/node_modules/rxjs Completed in 59578ms
7824 timing reify:unpack Completed in 59580ms
7825 timing command:audit Completed in 379876ms
7826 verbose stack TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
7826 verbose stack at validateString (internal/validators.js:120:11)
7826 verbose stack at relative (path.js:1053:5)
7826 verbose stack at /usr/share/nodejs/@npmcli/arborist/lib/arborist/reify.js:1072:21
7826 verbose stack at Array.map ()
7826 verbose stack at /usr/share/nodejs/@npmcli/arborist/lib/arborist/reify.js:1070:66
7826 verbose stack at Array.map ()
7826 verbose stack at Arborist.[rollbackMoveBackRetiredUnchanged] (/usr/share/nodejs/@npmcli/arborist/lib/arborist/reify.js:1070:8)
7826 verbose stack at Arborist.[reifyPackages] (/usr/share/nodejs/@npmcli/arborist/lib/arborist/reify.js:234:31)
7826 verbose stack at async Arborist.reify (/usr/share/nodejs/@npmcli/arborist/lib/arborist/reify.js:154:5)
7826 verbose stack at async Audit.exec (/usr/share/nodejs/npm/lib/commands/audit.js:49:5)
7827 verbose cwd /mnt/d/Workflow/sequential-workflow-designer
7828 verbose Linux 5.10.16.3-microsoft-standard-WSL2
7829 verbose argv "/usr/bin/node" "/usr/bin/npm" "audit" "fix"
7830 verbose node v12.22.9
7831 verbose npm v8.5.1
7832 error code ERR_INVALID_ARG_TYPE
7833 error The "from" argument must be of type string. Received undefined
7834 verbose exit 1
7835 timing npm Completed in 379990ms
7836 verbose unfinished npm timer reify 1682893087375
7837 verbose unfinished npm timer reify:unretire 1682893272705
7838 verbose code 1
7839 error A complete log of this run can be found in:
7839 error /home/reza/.npm/_logs/2023-04-30T22_14_52_723Z-debug-0.log

Scrolling issue in toolbox

Hello,

While using the toolbox, I've noticed that scrolling also affects the main web view.

I believe it would be more user-friendly if these two elements operated independently. Specifically, when scrolling within the toolbox, it shouldn't impact the scrolling behavior of the main web view.

This would ensure a smoother and more intuitive user experience, especially when the toolbox contains numerous items.


Picture:

toolbox
Screenshot from 2023-10-06 15-45-57

main web view
Screenshot from 2023-10-06 15-47-47


Video:

NoCodeJS_Scroll.mp4

app.component.html
<sqd-designer
	theme="light"
	[undoStackSize]="10"
	[definition]="definition"
	[toolboxConfiguration]="toolboxConfiguration"
	[stepsConfiguration]="stepsConfiguration"
	[validatorConfiguration]="validatorConfiguration"
	[controlBar]="true"
	[areEditorsHidden]="false"
	[globalEditor]="globalEditor"
	[stepEditor]="stepEditor"
	(onReady)="onDesignerReady($event)"
	(onDefinitionChanged)="onDefinitionChanged($event)"
>
</sqd-designer>

<ng-template #globalEditor let-editor>
	<h2>Global Editor</h2>

	<h3>Velocity</h3>
	<mat-form-field class="full-width">
		<input
			matInput
			type="number"
			[value]="editor.definition.properties.velocity"
			(input)="updateProperty(editor.definition.properties, 'velocity', $event, editor.context)"
		/>
	</mat-form-field>
</ng-template>

<ng-template #stepEditor let-editor>
	<h2>Step Editor</h2>

	<mat-tab-group>
		<mat-tab label="Basic">
			<h3>Name</h3>
			<mat-form-field class="full-width">
				<input matInput type="text" [value]="editor.step.name" (input)="updateName(editor.step, $event, editor.context)" />
			</mat-form-field>
		</mat-tab>
		<mat-tab label="Details">
			<h3>Velocity</h3>
			<mat-form-field class="full-width">
				<input
					matInput
					type="number"
					[value]="editor.step.properties.velocity"
					(input)="updateProperty(editor.step.properties, 'velocity', $event, editor.context)"
				/>
			</mat-form-field>
		</mat-tab>
	</mat-tab-group>
</ng-template>

<div class="block">
	<button mat-raised-button color="primary" (click)="reloadDefinitionClicked()">Reload definition</button>
	&nbsp; Is valid: <strong>{{ isValid }}</strong>
</div>

<div class="block">
	<mat-form-field class="full-width flex-1s">
		<textarea matInput cols="120" rows="16" readonly>{{ definitionJSON }}</textarea>
	</mat-form-field>
</div>

<div class="block">
	<mat-form-field class="full-width flex-1s">
		<textarea matInput cols="120" rows="16" >{{ definitionJSON }}</textarea>
	</mat-form-field>
</div>


<div class="block">
	This demo uses Angular, Material UI and
	<a href="https://github.com/nocode-js/sequential-workflow-designer/tree/main/angular/designer" target="_blank"
		>Sequential Workflow Designer for Angular</a
	>.
</div>

In this file, I duplicated the class="block" to extend the length of the main web view, enabling scrolling.

app.component.ts
import { Component, OnInit } from '@angular/core';
import {
	Definition,
	Designer,
	GlobalEditorContext,
	Properties,
	Uid,
	Step,
	StepEditorContext,
	StepsConfiguration,
	ToolboxConfiguration,
	ValidatorConfiguration
} from 'sequential-workflow-designer';

function createStep(): Step {
	return {
		id: Uid.next(),
		componentType: 'task',
		name: 'Step',
		properties: { velocity: 0 },
		type: 'task'
	};
}

function testToolbox(): Step[]{
	let length = 10;
	let examples :Step[]=[];
	for (let nums=0;nums<length;nums++){
		examples.push({
			id: Uid.next(),
			componentType: 'task',
			name: 'Step'+nums,
			properties: { velocity: 0 },
			type: 'task'
		})
	}
		
	
	return examples
}

function createDefinition(): Definition {
	
	return {
		properties: {
			velocity: 0
		},
		sequence: [createStep()]
	};
}

@Component({
	selector: 'app-root',
	templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
	private designer?: Designer;

	public definition: Definition = createDefinition();
	public definitionJSON?: string;
	public isValid?: boolean;

	public readonly toolboxConfiguration: ToolboxConfiguration = {
		groups: [
			{
				name: 'Step',
				steps: [createStep()]
			},
			{
				name: 'test',
				steps:testToolbox()
			},
		]
	};
	public readonly stepsConfiguration: StepsConfiguration = {
		iconUrlProvider: () => './assets/angular-icon.svg'
	};
	public readonly validatorConfiguration: ValidatorConfiguration = {
		step: (step: Step) => !!step.name && Number(step.properties['velocity']) >= 0,
		root: (definition: Definition) => Number(definition.properties['velocity']) >= 0
	};

	public ngOnInit() {
		this.updateDefinitionJSON();
	}

	public onDesignerReady(designer: Designer) {
		this.designer = designer;
		this.updateIsValid();
		console.log('designer ready', this.designer);
	}

	public onDefinitionChanged(definition: Definition) {
		this.definition = definition;
		this.updateIsValid();
		this.updateDefinitionJSON();
		console.log('definition has changed');
	}

	public updateName(step: Step, event: Event, context: StepEditorContext) {
		step.name = (event.target as HTMLInputElement).value;
		context.notifyNameChanged();
	}

	public updateProperty(properties: Properties, name: string, event: Event, context: GlobalEditorContext | StepEditorContext) {
		properties[name] = (event.target as HTMLInputElement).value;
		context.notifyPropertiesChanged();
	}

	public reloadDefinitionClicked() {
		this.definition = createDefinition();
		this.updateDefinitionJSON();
	}

	private updateDefinitionJSON() {
		this.definitionJSON = JSON.stringify(this.definition, null, 2);
	}

	private updateIsValid() {
		this.isValid = this.designer?.isValid();
	}
}

In this file, I've created a function testToolbox():Step[] to generate multiple step items in the toolbox.

Both of these files are based on the angular-app folder within the demos directory of the repository.

User defined conditionals?

Is it possible for the conditional step to have multiple user defined conditions? In our case we need a switch where the user can add its own case choices.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.