mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
Ability to evaluate an object as payload (#5697)
This commit is contained in:
parent
5621dbbb05
commit
0186d11fe8
@ -198,7 +198,18 @@ export class ExtensionService {
|
|||||||
* @param context Parameter object for the expression with details of app state
|
* @param context Parameter object for the expression with details of app state
|
||||||
* @returns Result of evaluated expression, if found, or the literal value otherwise
|
* @returns Result of evaluated expression, if found, or the literal value otherwise
|
||||||
*/
|
*/
|
||||||
runExpression(value: string, context?: any) {
|
runExpression(value: string | {} , context?: any) {
|
||||||
|
if (typeof value === 'string' ) {
|
||||||
|
return this.evaluateExpression(value, context);
|
||||||
|
} else {
|
||||||
|
Object.keys(value).forEach( (key) => {
|
||||||
|
value[key] = this.evaluateExpression(value[key], context);
|
||||||
|
});
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private evaluateExpression(value: string, context?: any): string {
|
||||||
const pattern = new RegExp(/\$\((.*\)?)\)/g);
|
const pattern = new RegExp(/\$\((.*\)?)\)/g);
|
||||||
const matches = pattern.exec(value);
|
const matches = pattern.exec(value);
|
||||||
|
|
||||||
@ -209,7 +220,6 @@ export class ExtensionService {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user