-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Plugin: add-rows-on-paste #599
Conversation
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.
looks great to me, thanks for writing this up
const newRows = []; | ||
|
||
for(let i = 0; i < count; i++) { | ||
newRows.push({ index: rowLength + i, data: {} }); | ||
} |
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 might be a handy shortcut
const newRows = Array.from({ length: count }, (_, i) => ({ index: rowLength + i, data: {} }))
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.
I believe loop works better and more efficient
const items = this.providers.data.stores.rgRow.store.get('source'); | ||
|
||
items.push(...event.detail.newRows.map(j => j.data)) | ||
|
||
|
||
this.providers.data.setData(items); |
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.
Given that we'e doing a items.push()
(mutates the items array) and then also calling setData(items)
, are we mutating the data source twice here?
Wondering if this might be better, or maybe it doesn't matter;
const items = [
...this.providers.data.stores.rgRow.store.get('source'),
...event.detail.newRows.map(j => j.data)
]
this.providers.data.setData(items);
@Techn1x How would you recommend adding columns as well? This might be more difficult because of the mapping from column to object property? |
Yeah you're totally right, didn't think of that. I think it's a fair assumption that columns are statically defined by the developr and won't change based on user pasting in data input |
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.
LGTM, though I am not a maintainer (and am actually fairly new to the library) so my review probably holds no weight :)
I believe that's the point of open source so everyone reviews holds wait :-) |
Quality Gate passedIssues Measures |
Thank you @richardliebmann, all merged, probably we'll add some more updates on it in the future if you don't mind. |
Silly question but what path do I import this plugin from? There's docs on creating plugins but I am having trouble using 😄
EDIT: nevermind, it's simply from the main path. Just had to read the source code and see how it was all being exported |
This plugin adds new rows to the data if the number of entries is greater than the current data count.
Closes #338