Skip to content

feat(tabular-modification): inline cell edit and row manipulation#3948

Open
flomillot wants to merge 6 commits into
mainfrom
florent/tabular-modification-inline-edit
Open

feat(tabular-modification): inline cell edit and row manipulation#3948
flomillot wants to merge 6 commits into
mainfrom
florent/tabular-modification-inline-edit

Conversation

@flomillot
Copy link
Copy Markdown
Contributor

@flomillot flomillot commented May 15, 2026

Summary

Until now, the tabular modification/creation dialog only supported read-only CSV import: any correction required editing the CSV outside the app and re-importing it. This PR adds inline cell editing and row deletion directly in the UI.

Key changes

  • CustomAGGrid (read-only) → CustomAgGridTable (commons-ui): inline editing, multi-row selection + deletion, row add, drag handle, move up/down.
  • The existing CSV flow is preserved as is (file picker, skeleton generation, local parsing). Parsed rows are injected into the grid via a ref to the shared component's internal useFieldArray — RHF forbids a second useFieldArray on the same name.
  • Typed cells: agSelectCellEditor for ENUM (values from field.options), NumericEditor for NUMBER, default text editor otherwise (including BOOLEAN). property_* columns are text-editable.
  • The EQUIPMENT_ID (pinned) column receives rowDrag: true — AG Grid's default drag handle, following the removal of rowDragEntireRow from commons-ui.
  • AG_GRID_ROW_UUID is injected per row at all three entry points: CSV parse (handleComplete), editing an existing modification (initTabularCreationData / initTabularModificationData). Required for the grid's getRowId to be stable.
  • Added the agGridBackground theme token (light + dark) consumed by CustomAgGridTable styles.
  • Removed the top-of-dialog ErrorInput (duplicate: BottomRightButtons already renders one under the grid).

Known limitations / follow-up

Typed validation (required, requiredIf, BOOLEAN/NUMBER/ENUM) is currently only re-executed on CSV parse. After inline edit / add / delete, the alert does not refresh and submit-side validation remains minimal (yup.array().min(1) only). Follow-up is planned.

Dependency

Requires gridsuite/commons-ui#1133 to be merged and released.

The tabular modification/creation dialog used to be fed exclusively by
a CSV import: rows were displayed read-only and any correction
required editing the CSV outside the app and re-importing it.

Replace the read-only CustomAGGrid by CustomAgGridTable, which brings
inline edit, multi-row selection + delete, add row, drag handle and
move up/down via its bottom-right buttons. The existing CSV import
flow on top of the dialog is preserved untouched; CSV-parsed rows are
loaded into the grid imperatively through a forwarded ref to the
internal useFieldArray.

Details:
- Inject AG_GRID_ROW_UUID on each row when loading from CSV
  (handleComplete) and when restoring an existing modification via
  editData (initTabularCreationData / initTabularModificationData).
  CustomAgGridTable uses this UUID for getRowId, so without it row
  tracking degenerates to "undefined === undefined", which silently
  collapses the field array.
- Make columns editable with the right cell editor per field type:
  agSelectCellEditor for BOOLEAN and ENUM, NumericEditor for NUMBER,
  default text editor otherwise. Properties columns are editable as
  text.
- Mark the pinned EQUIPMENT_ID column as the row drag handle
  (rowDrag: true), now that commons-ui no longer hardcodes
  rowDragEntireRow.
- Replace every setValue(MODIFICATIONS_TABLE, ...) by replace() via
  the table ref to keep the underlying useFieldArray in sync (a
  second useFieldArray on the same name is forbidden by RHF).
- Drop the top-of-dialog ErrorInput; BottomRightButtons already
  renders one right under the grid.
- Add the agGridBackground token to the gridstudy theme (light and
  dark) so CustomAgGridTable's styles can read theme.agGridBackground.color.

Requires commons-ui change forwarding useFieldArray via ref and
making row drag opt-in (gridsuite/commons-ui#1133).

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors the tabular network modifications grid from form-state-driven rendering to imperative ref-based updates. It adds UUID row identifiers during initialization, updates MUI theme styling for grid backgrounds, and switches grid rendering from CustomAGGrid to CustomAgGridTable with specialized column editors and ref-backed data updates.

Changes

Tabular Grid Refactoring

Layer / File(s) Summary
Theme styling and typing
src/module-mui.d.ts, src/components/app-wrapper.jsx
MUI theme extension adds agGridBackground color configuration; light theme sets it to white and dark theme to #383838.
UUID row initialization in TabularDialog
src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx
Imports reformatted; uuid4() values assigned to AG_GRID_ROW_UUID during both modification and creation initialization; dialog paper height set to 83vh.
TabularForm ref-based grid infrastructure and column configuration
src/components/dialogs/network-modifications/tabular/tabular-form.tsx
CustomAgGridTable integrated via ref; column definitions generated with field-type-specific editors (NumericEditor for NUMBER, ag select for ENUM); makeDefaultRowData initializes rows with UUIDs.
TabularForm grid data flows and rendering
src/components/dialogs/network-modifications/tabular/tabular-form.tsx
CSV parsing, file errors, equipment type changes, and property selection changes all use tableRef.replace() instead of form state updates; grid rendering switches to CustomAgGridTable; error alert moved to standalone conditional display.

Suggested reviewers

  • achour94
  • antoinebhs
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main enhancement: adding inline cell editing and row manipulation to tabular modifications, which is the core purpose of this PR.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, covering key changes, implementation details, typed cell editors, theme tokens, and known limitations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@flomillot flomillot changed the title feat(tabular-modification): inline cell edit and row deletion feat(tabular-modification): inline cell edit and row manipulation May 18, 2026
flomillot added 5 commits May 18, 2026 15:27
…olDef

DefaultCellRenderer was repeated for every typed branch (BOOLEAN,
NUMBER, ENUM, default). Move it once into defaultColDef and drop the
per-case assignments.

BOOLEAN now falls through to the default text editor instead of
agSelectCellEditor + BooleanNullableCellRenderer; remove the dead
cellEditorParams and the now-unused BooleanNullableCellRenderer
import.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
… selection props

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
…proved layout consistency

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx`:
- Line 121: The UI-only FieldConstants.AG_GRID_ROW_UUID is being added to row
objects for grid state but is leaking into API payloads; update the submission
path to strip this key before backend conversion by adding an explicit guard
that ignores FieldConstants.AG_GRID_ROW_UUID: either add a top-level filter in
convertCreationFieldFromFrontToBack to return undefined/skip when the field key
=== FieldConstants.AG_GRID_ROW_UUID, and/or add a pre-iteration filter in the
modification transformation strategy (the function that iterates row keys to
build modification payloads) so it never processes that key; ensure both
creation and modification flows (the code that calls
convertCreationFieldFromFrontToBack and the modification transformer) exclude
AG_GRID_ROW_UUID before assembling the final payload.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 755a86b8-0269-472d-87b8-7139176f1f44

📥 Commits

Reviewing files that changed from the base of the PR and between ed0662f and 8a0af7d.

📒 Files selected for processing (4)
  • src/components/app-wrapper.jsx
  • src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx
  • src/components/dialogs/network-modifications/tabular/tabular-form.tsx
  • src/module-mui.d.ts

}
}
modification = addPropertiesFromBack(modification, modif?.[TABULAR_PROPERTIES]);
modification[FieldConstants.AG_GRID_ROW_UUID] = uuid4();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C3 'AG_GRID_ROW_UUID|Object\.keys\(row\)|convertCreationFieldFromFrontToBack|transformModificationsTable' \
  src/components/dialogs/network-modifications/tabular

Repository: gridsuite/gridstudy-app

Length of output: 10301


🏁 Script executed:

cat -n src/components/dialogs/network-modifications/tabular/tabular-creation-utils.ts | sed -n '188,210p'

Repository: gridsuite/gridstudy-app

Length of output: 583


🏁 Script executed:

cat -n src/components/dialogs/network-modifications/tabular/tabular-modification-utils.ts | sed -n '486,510p'

Repository: gridsuite/gridstudy-app

Length of output: 463


🏁 Script executed:

rg -n -A30 'transformRowToBackEndModification' src/components/dialogs/network-modifications/tabular/tabular-modification-utils.ts | head -60

Repository: gridsuite/gridstudy-app

Length of output: 1455


🏁 Script executed:

rg -n 'AG_GRID_ROW_UUID' src/components/dialogs/network-modifications/tabular/tabular-modification-utils.ts

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

rg -n 'AG_GRID_ROW_UUID' src/components/dialogs/network-modifications/tabular/tabular-creation-utils.ts

Repository: gridsuite/gridstudy-app

Length of output: 49


Remove AG_GRID_ROW_UUID before submitting to backend.

Lines 121 and 139–140 add FieldConstants.AG_GRID_ROW_UUID to row objects for UI state tracking. However, this field propagates to the API payload:

  • Creation submissions (lines 195–197) iterate all row keys without filtering, passing each through convertCreationFieldFromFrontToBack, which has no guard for the UUID field.
  • Modification submissions (line 166) delegate to transformation strategies that iterate all keys (line 444) without filtering.

Add an explicit check in convertCreationFieldFromFrontToBack or in the modification transformation strategy to exclude FieldConstants.AG_GRID_ROW_UUID before the backend payload is assembled.

Also applies to: 137–140

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx` at
line 121, The UI-only FieldConstants.AG_GRID_ROW_UUID is being added to row
objects for grid state but is leaking into API payloads; update the submission
path to strip this key before backend conversion by adding an explicit guard
that ignores FieldConstants.AG_GRID_ROW_UUID: either add a top-level filter in
convertCreationFieldFromFrontToBack to return undefined/skip when the field key
=== FieldConstants.AG_GRID_ROW_UUID, and/or add a pre-iteration filter in the
modification transformation strategy (the function that iterates row keys to
build modification payloads) so it never processes that key; ensure both
creation and modification flows (the code that calls
convertCreationFieldFromFrontToBack and the modification transformer) exclude
AG_GRID_ROW_UUID before assembling the final payload.

Comment on lines +302 to +306
const rowsWithUuid = results.data.map((row) => ({
...row,
[FieldConstants.AG_GRID_ROW_UUID]: uuid4(),
}));
tableRef.current?.replace(rowsWithUuid);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Inline edits/additions bypass the only real validation path.

The grid is editable and can create new rows now, but the required/type checks still only run during CSV parsing. That means users can add blank rows or change a cell to an invalid value and still save because errors never refresh; conversely, fixing a CSV error inline can leave the form blocked. Please re-run row validation on grid mutations or validate the current table again in onSave.

Also applies to: 411-440, 444-453, 545-559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant