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

update dropdown formatter example #309

Closed
wants to merge 3 commits into from

Conversation

jeremielodi
Copy link
Contributor

using a separate service to manage dropdown.
2019-10-10_09-00-11

@@ -11,13 +11,14 @@ import {
Formatters,
GridOption,
OnEventArgs,
} from './../modules/angular-slickgrid';
} from 'angular-slickgrid';
Copy link
Owner

Choose a reason for hiding this comment

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

you cannot do that here, you need to put back previous code. This is the lib and we need to reference it, it is not installed as a node_modules but instead is used directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right

args,
actionColumnIndex: 6,
parent : this,
$
Copy link
Owner

Choose a reason for hiding this comment

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

there's no need to pass the $, you can use declare var $: any; in the Service.

Copy link
Contributor Author

@jeremielodi jeremielodi Oct 10, 2019

Choose a reason for hiding this comment

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

Okay

@codecov-io
Copy link

codecov-io commented Oct 10, 2019

Codecov Report

Merging #309 into master will decrease coverage by 0.44%.
The diff coverage is 32.7%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
- Coverage   97.28%   96.85%   -0.43%     
==========================================
  Files         135      137       +2     
  Lines        7644     7693      +49     
  Branches     2593     2598       +5     
==========================================
+ Hits         7436     7450      +14     
- Misses        208      243      +35
Impacted Files Coverage Δ
src/app/modules/angular-slickgrid/index.ts 100% <100%> (ø) ⬆️
...ular-slickgrid/modules/angular-slickgrid.module.ts 100% <100%> (ø) ⬆️
.../app/modules/angular-slickgrid/formatters/index.ts 100% <100%> (ø) ⬆️
...ngular-slickgrid/formatters/bsDropdownFormatter.ts 100% <100%> (ø)
...rc/app/modules/angular-slickgrid/services/index.ts 100% <100%> (ø) ⬆️
...s/angular-slickgrid/services/bsDropdown.service.ts 14.64% <14.64%> (ø)
...dules/angular-slickgrid/sorters/sorterUtilities.ts 100% <0%> (ø) ⬆️
...ckgrid/filter-conditions/executeMappedCondition.ts 100% <0%> (ø) ⬆️
...pp/modules/angular-slickgrid/services/utilities.ts 100% <0%> (ø) ⬆️
... and 1 more

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 2e90077...de1758d. Read the comment docs.

@jeremielodi jeremielodi force-pushed the dropdown-update branch 2 times, most recently from 4b37218 to 682e9da Compare October 10, 2019 13:44
@@ -18,6 +18,8 @@ import { CustomAngularComponentEditor } from './custom-angularComponentEditor';
import { CustomAngularComponentFilter } from './custom-angularComponentFilter';
import { CustomTitleFormatterComponent } from './custom-titleFormatter.component';
import { FilterNgSelectComponent } from './filter-ng-select.component';
import { DropDownService } from './dropdown.service';
Copy link
Owner

Choose a reason for hiding this comment

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

Your new Service doesn't seem to be part of the providers of the App Module, is that something you forgot to do? You don't seem to instantiate that Service but instead using it as a static Service, I'm not sure that is a good idea since you won't be able to use Dependency Injection in the future

@jeremielodi jeremielodi force-pushed the dropdown-update branch 2 times, most recently from df23679 to 8c5fb14 Compare October 11, 2019 05:26
@jeremielodi
Copy link
Contributor Author

The last thing we can do is to create dropdownFormatter like you did iconFormatter defined at src\app\modules\angular-slickgrid\formatters\iconFormatter.ts

@jeremielodi jeremielodi force-pushed the dropdown-update branch 2 times, most recently from 6bc77b3 to 982cacd Compare October 11, 2019 06:12
@ghiscoding
Copy link
Owner

ghiscoding commented Oct 11, 2019

If you add something to the library code itself (the Formatter), you will need to add Unit Tests as well. There isn't any unit tests for the examples but all the lib is fully tested (what I have for the Examples are some E2E tests). You can take a look at the Formatter __tests__ folder. I put a lot of effort in adding all necessary tests, so I hope you would do the same so that the test coverage doesn't get lower.

I see that your last commit decreased the test code coverage

- Coverage   97.28%   97.22%   -0.06%  

I'm also wondering if the name you chose for the Formatter is a little too generic, it doesn't represent that it's a Bootstrap Dropdown component. I'm not sure of a better name, but I'd like to make it a bit clearer that it's not a regular dropdown... maybe bsDropdownFormatter or bootstrapDropdownFormatter, I'll let you choose the final name

@jeremielodi
Copy link
Contributor Author

I did not realize that you use boostrap3, all my updates were working fine in my project but when I tried to create a PR here there was bugs..

@ghiscoding
Copy link
Owner

My library works with both version of Bootstrsap 3-4. The lib itself was written with Bootstrap 3 but when I want to test BS4, I use the Angular-Slickgrid-Demos for BS4. Usually just passing the css classes for both versions makes it work for both version.

@jeremielodi
Copy link
Contributor Author

Did you test my updates, does it work fine?

@ghiscoding
Copy link
Owner

Didn't have time yet, this is mostly just an example



interface DropDownServiceParams {
grid: AngularGridInstance,
Copy link
Owner

Choose a reason for hiding this comment

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

You don't need to pass this grid object, you can get it instead from the SharedService, see this line as example

constructor(... sharedService: SharedService) {}
...
this.sharedService.grid;

@ghiscoding
Copy link
Owner

I see you changed the code a lot and added a new Service, that is all fine but again I'll ask to add necessary Jest Unit Tests for this new Service. I didn't have a chance to try this yet, I'll give it a try next week. Thanks

describe('Render method', () => {
const service = BsDropDownService;
it('should show check is the dropdown is displayed after clic', () => {
expect(true).toBe(true);
Copy link
Owner

Choose a reason for hiding this comment

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

I hope you will eventually add more tests than this, because I won't accept this PR as it is. Please provide sufficient Jest Unit Tests before I can review and accept this PR

@ghiscoding
Copy link
Owner

Superseded by #314

@jeremielodi
I took your PR and fixed a few things, added Jest Unit Tests and Cypress E2E test for your new Action Dropdown. I'll release a new version today.

There is 1 major thing to note about your code, you cannot export the SharedService from the Angular-Slickgrid Module, the reason is because that service (and others) have to be Non-Singleton. If you make them Singleton and you have 2 or more Grids in your window and you export the service as Singleton, then using a service in 1 grid could/will impact the next grid... So that is the reason the SharedService and a few other Services are only available from the (onAngularGridCreated)="angularGridReady($event)"

@ghiscoding ghiscoding closed this Oct 17, 2019
@jeremielodi
Copy link
Contributor Author

Thanks

@jeremielodi
Copy link
Contributor Author

jeremielodi commented Oct 17, 2019

@ghiscoding, I wonder if it's possible to have the component(page) context inside a formatter.
That way it will be easy to render templates in grid's cell.

@ghiscoding
Copy link
Owner

You can refresh your code and play with it and make other contributions if you wish in the future. I'm about to release a new version (in the next few minutes) and I will go with the code I have now. I'm certainly open for PR that might enhance the lib and/or the examples. Thanks

@ghiscoding
Copy link
Owner

Also up vote ⭐️ if you like the lib and haven't up voted yet, thanks 😸

@ghiscoding
Copy link
Owner

ghiscoding commented Oct 17, 2019

Found out that the dropdown was not working with Bootstrap 4, I made a commit to fix that in the BsDropdownService but I'll wait couple days before releasing a new version, just in case something else comes up.

EDIT

I actually refactored the Service again and added almost full test coverage now with this commit

@ghiscoding
Copy link
Owner

@jeremielodi
You might be interested in 2 new Context Menu plugins that I'm currently working on here. I'm currently developing them as SlickGrid (core) Plugins, once that is done I will integrate them into Angular-Slickgrid (might fall after Christmas).

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