@appscode/ui-builder
Version:
## Motivation
45 lines (40 loc) • 1.15 kB
JavaScript
import { mapGetters } from "vuex";
import { getValue } from "@/plugins/json-ref-resolver";
export default {
props: {
contextObject: {
type: Object,
default: () => ({}),
},
},
computed: {
...mapGetters({
functions: "wizard/functions",
}),
},
methods: {
async performFuncCall(funcName, itemCtx) {
// split to separate function name and parameters
try {
const split = funcName.split("|");
const functionName = split.shift();
const parameters = [...split];
const func = getValue(this.functions, functionName);
// execute the function mentioned in ui json, if not declared in functions js file, then throw error
if (func === undefined)
throw new Error(
`function "${functionName}" not declared in your functions.js file`
);
else {
const resp = await func(
{ ...this.contextObject, itemCtx }, // pass item context along with the normal context
...parameters
);
return resp;
}
} catch (e) {
console.log(e);
}
},
},
};