isShow: function()

in src/framework/MUtil.tsx [286:303]


  isShow: function (database: any, objectFields: MFieldSchema[], showIfExpr: string) {
    if (!showIfExpr) return true
    let l1fields = _.uniq(
      objectFields
        .filter(e => !!e.name)
        .map(e => _.first(e.name.split(".")))
    );
    let showIfScript = `let {${l1fields.join(",")}} = data || {};\n return ${showIfExpr}`;
    try {
      const fn = Object.keys(SchemaFunc)
      const fv = Object.values(SchemaFunc)
      let res = new Function("_", "data", ...fn, showIfScript)(_, database, ...fv);
      return res;
    } catch (e) {
      console.error("Calc isShow failed: " + e.message, "function(_,data){" + showIfScript + "}", database);
      return true;
    }
  },