-
Notifications
You must be signed in to change notification settings - Fork 63
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
bug/pager - DISMISS_EDITOR, REMOVE_ROW, and ADD_NEW_ROW now set total correctly #133
Conversation
I think these changes look good 👍 Let's get the tests fixed; I think this is a good/sensible change. |
Codecov Report
@@ Coverage Diff @@
## master #133 +/- ##
==========================================
+ Coverage 81.34% 81.36% +0.01%
==========================================
Files 111 111
Lines 4492 4496 +4
==========================================
+ Hits 3654 3658 +4
Misses 838 838
Continue to review full report at Codecov.
|
I went ahead and moved the logic for updating the totals back to addNewRow and dismissEditor for the time being due to a conflict with the latest changes to allow for inserting a new row editor at any point in the grid |
0e3b22b
to
8d9ddd5
Compare
Changes look good. Sort of unrelated, how come we don't update the total in const updated = record.merge({
data: remainingRows,
proxy: remainingRows,
currentRecords: remainingRows,
lastUpdate: generateLastUpdate()
}); Should we add |
@@ -165,8 +162,8 @@ export const addNewRow = (state, { rowId, stateKey }) => { | |||
data: newData, | |||
proxy: data, | |||
isEditing: true, | |||
lastUpdate: generateLastUpdate(), | |||
total: newData.size | |||
total: existingState.get('total') + 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to be a little bit more defensive here sadly. I would add a check to make sure existingState has been initialized, otherwise this will throw
11a8eb2
to
759a14c
Compare
Thanks for the feedback! I updated the removeRow actionHandler to decrement the total and fixed the tests to handle this change. I had previously missed this because we do a setData after removing rows but I could see where this may not be wanted/needed plus it makes the actionHandlers behave consistently. Deleting rows on the demo grid now gives you instant feedback that the number of currently displayed rows and total have changed without requiring setData/refresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks great, two tiny things!
const remainingRows = state | ||
.getIn([stateKey, 'data']) | ||
.remove(rowIndex || 0, 1); | ||
|
||
const record = state.get(stateKey); | ||
|
||
const updatedTotal = existingState | ||
&& existingState.get('total') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run npm run lint
and see if you get any errors
const updated = record.merge({ | ||
data: remainingRows, | ||
proxy: remainingRows, | ||
currentRecords: remainingRows, | ||
total: updatedTotal - 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nit, but if total resolved to 0, then we're setting the total to -1
which probably isn't best.
759a14c
to
f874133
Compare
fixed total on removeRow
f874133
to
e1dc52a
Compare
Fix for bug #132.
Feedback Requested: I moved the logic for updating total from addNewRows and dismissEditor to saveRow so the grid totals update on save. I can see arguments for either.
Note: tests are currently failing due to moving the logic, will update after getting feedback