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

use batchSelection option in datatable #9

Open
JenniferCavaccuiti opened this issue Feb 20, 2024 · 1 comment
Open

use batchSelection option in datatable #9

JenniferCavaccuiti opened this issue Feb 20, 2024 · 1 comment

Comments

@JenniferCavaccuiti
Copy link

JenniferCavaccuiti commented Feb 20, 2024

Hello,

I need to add batchSelection option in the datable to have checkboxes on rows and headers.

I made you a pull request.

Is it the right way to do it ?

Thank you

@Pierstoval
Copy link
Member

For now, it's not supported.

An option must be added to the List action to allow configuring a batch selection system.

I see it like this:

  • An option batchActions in the List actions options
  • This option contains at least these properties:
    • enabled: boolean
    • actions: Array<{label: string, name: string}>, to determine all possible batch actions
  • In CrudList.svelte:
    • If operation.options.batchActions.enabled, inject actions in the data table like this: <DataTable /* ... */ batchActions={operation.options.batchActions.actions} /* ... */ >
  • In DataTable.svelte:
    • Create a new export let batchActions = Array<{label: string, name: string}> = []; prop
    • Inject in Carbon's DataTable the batchSelection={batchActions.length > 0} attribute
    • At this point, you have to follow the use of and component by Carbon in the following documentation example: https://carbon-components-svelte.onrender.com/components/DataTable#batch-selection-with-batch-actions-toolbar
    • The toolbar must be connected to whether items were selected
    • A list of action buttons must be displayed depending on the batchActions var / dashboard property, so that when you click on them, the link is called.
    • When the link is called, dispatch a new event named batchActionCall for which event data will directly be the rows that are selected.
  • Then after that, in CrudList.svelte:
    • You add an on:batchActionCall={onBatchActionCall} attribute to your DataTable instantiation, and call your state processor, for which the data being the list of objects you just called. This will allow you to configure API calls for you batch actions on your state processor.

I'm still not 100% sure about the {label: string, name: string} type for the actions. Maybe we should create a plain NamedAction extends DefaultAction class with a constructor like constructor(label: string, name: string, icon?: ActionIcon, options?: ActionOptions), in order to have a type like actions: Array<NamedAction> in List's options , so that the name property will be used to properly name your StateProcessor's call in CrudList.svelte.

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

No branches or pull requests

2 participants