fix: "Delete Selected Rows" bug for tables with no key columns#1996
fix: "Delete Selected Rows" bug for tables with no key columns#1996AkshatJawne merged 9 commits intodeephaven:mainfrom
Conversation
If we know it can never be shown for a given table it should be hidden rather than disabled. Only disable it if there's a condition in which it could be come enabled. |
Will make this change right now |
|
Will look into e2e tests failing |
| model.isEditable && | ||
| selectedRanges.length > 0 | ||
| selectedRanges.length > 0 && | ||
| model.isDeletableRanges(selectedRanges) |
There was a problem hiding this comment.
From Don's comment:
If we know it can never be shown for a given table it should be hidden rather than disabled. Only disable it if there's a condition in which it could be come enabled.
In this case you're just hiding it if the selected range isn't deletable, which if you have a totals row visible isn't quite correct - in that case, we should be showing the menu item, just disabled (since you can delete some rows, just not the totals rows). Other tables where you can't delete anything is where it shouldn't be shown at all.
So there's a few different types of tables we should be testing here (input_table docs here):
from deephaven import agg, empty_table, input_table
# Immutable table - should not show Delete Selected Rows, should not be editable
immutable_table = empty_table(10).update(["X = i", "Y=Math.sin(i)"])
# Append only table - should be able to add new rows, Delete Selected Rows should not be visible
append_only_table = input_table(init_table=source)
# Keyed row table - should be able to add new rows, Delete Selected Rows should be visible
keyed_table = input_table(init_table=source, key_cols=["X"])Then, after making the keyed_table, you should be able to go to the table menu, hit Aggregate Columns, and add an aggregation (such as Sum). (BUG NOTE: Looks like you'll need to position it at the "Top" or you can't see the totals - should log that as a separate issue). Right clicking a keyed row should show "Delete Selected Rows" and enabled, but right-clicking the totals row should just show "Delete Selected Rows" and have it disabled.
I think to achieve all that we'll change up the design a little bit... it will be a bit more complicated, but it will be a cleaner design.
- Add a
DeletableGridModel.tsnext toEditableGridModel.ts, and define an interface for a grid model that is deletable (e.g. anisDeletable: boolean;property, andisDeletableRangeandisDeletableRangesmethods). Also create the type predicates (isDeletableGridModelandassertIsDeletableGridModel. SeeisEditableGridModelandassertIsEditableGridModelinEditableGridModelfor examples). - Have
IrisGridProxyModelimplementDeletableGridModel, and delegate to it's underlying model if the underlying model isDeletableGridModel(much like theEditableGridModelmethods work inIrisGridProxyModel) - Have
IrisGridTableModelTemplateimplement theDeletableGridModel.- No need to change the other models, since they won't implement
DeletableGridModel.
- No need to change the other models, since they won't implement
- Check
isDeleteablefor adding the menu, then disable with!isDeletableRange
Let me know if you have questions. Making this a little more complicated, but now it will be more robust.
There was a problem hiding this comment.
Also update your PR description after updating the content.
|
Merging now! |
Resolves #1868
Changes: