Skip to content

Added insert rows functionality #1291

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

Closed

Conversation

Subhajitdas298
Copy link
Contributor

Summary

Added convenience method to insert any rows in between existing rows.

Test plan

Added 3 new test cases for insert row.

@Subhajitdas298
Copy link
Contributor Author

Resolved conflict with latest master

Copy link
Member

@alubbe alubbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 quick comments - but the PR looks good!

@alubbe
Copy link
Member

alubbe commented Jun 2, 2020

We just did a group review - once those two points are addressed, this is good to go 👍

@Subhajitdas298
Copy link
Contributor Author

Added option to inherit style for addRow/s and insertRow/s without affecting existing implementations. Added test cases for same.
Please review.

@Subhajitdas298
Copy link
Contributor Author

@alubbe Please review the latest changes. Thanks

@Subhajitdas298
Copy link
Contributor Author

Subhajitdas298 commented Jun 4, 2020

@alubbe Please review my recent changes and provide latest review. Thank you


insertRows(pos, values, styleOption = 'n') {
this.spliceRows(pos, 0, ...values);
if (styleOption !== 'n') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Siemienik I remember we had a discussion around cloning/copying style objects - could you review this part of the new code?

Copy link
Member

@Siemienik Siemienik Jun 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the best idea to maintain style's is change logic of setters to use Object.freez and copy values there. ( When any setter style is being used then all style object should be copy and freez)

I didn't know yet how this solution impact to this pr.

For instance:

set fill(fill){
 style = Object.freez({ ...style, fill:Object.freez(fill)});
}

(Written on smartfon - sorry for any mistake)

Edit: this will made styles immutable and protect us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style setting logic is based on already existing logic in splice method.

rDst.style = rSrc.style; // eslint-disable-next-line no-loop-func rSrc.eachCell({includeEmpty: true}, (cell, colNumber) => { rDst.getCell(colNumber).style = cell.style; }); rDst.height = rSrc.height;

Are you suggesting something like, this:
rDst.style = Object.freeze({...rSrc.style}); // eslint-disable-next-line no-loop-func rSrc.eachCell({includeEmpty: true}, (cell, colNumber) => { rDst.getCell(colNumber).style = Object.freeze({...cell.style}); }); rDst.height = rSrc.height;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Siemienik are you saying, to do it like this:
rDst.getCell(colNumber).style = Object.freeze({...cell.style}); });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Siemienik the existing property specific setter actual logic is in "_applyStyle" in row.js and again in cell's setter. This is not using Object.freeze yet. This may be added in another PR.
This pr directly copies style internally, just like spilceRows.
I have update the copy logic with Object.freeze as you told.
@Siemienik @alubbe Please review. Thank you.

@alubbe
Copy link
Member

alubbe commented Jun 5, 2020

The new changes look great - just left a comment regarding the copying of styles, let's see what @Siemienik has to say

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