Skip to content

Commit 3ae0581

Browse files
authored
Merge pull request #34 from easeq/master
Improvements
2 parents ba1c4ec + bb06425 commit 3ae0581

File tree

9 files changed

+20
-17
lines changed

9 files changed

+20
-17
lines changed

demo/src/schema/basic.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { MODIFY_DATA } from '../../../src/actions';
2+
import { MODIFY_DATA, REQUEST_DATA, IS_LOADING } from '../../../src/actions';
33

44
export default {
55
name: 'posts',
@@ -174,7 +174,13 @@ export default {
174174
visible: true,
175175
state: false,
176176
thunk: ( config ) => ( dispatch, getState ) => {
177-
console.log('toolbar button click', config);
177+
const tableState = getState()[config.reducerName][config.name];
178+
console.log('toolbar button click', config, tableState);
179+
config.action(REQUEST_DATA)();
180+
config.action(IS_LOADING)({ value: true });
181+
setTimeout(function() {
182+
config.action(IS_LOADING)({ value: false });
183+
}, 1000);
178184
}
179185
}, {
180186
type: 'resetFilters',

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@flipbyte/redux-datatable",
3-
"version": "0.5.3",
3+
"version": "0.5.4",
44
"description": "React-Redux data table",
55
"main": "lib/index.js",
66
"module": "es/index.js",

src/Renderer/Body/Date.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const Date = ({
2525
modified={ isModified }
2626
className={ isModified ? 'modified' : ''}
2727
value={ formatDate(value, 'Y-m-d') }
28+
autocomplete="off"
2829
/>
2930
</Row>
3031
)}

src/Renderer/Body/Text.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const Text = ({
2424
modified={ isModified }
2525
className={ isModified ? 'modified' : ''}
2626
value={ value }
27+
autocomplete="off"
2728
/>
2829
</Row>
2930
)}

src/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const SET_SELECTION = 'SET_SELECTION';
1212
export const CLEAR_FILTER = 'CLEAR_FILTER';
1313
export const DELETE_DATA = 'DELETE_DATA';
1414
export const MODIFY_DATA = 'MODIFY_DATA';
15+
export const IS_LOADING = 'IS_LOADING';
1516

1617
export const cancelRequest = createActionCreator(REQUEST_DATA_CANCEL);
1718
export const requestData = createActionCreator(REQUEST_DATA);

src/createTable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const renderTable = ({
241241
isEditing={ isEditing }
242242
origValue={ origValue }
243243
modifiedData={ modifiedData }
244-
isModified={ !!modifiedValue }
244+
isModified={ _.has(modifiedData, name) }
245245
modifiedValue={ modifiedValue }
246246
handleChange={(event) => {
247247
var newData = { ...modifiedData };

src/epics.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,21 @@ export const setParamsEpic = ( action$, state$ ) => action$.pipe(
3030

3131
return of(
3232
cancelRequest({ name }),
33-
requestData({
34-
name, routes, reducerName, entity, payload: { query: _.get(state$.value, [reducerName, name]).query }
35-
})
33+
requestData({ name, routes, reducerName, entity })
3634
);
3735
})
3836
);
3937

4038
export const fetchDataEpic = ( action$, state$, { api }) => action$.pipe(
4139
ofType(REQUEST_DATA),
4240
switchMap((action) => {
43-
const {
44-
meta: { name, routes, entity },
45-
payload
46-
} = action;
41+
const { name, routes, entity, reducerName } = action.meta;
42+
const query = _.get(state$.value, [reducerName, name]).query;
4743

4844
return api.get(routes.get.route, {
4945
params: {
5046
...routes.get.params,
51-
...payload.query
47+
...query
5248
}
5349
}).pipe(
5450
map((response) => {
@@ -93,10 +89,7 @@ export const deleteDataEpic = ( action$, state$, { api }) => action$.pipe(
9389
return of(
9490
createNotification({ type: NOTIFICATION_TYPE_SUCCESS, message: response.result }),
9591
cancelRequest({ name }),
96-
requestData({
97-
name, routes, reducerName, entity,
98-
payload: { query: _.get(state$.value, [reducerName, name]).query }
99-
})
92+
requestData({ name, routes, reducerName, entity })
10093
);
10194
}),
10295
catchError((error) => of(

src/reducer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default function reducer(state = {}, action) {
5050
const tableState = getTableState(name)(state);
5151
const stateUpdater = updateState(state, name);
5252
const acceptedActions = {
53+
[actions.IS_LOADING]: () => stateUpdater({ isFetching: !!payload.value }),
5354
[actions.REQUEST_DATA]: () => stateUpdater({ isFetching: true }),
5455
[actions.REQUEST_DATA_CANCEL]: () => stateUpdater({ isFetching: false }),
5556
[actions.RECEIVE_DATA]: () => stateUpdater({

0 commit comments

Comments
 (0)