- added category plugin that enables adding category for the filters.#455
- added category plugin that enables adding category for the filters.#455cansaner wants to merge 2 commits intomistic100:devfrom
Conversation
|
The CI failed on codestyle, run tests locally before pushing. |
src/plugins/category/plugin.js
Outdated
| * Read "category" from JSON | ||
| */ | ||
| this.on('jsonToRule.filter', function(e, json) { | ||
| //e.value.category = e.builder.getCategoryById(json.category ? json.category : '-1'); |
|
|
||
| <link rel="stylesheet" href="http://mistic100.github.io/jQuery-QueryBuilder/assets/flags/flags.css"> | ||
| <style> | ||
| .flag { |
There was a problem hiding this comment.
please do not change the indentation of the whole file.
| this.categories = this.settings.categories; | ||
|
|
||
| // CHECK ALL CATEGORIES | ||
| this.categories = this.checkCategories(this.categories); |
| // keep a pointer to the original addRule method | ||
| var originaAddRule = QueryBuilder.prototype.addRule; | ||
|
|
||
| QueryBuilder.extend({ |
There was a problem hiding this comment.
Not ok, you must find a way the call the original method (but putting the new code before or after) or use existing events, or add new events where needed.
There was a problem hiding this comment.
Same for all overwritten methods
src/plugins/category/plugin.js
Outdated
| isFilterOKForCategory: function(filterId, categoryId) { | ||
| var filtersOfCategory = this.getFiltersForCategoryId(categoryId); | ||
|
|
||
| for (var i = 0; i < filtersOfCategory.length; i++) { |
There was a problem hiding this comment.
can make usage of filtersOfCategory.some method
| getFiltersForCategoryId: function(categoryId) { | ||
| var filtersOfCategory = []; | ||
| var category = this.getCategoryById(categoryId); | ||
| this.filters.forEach(function(filter, i) { |
There was a problem hiding this comment.
useless double foreach : loop over category.filters and use getFilterById
| * @return {boolean} true if filter belongs to that category | ||
| */ | ||
| isFilterOKForCategory: function(filterId, categoryId) { | ||
| var filtersOfCategory = this.getFiltersForCategoryId(categoryId); |
There was a problem hiding this comment.
useless access to getFiltersForCategoryId: use getCategoryById and loop over its filters
|
@cansaner there are two much breakable code (overriden methods) for this to be merged. You are free to release this as a separated standalone plugin in it's own repository (I can help you to make it standalone if you want). |
|
@mistic100 I will definitely focus on making it standalone. My thesis statement is pushing me hard these days. I ll hopefully focus back on October I guess... Thanks a lot in advance |
Merge request checklist
devand I am issuing the PR todev__localeand__authorfields