Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table edit default behavior #1530

Merged
merged 21 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
705 changes: 442 additions & 263 deletions frontend/taipy-gui/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/taipy-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.3",
"react-helmet-async": "^2.0.1",
"react-jsx-parser": "^1.28.4",
"react-jsx-parser": "^1.29.0",
"react-markdown": "^9.0.1",
"react-plotly.js": "^2.5.1",
"react-router-dom": "^6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions frontend/taipy-gui/src/components/Taipy/AutoLoadingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const AutoLoadingTable = (props: TaipyTableProps) => {

const className = useClassNames(props.libClassName, props.dynamicClassName, props.className);
const active = useDynamicProperty(props.active, props.defaultActive, true);
const editable = useDynamicProperty(props.editable, props.defaultEditable, true);
const editable = useDynamicProperty(props.editable, props.defaultEditable, false);
const hover = useDynamicProperty(props.hoverText, props.defaultHoverText, undefined);
const baseColumns = useDynamicJsonProperty(props.columns, props.defaultColumns, defaultColumns);

Expand Down Expand Up @@ -292,7 +292,7 @@ const AutoLoadingTable = (props: TaipyTableProps) => {
}
});
addDeleteColumn(
(active && (onAdd || onDelete) ? 1 : 0) +
(active && editable && (onAdd || onDelete) ? 1 : 0) +
(active && filter ? 1 : 0) +
(active && downloadable ? 1 : 0),
baseColumns
Expand Down
11 changes: 7 additions & 4 deletions frontend/taipy-gui/src/components/Taipy/PaginatedTable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ describe("PaginatedTable Component", () => {
const state: TaipyState = INITIAL_STATE;
const { getAllByTestId, queryAllByTestId, rerender } = render(
<TaipyContext.Provider value={{ state, dispatch }}>
<PaginatedTable data={undefined} defaultColumns={editableColumns} onEdit="onEdit" showAll={true} />
<PaginatedTable data={undefined} defaultColumns={editableColumns} editable={true} onEdit="onEdit" showAll={true} />
</TaipyContext.Provider>
);

Expand All @@ -384,6 +384,7 @@ describe("PaginatedTable Component", () => {
<PaginatedTable
data={editableValue as TableValueType}
defaultColumns={editableColumns}
editable={true}
onEdit="onEdit"
showAll={true}
/>
Expand All @@ -400,7 +401,7 @@ describe("PaginatedTable Component", () => {
const state: TaipyState = INITIAL_STATE;
const { getByTestId, queryAllByTestId, getAllByTestId, rerender } = render(
<TaipyContext.Provider value={{ state, dispatch }}>
<PaginatedTable data={undefined} defaultColumns={editableColumns} onEdit="onEdit" showAll={true} />
<PaginatedTable data={undefined} defaultColumns={editableColumns} editable={true} onEdit="onEdit" showAll={true} />
</TaipyContext.Provider>
);

Expand All @@ -409,6 +410,7 @@ describe("PaginatedTable Component", () => {
<PaginatedTable
data={editableValue as TableValueType}
defaultColumns={editableColumns}
editable={true}
onEdit="onEdit"
showAll={true}
/>
Expand Down Expand Up @@ -497,7 +499,7 @@ describe("PaginatedTable Component", () => {
const state: TaipyState = INITIAL_STATE;
const { getByTestId } = render(
<TaipyContext.Provider value={{ state, dispatch }}>
<PaginatedTable data={undefined} defaultColumns={editableColumns} showAll={true} onAdd="onAdd" />
<PaginatedTable data={undefined} defaultColumns={editableColumns} showAll={true} editable={true} onAdd="onAdd" />
</TaipyContext.Provider>
);

Expand All @@ -519,7 +521,7 @@ describe("PaginatedTable Component", () => {
const state: TaipyState = INITIAL_STATE;
const { getAllByTestId, getByTestId, queryAllByTestId, rerender } = render(
<TaipyContext.Provider value={{ state, dispatch }}>
<PaginatedTable data={undefined} defaultColumns={editableColumns} showAll={true} onDelete="onDelete" />
<PaginatedTable data={undefined} defaultColumns={editableColumns} showAll={true} editable={true} onDelete="onDelete" />
</TaipyContext.Provider>
);

Expand All @@ -528,6 +530,7 @@ describe("PaginatedTable Component", () => {
<PaginatedTable
data={editableValue as TableValueType}
defaultColumns={editableColumns}
editable={true}
showAll={true}
onDelete="onDelete"
/>
Expand Down
4 changes: 2 additions & 2 deletions frontend/taipy-gui/src/components/Taipy/PaginatedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
const refresh = typeof props.data === "number";
const className = useClassNames(props.libClassName, props.dynamicClassName, props.className);
const active = useDynamicProperty(props.active, props.defaultActive, true);
const editable = useDynamicProperty(props.editable, props.defaultEditable, true);
const editable = useDynamicProperty(props.editable, props.defaultEditable, false);
const hover = useDynamicProperty(props.hoverText, props.defaultHoverText, undefined);
const baseColumns = useDynamicJsonProperty(props.columns, props.defaultColumns, defaultColumns);

Expand All @@ -149,7 +149,7 @@ const PaginatedTable = (props: TaipyPaginatedTableProps) => {
}
});
addDeleteColumn(
(active && (onAdd || onDelete) ? 1 : 0) +
(active && editable && (onAdd || onDelete) ? 1 : 0) +
(active && filter ? 1 : 0) +
(active && downloadable ? 1 : 0),
baseColumns
Expand Down
Loading
Loading