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

bug/pager - DISMISS_EDITOR, REMOVE_ROW, and ADD_NEW_ROW now set total correctly #133

Merged
merged 1 commit into from
Mar 6, 2017

Conversation

Vanderslice
Copy link
Contributor

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

@bencripps
Copy link
Owner

I think these changes look good 👍

Let's get the tests fixed; I think this is a good/sensible change.

@codecov-io
Copy link

codecov-io commented Mar 3, 2017

Codecov Report

Merging #133 into master will increase coverage by 0.01%.
The diff coverage is 80%.

@@            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
Impacted Files Coverage Δ
src/reducers/actionHelpers/datasource.js 66.07% <80%> (+0.82%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ecf836...e1dc52a. Read the comment docs.

@Vanderslice
Copy link
Contributor Author

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

@Vanderslice Vanderslice changed the title [WIP] bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly Mar 3, 2017
@Vanderslice Vanderslice changed the title bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly [WIP] bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly Mar 3, 2017
@Vanderslice Vanderslice changed the title [WIP] bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly Mar 3, 2017
@bencripps
Copy link
Owner

Changes look good. Sort of unrelated, how come we don't update the total in removeRow like we do with addRow? Here's the snippet from the actionHandler for removeRow:

const updated = record.merge({
        data: remainingRows,
        proxy: remainingRows,
        currentRecords: remainingRows,
        lastUpdate: generateLastUpdate()
    });

Should we add total to this update?

@@ -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,
Copy link
Owner

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

@Vanderslice Vanderslice force-pushed the bug/pager-fixes branch 3 times, most recently from 11a8eb2 to 759a14c Compare March 6, 2017 10:56
@Vanderslice
Copy link
Contributor Author

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

@Vanderslice Vanderslice changed the title bug/pager - DISMISS_EDITOR and ADD_NEW_ROW now set total correctly bug/pager - DISMISS_EDITOR, REMOVE_ROW, and ADD_NEW_ROW now set total correctly Mar 6, 2017
Copy link
Owner

@bencripps bencripps left a 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')
Copy link
Owner

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,
Copy link
Owner

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.

@bencripps bencripps merged commit 01830cf into bencripps:master Mar 6, 2017
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

Successfully merging this pull request may close these issues.

3 participants