Skip to content

Commit

Permalink
Add seams to enable new WDS data table features. (#4599)
Browse files Browse the repository at this point in the history
  • Loading branch information
jladieu authored Jan 22, 2024
1 parent f002a2f commit f8ebbe4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
5 changes: 5 additions & 0 deletions src/libs/ajax/data-table-providers/DataTableProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export interface DataTableFeatures {
supportsTsvAjaxDownload: boolean;
supportsTypeDeletion: boolean;
supportsTypeRenaming: boolean;
supportsEntityRenaming: boolean;
supportsEntityUpdating: boolean;
supportsAttributeRenaming: boolean;
supportsAttributeDeleting: boolean;
supportsAttributeClearing: boolean;
supportsExport: boolean;
supportsPointCorrection: boolean;
supportsFiltering: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export class EntityServiceDataTableProvider implements DataTableProvider {
supportsTsvAjaxDownload: false,
supportsTypeDeletion: true,
supportsTypeRenaming: true,
supportsEntityRenaming: true,
supportsEntityUpdating: true,
supportsAttributeRenaming: true,
supportsAttributeDeleting: true,
supportsAttributeClearing: true,
supportsExport: true,
supportsPointCorrection: true,
supportsFiltering: true,
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ajax/data-table-providers/WdsDataTableProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ export class WdsDataTableProvider implements DataTableProvider {
supportsTsvAjaxDownload: true,
supportsTypeDeletion: true,
supportsTypeRenaming: false,
supportsEntityRenaming: false,
supportsEntityUpdating: false, // TODO: enable as part of AJ-594
supportsAttributeRenaming: false, // TODO: enable as part of AJ-1278, requires `edit.renameAttribute` capability
supportsAttributeDeleting: false, // TODO: enable as part of AJ-1275, requires `edit.deleteAttribute` capability
supportsAttributeClearing: false,
supportsExport: false,
supportsPointCorrection: false,
supportsFiltering: false,
Expand Down
44 changes: 26 additions & 18 deletions src/workspace-data/data-table/shared/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ const DataTable = (props) => {
text: entityName,
}),
editable &&
dataProvider.features.supportsEntityRenaming &&
h(EditDataLink, {
'aria-label': `Rename ${entityType} ${entityName}`,
onClick: () => setRenamingEntity(entityName),
Expand Down Expand Up @@ -553,25 +554,31 @@ const DataTable = (props) => {
searchByColumn: (v) => searchByColumn(attributeName, v),
extraActions: _.concat(
editable
? [
// settimeout 0 is needed to delay opening the modaals until after the popup menu closes.
? _.compact([
// settimeout 0 is needed to delay opening the modals until after the popup menu closes.
// Without this, autofocus doesn't work in the modals.
{
label: 'Rename Column',
...actionProps,
onClick: () => setTimeout(() => setRenamingColumn(attributeName), 0),
},
{
label: 'Delete Column',
...actionProps,
onClick: () => setTimeout(() => setDeletingColumn(attributeName), 0),
},
{
label: 'Clear Column',
...actionProps,
onClick: () => setTimeout(() => setClearingColumn(attributeName), 0),
},
]
dataProvider.features.supportsAttributeRenaming
? {
label: 'Rename Column',
...actionProps,
onClick: () => setTimeout(() => setRenamingColumn(attributeName), 0),
}
: null,
dataProvider.features.supportsAttributeDeleting
? {
label: 'Delete Column',
...actionProps,
onClick: () => setTimeout(() => setDeletingColumn(attributeName), 0),
}
: null,
dataProvider.features.supportsAttributeClearing
? {
label: 'Clear Column',
...actionProps,
onClick: () => setTimeout(() => setClearingColumn(attributeName), 0),
}
: null,
])
: [],
extraColumnActions ? extraColumnActions(attributeName) : []
),
Expand Down Expand Up @@ -602,6 +609,7 @@ const DataTable = (props) => {
});
const editLink =
editable &&
dataProvider.features.supportsEntityUpdating &&
h(EditDataLink, {
'aria-label': `Edit attribute ${attributeName} of ${entityType} ${entityName}`,
'aria-haspopup': 'dialog',
Expand Down

0 comments on commit f8ebbe4

Please sign in to comment.