VirtoCommerce / vc-platform

Virto Commerce B2B Innovation Platform
https://virtocommerce.com
Other
1.23k stars 845 forks source link

VCST-1448: Added the ability to unregister meta fields by name, templateUrl or a custom search predicate callback. #2813

Closed OlegoO closed 4 months ago

OlegoO commented 4 months ago

Description

Original PR by @SamBauwensPM: https://github.com/VirtoCommerce/vc-platform/pull/2812

Added the ability to unregister meta fields by name, templateUrl or a custom search predicate callback

We originally did that in a custom module of ours, and @EugeneOkhriemnko suggested I create a PR here so everyone can benefit.

Since there is no real method overloading in js, I did some _.isFunction magic to allow the same method ~group to accept the 3 different types of values for metaFieldToFind: name, function callback or object reference.

I added an error message because I think it's better t have an error than to silently not remove a field, but that could be considered a breaking change since the previous code didn't throw an error, if preferred this could be changed so that it only throws on error if metaFieldDescription, or not throw at all, or having this error throwing behaviour configured somewhere I don't know.

I tried to stay backwards compatible with the way unregisterMetaFields worked before, i.e it accepts an object reference in metaFieldToFind.## References

QA-test:

Jira-link:

https://virtocommerce.atlassian.net/browse/VCST-1448

Artifact URL:

Image tag: 3.839.0-pr-2813-72ba-vcst-1448-72baae9b

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud