feat(plugin-workflow): add array mapping support in processor (#1662)
This commit is contained in:
parent
3ec8b2d45f
commit
0d0c5ff9e0
@ -6,7 +6,7 @@ import formulajs from "../utils/formulajs";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
export { Evaluator } from '../utils';
|
export { Evaluator, evaluate, appendArrayColumn } from '../utils';
|
||||||
|
|
||||||
export const evaluators = new Registry<Evaluator>();
|
export const evaluators = new Registry<Evaluator>();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ export type Scope = { [key: string]: any };
|
|||||||
|
|
||||||
export type Evaluator = (expression: string, scope?: Scope) => any;
|
export type Evaluator = (expression: string, scope?: Scope) => any;
|
||||||
|
|
||||||
function appendArrayColumn(scope, key) {
|
export function appendArrayColumn(scope, key) {
|
||||||
const paths = key.split('.');
|
const paths = key.split('.');
|
||||||
let data = scope;
|
let data = scope;
|
||||||
for (let p = 0; p < paths.length && data != null; p++) {
|
for (let p = 0; p < paths.length && data != null; p++) {
|
||||||
|
@ -2,6 +2,7 @@ import { Transaction, Transactionable } from 'sequelize';
|
|||||||
import parse from 'json-templates';
|
import parse from 'json-templates';
|
||||||
|
|
||||||
import { Model } from "@nocobase/database";
|
import { Model } from "@nocobase/database";
|
||||||
|
import { appendArrayColumn } from '@nocobase/evaluators';
|
||||||
|
|
||||||
import Plugin from '.';
|
import Plugin from '.';
|
||||||
import ExecutionModel from './models/Execution';
|
import ExecutionModel from './models/Execution';
|
||||||
@ -296,6 +297,11 @@ export default class Processor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getParsedValue(value, node?) {
|
public getParsedValue(value, node?) {
|
||||||
return parse(value)(this.getScope(node));
|
const template = parse(value);
|
||||||
|
const scope = this.getScope(node);
|
||||||
|
template.parameters.forEach(({ key }) => {
|
||||||
|
appendArrayColumn(scope, key);
|
||||||
|
});
|
||||||
|
return template(scope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user