Skip to content

Commit

Permalink
Merge pull request #391 from webitel/fix/add-reset-state-in-table-sto…
Browse files Browse the repository at this point in the history
…re-module

fix: add resetState in tableStoreModule[WTEL-5711](https://webitel.at…
  • Loading branch information
Lera24 authored Dec 13, 2024
2 parents 866e50c + 143d6e6 commit 56ccd99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.12.21",
"version": "24.12.22",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
13 changes: 13 additions & 0 deletions src/store/new/modules/tableStoreModule/tableStoreModule.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deepCopy from 'deep-copy';
import FilterEvent from '../../../../modules/Filters/enums/FilterEvent.enum.js';
import {
queryToSortAdapter,
Expand All @@ -11,6 +12,7 @@ const state = () => ({
error: {},
isLoading: false,
isNextPage: false,
_resettable: {},
});

const getters = {
Expand Down Expand Up @@ -234,10 +236,21 @@ const actions = {
context,
payload,
) => context.dispatch('api/DELETE_ITEM', payload),

RESET_TABLE_STATE: async (context) => {
context.commit('RESET_TABLE_STATE');
},
};

const mutations = {
RESET_TABLE_STATE: (state) => {
Object.assign(state, deepCopy(state._resettable));
},
};

export default () => ({
state: state(),
getters,
actions,
mutations,
});
5 changes: 5 additions & 0 deletions src/store/new/modules/tableStoreModule/useTableStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export const useTableStore = (namespace) => {
return store.dispatch(`${tableNamespace}/SET_SELECTED`, payload);
}

function resetState(payload) {
return store.dispatch(`${tableNamespace}/RESET_TABLE_STATE`, payload);
}

return {
namespace: tableNamespace,

Expand All @@ -62,5 +66,6 @@ export const useTableStore = (namespace) => {
deleteData,
sort,
setSelected,
resetState,
};
};

0 comments on commit 56ccd99

Please sign in to comment.