使用HTML / CSS / JS创建工作流生成器 [英] Create a workflow generator using HTML/CSS/JS

查看:74
本文介绍了使用HTML / CSS / JS创建工作流生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个工作流生成器,您可以在一个

I'm creating a workflow generator where you can fill in some questions in select form dropdowns in one

中填写选择表单下拉列表中的一些问题,更改时将更改工作流中的文本并将图片添加到侧边栏(如果它们与流相关) 。我已经知道如何做到这一点,它按照我想要的方式工作。



我的问题是我想知道是否有最佳方式做这个。我有成千上万的行和场景,我只是想知道是否可以像我目前所做的那样编写Javascript中的所有可能性,或者是否更容易将它们写入XML文件并从中读取或其他内容。



我的尝试:



目前手写所有可能的JS文件中的解决方案。
, that when changed will change the text in the workflow and add pictures to a sidebar if they are relevant to the flow. I already know how to do this and it works the way that I want it to.

My issue is that I would like to know if there is an optimal way to do this. I have thousands of lines and scenarios that I am just wondering if it's fine to write all of the possibilities in Javascript like I am doing currently, or if it would be easier to write them into an XML file and read from that or something else.

What I have tried:

Currently handwriting all of the possible solutions in the JS file.

推荐答案

这是基于状态机的解决方案的理想选择。实际上,工作流程定义为状态机。如果你还不熟悉的话,搜索一下这个主题的背景,你会发现很多描述。



为什么要这么麻烦?好吧,你已经说过你有成千上万行的JS。如果将解决方案正式化为状态机,或者您可能需要嵌套计算机。例如使用外部机器引导整个工作流程,在输入某些顶级状态时激活子机器。



这种方法应该有助于组织你的关于解决方案的想法,而不是记录它。一旦您拥有通用状态机实现,就可以轻松添加对工作流程的更改。



状态机的主要功能是:(1)定义状态,这些是工作流程中的活动(要完成的事情); (2)定义允许的转换(如果处于状态A,你可以移动到状态B,C,......Z,也可能还回到A等); (3)定义驱动状态转换的事件。在您的情况下,某些工作的完成可能是一个事件,但可能会发生中断,例如取消任务,这可能会触发转换到另一个状态(例如空闲)。



我认为你不应该把XML视为一种可以采用的东西,因为它似乎是一种可能有用的技术。是的,XML可能会发挥作用,但您需要首先完成 设计 并让所使用的技术源于此,而不是先设计先前的假设您应该使用这种或那种技术。



我发布这个可能有点乐观的解决方案,但是,实际上我不认为你的问题可以用更具体的术语来回答。祝它好运 - 听起来像一个有趣的项目!
This is an ideal candidate for a State Machine based solution. In fact a workflow is by definition a state machine. Search for some background on this topic if you're not already familar, you'll find many descriptions.

Why bother? Well you've said yourself that you have many thousands of lines of JS. If you formalise your solution into a state machine, or you may need a nested machine. e.g. Using an "outer" machine that guides through the overall workflow, with sub-machines activated when certain top level states are entered.

This approach should help to organise your your thoughts about the solution and not least to document it. Changes to the workflow are easily added once you have a generic state machine implementation.

The key features of a state machine are: (1) Define the states, these are "activities" (things that are to be done) in your workflow; (2) Define the allowed transitions (if in state "A" you can move to state "B", "C", .. "Z", and possibly also back to "A" etc); (3) Define the events that drive state transitions. In your case the completion of some work is probably an event, but perhaps an interruption such as cancellation of a task can occur which might trigger a transition into another state (such as Idle).

I don't think you should look on XML as something to adopt simply because it seems like a possibly-useful technology. Yes, XML may have a role to play, but you need to work through your design first and let the technologies used stem from that, rather than designing something with a prior assumption that you should be using this or that technique.

I've posted this as a solution which is probably a bit optimistic, however, realistically speaking I don't think your question can be answered in any more concrete terms. Good luck with it - sounds like a fun project!


这篇关于使用HTML / CSS / JS创建工作流生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