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

Export selected rows from button action #4824

Merged
merged 3 commits into from
Mar 8, 2022

Conversation

PClmnt
Copy link
Collaborator

@PClmnt PClmnt commented Mar 7, 2022

Description

Previously users had no way to export data from their application.

This PR allows the user to create a button action, select a table that they would to export rows from and export those rows when their created button is clicked.

This works for both internal and external tables.

n.b I had to slightly modify the row selection store and client table component to store the Table ID, for use in the exportRows API call. The table ID is needed for output processing etc. I've therefore updated dataBinding.js to take account of this, it still will only output the selected row IDs
image

image

@@ -42,6 +42,7 @@
$: {
rowSelectionStore.actions.updateSelection(
$component.id,
selectedRows.length ? selectedRows[0].tableId : "",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Setting the table id here, this seems to be fine because the store gets reset when the data provider above it gets changed. Still unsure of why this is the case, but it does.

@codecov-commenter
Copy link

Codecov Report

Merging #4824 (ea63b9b) into develop (86f649c) will decrease coverage by 0.27%.
The diff coverage is 12.50%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4824      +/-   ##
===========================================
- Coverage    69.51%   69.23%   -0.28%     
===========================================
  Files          145      145              
  Lines         4979     5003      +24     
  Branches       765      766       +1     
===========================================
+ Hits          3461     3464       +3     
- Misses        1066     1086      +20     
- Partials       452      453       +1     
Impacted Files Coverage Δ
packages/server/src/api/routes/row.js 100.00% <ø> (ø)
...ackages/server/src/api/controllers/row/external.js 15.68% <9.09%> (-0.80%) ⬇️
...ackages/server/src/api/controllers/row/internal.js 79.31% <12.50%> (-2.75%) ⬇️
packages/server/src/api/controllers/row/index.js 77.77% <20.00%> (-3.40%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e159e4a...ea63b9b. Read the comment docs.

@joebudi
Copy link
Contributor

joebudi commented Mar 7, 2022

@PClmnt this is awesome and critical for business users when building reports

Copy link
Member

@shogunpurple shogunpurple left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work 🚀 Also really cool the way you can do this directly through the budibase API now.

@shogunpurple shogunpurple merged commit 62b9983 into develop Mar 8, 2022
@shogunpurple shogunpurple deleted the feature/export-from-client branch March 8, 2022 11:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2022
Copy link
Member

@aptkingston aptkingston left a comment

Choose a reason for hiding this comment

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

Nice one Peter! This looks good and will be really useful 👍

The only issue I can see is around configuring the action. By fetching selected rows by table ID, having 2 table components referencing the same table will now overwrite each other. I think it's also a bit confusing that this isn't linked to the table components (where you actually do the row selection).

I would suggest:

  • Update the button action so that you select a table component, not a backend table
  • Don't store tableId in the selection store, just fetch the selected rows by table component ID
  • When executing the action. determine the tableId by looking at the selected rows
  • Update the button action to be more clear that it's linked to table components, and not just a generic data export action

runtimeBinding: `${safeState}.${makePropSafe(table._id)}`,
runtimeBinding: `${safeState}.${makePropSafe(table._id)}.${makePropSafe(
"selectedRows"
)}`,
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change for existing apps but we haven't released the row selection feature yet so this should be fine. More of just an FYI for the future!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants