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

feat(plugin): new Row Based Editor #1323

Merged
merged 41 commits into from
Jan 18, 2024
Merged

feat(plugin): new Row Based Editor #1323

merged 41 commits into from
Jan 18, 2024

Conversation

zewa666
Copy link
Contributor

@zewa666 zewa666 commented Jan 11, 2024

this adds the new row based edit plugin

closes #1299

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (a9cb8ee) 98.0% compared to head (f5f429c) 99.4%.
Report is 16 commits behind head on master.

Files Patch % Lines
...ackages/common/src/extensions/slickRowBasedEdit.ts 99.3% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1323     +/-   ##
========================================
+ Coverage    98.0%   99.4%   +1.5%     
========================================
  Files         198     199      +1     
  Lines       21286   21571    +285     
  Branches     7098    7203    +105     
========================================
+ Hits        20847   21429    +582     
+ Misses        439     142    -297     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 13, 2024

ok I'm still not sure I really understand how to approach the i18n part.
Here's what I've tried so far:
i18n.patch

the mentioned function translateItems isn't really suitable (array based) plus it doesn't really do anything besides calling translate.

@zewa666 zewa666 changed the title feat(plugin): new Row Based Edit, closes #1299 feat(plugin): new Row Based Edi Jan 14, 2024
@zewa666 zewa666 changed the title feat(plugin): new Row Based Edi feat(plugin): new Row Based Editor Jan 14, 2024
@ghiscoding
Copy link
Owner

ah sorry that wasn't a good explanation, without looking at the patch you linked (I'm supposed to be off on Sundays ;)). So anyway, I'll assume you might be looking for code when the locale changes, below is the code that calls that.

// translate them all on first load, then on each language change
if (gridOptions.enableTranslate) {
this.extensionService.translateAllExtensions();
this.translateColumnHeaderTitleKeys();
this.translateColumnGroupKeys();
}
// on locale change, we have to manually translate the Headers, GridMenu
this.subscriptions.push(
this._eventPubSubService.subscribe('onLanguageChange', () => {
if (gridOptions.enableTranslate) {
this.extensionService.translateAllExtensions();
this.translateColumnHeaderTitleKeys();
this.translateColumnGroupKeys();
if (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping) {
this.groupingService.translateGroupingAndColSpan();
}
}
})
);

So you probably need to add a method that will be called to from the callback above.

If that is still not helping, just let me know and I'll take a proper look at the patch

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 15, 2024

ok think I got it working. There was still a nasty bug with Cypress but I got a workaround to force drop the old cached items.
Next up ... writing docs

}
}

& .active {
Copy link
Owner

@ghiscoding ghiscoding Jan 15, 2024

Choose a reason for hiding this comment

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

I think you missed that one when I mentioned it couple days ago, I mean just remove & since it's not needed here

}
}

& .active {
Copy link
Owner

Choose a reason for hiding this comment

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

same as previous, & can be removed

this.gridOptions.rowBasedEditOptions?.actionButtons?.updateButtonTitleKey
)) ||
this.gridOptions.rowBasedEditOptions?.actionButtons?.updateButtonTitle ||
'Update the Row';
Copy link
Owner

Choose a reason for hiding this comment

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

I see a lot of the same code repeated, perhaps we could migrate this to an external protected function? Something along these lines

protected getTitleOrDefault(key: string, defaultTitle: string) {
  const actionBtnOptions = this.gridOptions.rowBasedEditOptions?.actionButtons; 
  const hasTranslateService = this.extensionUtility.translaterService?.translate;

  // another approach might be to move the line above to GETTERs in the class?
  
  return hasTranslateService ? actionBtnOptions[key] : defaultTitle;
}

this.btnUpdateTitle = this.getTitleOrDefault('updateButtonTitleKey', 'Update the Row');

I should probably do that in some other extensions like the GridMenu that I think I did something like you did and I think that this could make the code more readable.

@ghiscoding
Copy link
Owner

ghiscoding commented Jan 17, 2024

