Alfresco Activiti - 将特定字段设为只读 group/task
Alfresco Activiti - Make Field read only for specific group/task
我是 Alfresco 的新手,我创建了一个包含任务和用户组的工作流。
现在我想知道是否有办法通过一些只读字段向不同的用户组显示相同的表单。
有很多关于如何用代码做到这一点的答案,我只是想知道是否有办法在 UI 级别(来自应用程序)
不写代码是做不到的,但是我可以分享我的建议,让一些专家也分享他们的观点。
我看到了,有2个选项。
- 编写自定义控件并应用您的逻辑(仅共享方面的更改,回购方面的更改可能较少[根据您的业务逻辑])。
- 创建多个工作流表单并在运行时应用您的逻辑并动态显示表单。
选项 1:
可以参考tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\form\controls\textfield.ftl
中的textfield.ftl
在生成文本框时,Share 正在检查是否已禁用选项。如果是这样,它会添加 disabled="true"
属性。
<label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
<input id="${fieldHtmlId}" name="${field.name}" tabindex="0"
/* Other code lines are removed to make it simple to understand */
<#if field.disabled && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if> />
<@formLib.renderFieldHelp field=field />
您也可以应用类似的逻辑来实现您的案例,但您需要编写一些代码。
<label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
<input id="${fieldHtmlId}" name="${field.name}" tabindex="0"
/* Other code lines are removed to make it simple to understand */
/* We need to determine, how we will be bringing the condition over here */
<#if <YOUR_CONDITION> =="true")>disabled="true"</#if> />
<@formLib.renderFieldHelp field=field />
选项 2
共享配置更改。
<!-- Edit form With All controls enabled -->
<config evaluator="task-type" condition="example:Form1AllEnabled">
..
</config>
<!-- Edit form With specific controls disabled -->
<config evaluator="task-type" condition="example:Form1FewControlsDisabled">
..
</config>
工作流程(bpmn 文件)方面的变化
<userTask id="form1" name="User Update Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="${userUpdateTaskFormKey}">
</userTask>
您需要在执行级别创建委托并动态更新userUpdateTaskFormKey
变量。
@Override
public void execute(final DelegateExecution delegate) throws Exception
{
String userUpdateTaskFormKey = "example:Form1FewControlsDisabled"; //Keeping it default
String currentUserName = authenticationService.getCurrentUserName();
//Apply user business logic ....
if (user....your condition)
{
userUpdateTaskFormKey = "example:Form1AllEnabled";
}
}
我是 Alfresco 的新手,我创建了一个包含任务和用户组的工作流。 现在我想知道是否有办法通过一些只读字段向不同的用户组显示相同的表单。 有很多关于如何用代码做到这一点的答案,我只是想知道是否有办法在 UI 级别(来自应用程序)
不写代码是做不到的,但是我可以分享我的建议,让一些专家也分享他们的观点。
我看到了,有2个选项。
- 编写自定义控件并应用您的逻辑(仅共享方面的更改,回购方面的更改可能较少[根据您的业务逻辑])。
- 创建多个工作流表单并在运行时应用您的逻辑并动态显示表单。
选项 1:
可以参考tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\form\controls\textfield.ftl
中的textfield.ftl
在生成文本框时,Share 正在检查是否已禁用选项。如果是这样,它会添加 disabled="true"
属性。
<label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
<input id="${fieldHtmlId}" name="${field.name}" tabindex="0"
/* Other code lines are removed to make it simple to understand */
<#if field.disabled && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if> />
<@formLib.renderFieldHelp field=field />
您也可以应用类似的逻辑来实现您的案例,但您需要编写一些代码。
<label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
<input id="${fieldHtmlId}" name="${field.name}" tabindex="0"
/* Other code lines are removed to make it simple to understand */
/* We need to determine, how we will be bringing the condition over here */
<#if <YOUR_CONDITION> =="true")>disabled="true"</#if> />
<@formLib.renderFieldHelp field=field />
选项 2
共享配置更改。
<!-- Edit form With All controls enabled -->
<config evaluator="task-type" condition="example:Form1AllEnabled">
..
</config>
<!-- Edit form With specific controls disabled -->
<config evaluator="task-type" condition="example:Form1FewControlsDisabled">
..
</config>
工作流程(bpmn 文件)方面的变化
<userTask id="form1" name="User Update Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="${userUpdateTaskFormKey}">
</userTask>
您需要在执行级别创建委托并动态更新userUpdateTaskFormKey
变量。
@Override
public void execute(final DelegateExecution delegate) throws Exception
{
String userUpdateTaskFormKey = "example:Form1FewControlsDisabled"; //Keeping it default
String currentUserName = authenticationService.getCurrentUserName();
//Apply user business logic ....
if (user....your condition)
{
userUpdateTaskFormKey = "example:Form1AllEnabled";
}
}