createTableStoreModule
This module contains the necessary tools for organizing data in a table view.
It includes:
createTableStoreModuleuseTableStore
For integration with other store modules (like API, Card, Filters, Store Modules) see how-to page docs.
createTableStoreModule
Vuex store module which contains all necessary logic for working with tables. API Store Module child is required for it to work properly.
State
It contains all required state to power a table view:
dataList- list of data items from the APIheaders- list of table headersselected- list of selected items from dataList (preserves original items references)error- error response object if error during dataList fetching was occuredisLoading- boolean flag to indicatedataListloading stateisNextPage- boolean flag to indicate if there is more data to load
Getters
PARENT_ID- if table is nested, should be overriden.REQUIRED_FIELDS- list of fields, which should always be included inFIELDSgetter.['id']by defaultFIELDS- list of fields to get from API, depending on visibleheaderscolumns andREQUIRED_FIELDSGET_LIST_PARAMS: accepts override object and returns all request filters as params with overrides priority
Actions
See source code
Mutations
See source code
useTableStore
Receives
namespace- Vuex module namespace, without/tablesuffix
Returns
Properties
tableNamespace- Vuex table module namespace
for others, see store/state
dataListselectedisLoadingheadersisNexterror
Methods
see store/actions
loadDataonFilterEventpatchPropertydeleteDatasortsetSelected
Details and design considerations
Filters-related actions inside TableStoreModule
Filters-related actions should be separated from Table Module, because Filters are not required for the module to work properly.
However, it would be great to have them injected in table store, because they are used together inside one table namespace.
So, I've not came up with a better decision than just to left them inside TableStoreModule.