mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:29:16 +00:00
feat(plugin-workflow-form): add role name to form trigger context (#3182)
* feat(plugin-workflow-form): add role name to form trigger context * refactor(plugin-workflow-dynamic-calculation): move to extended group
This commit is contained in:
parent
5c74cb6361
commit
58f1918e73
@ -36,7 +36,7 @@ function DynamicExpression({ value, onChange }) {
|
||||
export default class extends Instruction {
|
||||
title = `{{t("Dynamic Calculation", { ns: "${NAMESPACE}" })}}`;
|
||||
type = 'dynamic-calculation';
|
||||
group = 'control';
|
||||
group = 'extended';
|
||||
description = `{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "${NAMESPACE}" })}}`;
|
||||
fieldset = {
|
||||
expression: {
|
||||
|
@ -70,6 +70,8 @@ export default class extends Trigger {
|
||||
const langTriggerData = useLang('Trigger data');
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const langUserSubmittedForm = useLang('User submitted form');
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const langRoleSubmittedForm = useLang('Role of user submitted form');
|
||||
const rootFields = [
|
||||
{
|
||||
collectionName: config.collection,
|
||||
@ -89,6 +91,12 @@ export default class extends Trigger {
|
||||
title: langUserSubmittedForm,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'roleName',
|
||||
uiSchema: {
|
||||
title: langRoleSubmittedForm,
|
||||
},
|
||||
},
|
||||
];
|
||||
const result = getCollectionFieldOptions({
|
||||
// depth,
|
||||
|
@ -4,5 +4,6 @@
|
||||
"Form data model": "Form data model",
|
||||
"Use a collection to match form data.": "Use a collection to match form data.",
|
||||
"Associations to use": "Associations to use",
|
||||
"User submitted form": "User submitted form"
|
||||
"User submitted form": "User submitted form",
|
||||
"Role of user submitted form": "Role of user submitted form"
|
||||
}
|
||||
|
@ -4,5 +4,6 @@
|
||||
"Form data model": "表单数据模型",
|
||||
"Use a collection to match form data.": "使用一个数据表来匹配表单数据。",
|
||||
"Associations to use": "待使用的关系数据",
|
||||
"User submitted form": "提交表单的用户"
|
||||
"User submitted form": "提交表单的用户",
|
||||
"Role of user submitted form": "提交表单用户的角色"
|
||||
}
|
||||
|
@ -51,7 +51,11 @@ export default class extends Trigger {
|
||||
private async trigger(context) {
|
||||
const { triggerWorkflows = '', values } = context.action.params;
|
||||
|
||||
const { currentUser } = context.state;
|
||||
const { currentUser, currentRole } = context.state;
|
||||
const userInfo = {
|
||||
user: toJSON(currentUser),
|
||||
roleName: currentRole,
|
||||
};
|
||||
|
||||
const triggers = triggerWorkflows.split(',').map((trigger) => trigger.split('!'));
|
||||
const workflowRepo = this.plugin.db.getRepository('workflows');
|
||||
@ -91,13 +95,13 @@ export default class extends Trigger {
|
||||
appends,
|
||||
});
|
||||
}
|
||||
this.plugin.trigger(workflow, { data: toJSON(payload), user: toJSON(currentUser) });
|
||||
this.plugin.trigger(workflow, { data: toJSON(payload), ...userInfo });
|
||||
});
|
||||
} else {
|
||||
const data = trigger[1] ? get(values, trigger[1]) : values;
|
||||
this.plugin.trigger(workflow, {
|
||||
data,
|
||||
user: currentUser,
|
||||
...userInfo,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user