get_state_fields = async (table_id, viewname, { columns }) => {
  const table = Table.findOne(table_id);
  if (!table) return [];
  const table_fields = table.fields;
  //console.log(table_fields);
  let state_fields = [];
  state_fields.push({ name: "_fts", label: "Anywhere", input_type: "text" });
  (columns || []).forEach((column) => {
    if (column.type === "Field") {
      const tbl_fld = table_fields.find((f) => f.name == column.field_name);
      if (tbl_fld && !tbl_fld.primary_key) {
        const f = new Field(tbl_fld);
        f.required = false;
        if (column.header_label) f.label = column.header_label;
        state_fields.push(f);
      }
    }
  });
  return state_fields;
}
@param {string} table_id
@param {*} viewname
@param {object} opts
@param {object[]} opts.columns
@returns {function}