this is out of context but, it's a nice story... so I keep adding unit tests for the core files and it's not exactly a fun exercise but I keep finding and fixing small bugs and also removed a bunch of unused/unreachable code. So it does seem to be worth the extra work (I'm now at 99.4% coverage, the end of the tunnel is in sight woohoo)

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 17, 2024

yeah its great when you see that type of payoff. I wasnt able to invest time the last few days sadly but hope to manage it in the next few ones.

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 17, 2024

hey with the latest commit I've added again a bit of TS type inference helpers.

image

Way back than I've added already some to create the Column defintion type. So my question is whether it's ok to leave them all sprinkled around or you'd want to co-locate them all in one ts-utils.ts file sort of

@ghiscoding
Copy link
Owner

ghiscoding commented Jan 17, 2024

hey with the latest commit I've added again a bit of TS type inference helpers.

image

Way back than I've added already some to create the Column defintion type. So my question is whether it's ok to leave them all sprinkled around or you'd want to co-locate them all in one ts-utils.ts file sort of

ah yeah I saw the inference type you added, at first glance I thought it was a little overkill since it's only used once hahah but nonetheless it's quite powerful and you can't go wrong with that approach. Feel free to put it where you think is best, when I started the project, I used to create a file per interface but I see my folder is getting quite large now and lately, I started grouping some of them by feature depending on what it is. So you could add it to interfaces/rowBasedEditOption.interface.ts if it's only used for that or create something like inference.helper or whatever and if that is what you go with then maybe move the ones you've done in the past from column.interface. I don't have any preferences on which approach to choose, just go with what you think is best

type PathsToStringProps<T> = T extends string | number | boolean | Date ? [] : {
[K in Extract<keyof T, string>]: [K, ...PathsToStringProps<T[K]>]
}[Extract<keyof T, string>];
/* eslint-disable @typescript-eslint/indent */
// disable eslint indent rule until this issue is fixed: https://github.com/typescript-eslint/typescript-eslint/issues/1824
type Join<T extends any[], D extends string> =
T extends [] ? never :
T extends [infer F] ? F :
T extends [infer F, ...infer R] ?
F extends string ? string extends F ? string : `${F}${D}${Join<R, D>}` : never : string;
/* eslint-enable @typescript-eslint/indent */
export interface Column<T = any> {

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 17, 2024

yeah I'm a bit nervous when magic strings are floating around as my future self isn't that mindful of knowing what the intention was. So it serves as a real well gatekeeper to focus the type and be more expressive (all of that just to save one line of comment 🤣 )

Nevertheless the docs are now also added. A quick review on those would be very appreciated.

You can override the styling, the hover text as well as whether a prompt — and with what text — should be shown. It is done by overriding the `actionButtons` property of the [plugins options](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/interfaces/rowBasedEditOption.interface.ts).

## Support for the Excel Copy Buffer Plugin
If the [Excel Copy Buffer Plugin](grid-functionalities/excel-copy-buffer.md) is configured, the Row based edting pluging will override it's behavior by denying pastes on all cells not within a editmode row. Nevertheless, any existing `BeforePasteCellHandler` will be respected.
Copy link
Owner

Choose a reason for hiding this comment

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

"the Row based edting pluging", the word "edting" has a typo

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 18, 2024

alright I think I got everything in that I've planned for. How do you want to proceed from here?

@ghiscoding ghiscoding merged commit 64d464c into ghiscoding:master Jan 18, 2024
7 checks passed
@ghiscoding
Copy link
Owner

looking good.... let's hit the Merge button 🚀

I think the next steps will be to replicate the new Example into the external repos (Angular-Slickgrid, ...), did you wanted to me to do that or did you wanted to do it too (for Angular I mean)?

@zewa666
Copy link
Contributor Author

zewa666 commented Jan 18, 2024

I can do so for Angular whenever you release slickgrid universal and bump it as dependency in Angular-slickgrid.

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.

Row Based Edit Plugin
2 participants