feat: option to hide a column in frontend when defining a Table Input, hides Tool identifier from table display (#6222)
* added changes to hide fields from table input * [autofix.ci] apply automated fixes --------- Co-authored-by: anovazzi1 <otavio2204@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
e1e9d7baef
commit
d1402b888f
5 changed files with 65 additions and 52 deletions
|
|
@ -12,6 +12,7 @@ TOOL_TABLE_SCHEMA = [
|
||||||
"sortable": False,
|
"sortable": False,
|
||||||
"filterable": False,
|
"filterable": False,
|
||||||
"edit_mode": EditMode.INLINE,
|
"edit_mode": EditMode.INLINE,
|
||||||
|
"hidden": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "description",
|
"name": "description",
|
||||||
|
|
@ -21,6 +22,7 @@ TOOL_TABLE_SCHEMA = [
|
||||||
"sortable": False,
|
"sortable": False,
|
||||||
"filterable": False,
|
"filterable": False,
|
||||||
"edit_mode": EditMode.POPOVER,
|
"edit_mode": EditMode.POPOVER,
|
||||||
|
"hidden": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tags",
|
"name": "tags",
|
||||||
|
|
@ -31,6 +33,7 @@ TOOL_TABLE_SCHEMA = [
|
||||||
"sortable": False,
|
"sortable": False,
|
||||||
"filterable": False,
|
"filterable": False,
|
||||||
"edit_mode": EditMode.INLINE,
|
"edit_mode": EditMode.INLINE,
|
||||||
|
"hidden": True,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class Column(BaseModel):
|
||||||
default: str | None = None
|
default: str | None = None
|
||||||
disable_edit: bool = Field(default=False)
|
disable_edit: bool = Field(default=False)
|
||||||
edit_mode: EditMode | None = Field(default=EditMode.MODAL)
|
edit_mode: EditMode | None = Field(default=EditMode.MODAL)
|
||||||
|
hidden: bool = Field(default=False)
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def set_display_name(self):
|
def set_display_name(self):
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,15 @@ const TableComponent = forwardRef<
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
let colDef = props.columnDefs.map((col, index) => {
|
let colDef = props.columnDefs
|
||||||
|
.map((col, index) => {
|
||||||
let newCol = {
|
let newCol = {
|
||||||
...col,
|
...col,
|
||||||
};
|
};
|
||||||
|
// Filter out hidden columns
|
||||||
|
if (col.hidden) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (props.rowSelection && props.onSelectionChanged && index === 0) {
|
if (props.rowSelection && props.onSelectionChanged && index === 0) {
|
||||||
newCol = {
|
newCol = {
|
||||||
...newCol,
|
...newCol,
|
||||||
|
|
@ -107,7 +112,8 @@ const TableComponent = forwardRef<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newCol;
|
return newCol;
|
||||||
});
|
})
|
||||||
|
.filter(Boolean); // Filter out null values from hidden columns
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const realRef: React.MutableRefObject<AgGridReact> =
|
const realRef: React.MutableRefObject<AgGridReact> =
|
||||||
useRef<AgGridReact | null>(null);
|
useRef<AgGridReact | null>(null);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ export interface ColumnField {
|
||||||
formatter?: FormatterType;
|
formatter?: FormatterType;
|
||||||
description?: string;
|
description?: string;
|
||||||
disable_edit?: boolean;
|
disable_edit?: boolean;
|
||||||
default?: any; // Add this line
|
default?: any;
|
||||||
edit_mode?: "modal" | "inline" | "popover";
|
edit_mode?: "modal" | "inline" | "popover";
|
||||||
|
hidden?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -524,7 +524,7 @@ export function brokenEdgeMessage({
|
||||||
export function FormatColumns(columns: ColumnField[]): ColDef<any>[] {
|
export function FormatColumns(columns: ColumnField[]): ColDef<any>[] {
|
||||||
if (!columns) return [];
|
if (!columns) return [];
|
||||||
const basic_types = new Set(["date", "number"]);
|
const basic_types = new Set(["date", "number"]);
|
||||||
const colDefs = columns.map((col, index) => {
|
const colDefs = columns.map((col) => {
|
||||||
let newCol: ColDef = {
|
let newCol: ColDef = {
|
||||||
headerName: col.display_name,
|
headerName: col.display_name,
|
||||||
field: col.name,
|
field: col.name,
|
||||||
|
|
@ -532,6 +532,7 @@ export function FormatColumns(columns: ColumnField[]): ColDef<any>[] {
|
||||||
filter: col.filterable,
|
filter: col.filterable,
|
||||||
context: col.description ? { info: col.description } : {},
|
context: col.description ? { info: col.description } : {},
|
||||||
cellClass: col.disable_edit ? "cell-disable-edit" : "",
|
cellClass: col.disable_edit ? "cell-disable-edit" : "",
|
||||||
|
hide: col.hidden,
|
||||||
valueParser: (params: ValueParserParams) => {
|
valueParser: (params: ValueParserParams) => {
|
||||||
const { context, newValue, colDef, oldValue } = params;
|
const { context, newValue, colDef, oldValue } = params;
|
||||||
if (
|
if (
|
||||||
|
|
@ -595,6 +596,7 @@ export function generateBackendColumnsFromValue(
|
||||||
sortable: !tableOptions?.block_sort,
|
sortable: !tableOptions?.block_sort,
|
||||||
filterable: !tableOptions?.block_filter,
|
filterable: !tableOptions?.block_filter,
|
||||||
default: null, // Initialize default to null or appropriate value
|
default: null, // Initialize default to null or appropriate value
|
||||||
|
hidden: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attempt to infer the default value from the data, if possible
|
// Attempt to infer the default value from the data, if possible
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue