-
-
Notifications
You must be signed in to change notification settings - Fork 893
SearchKit - Allow subsearch of different types #34853
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fa5407b
SearchKit - Add generic crm-search-display directive
colemanw e49d96f
SearchKit - Allow subsearch of different types
colemanw 229bf3e
SearchKit - Simplify crmSearchPage template and requirements
colemanw e714f40
Afform - Add support for generic `<crm-search-display>` tags.
colemanw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| (function(angular, $, _) { | ||
| "use strict"; | ||
|
|
||
| // Declare module | ||
| angular.module('crmSearchDisplay', CRM.angRequires('crmSearchDisplay')); | ||
| // Note: We're not using CRM.angRequires here to avoid circular dependencies with search display types. See crmSearchDisplay.ang.php | ||
| angular.module('crmSearchDisplay', ['api4', 'ngSanitize']); | ||
|
|
||
| })(angular, CRM.$, CRM._); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
ext/search_kit/ang/crmSearchDisplay/crmSearchDisplay.component.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| (function(angular, $, _) { | ||
| "use strict"; | ||
|
|
||
| // Generic wrapper to render any display type | ||
| angular.module('crmSearchDisplay').component('crmSearchDisplay', { | ||
| bindings: { | ||
| type: '@', | ||
| apiEntity: '@', | ||
| search: '<', | ||
| display: '<', | ||
| settings: '<', | ||
| filters: '<', | ||
| }, | ||
| template: function($element) { | ||
| let html = ''; | ||
| const displayTypes = CRM.crmSearchDisplay.viewableDisplayTypes; | ||
| Object.entries(displayTypes).forEach(([type, directive]) => { | ||
| html += `<${directive} ng-if="$ctrl.type === '${type}'" api-entity="{{:: $ctrl.apiEntity }}" search="$ctrl.search" display="$ctrl.display" settings="$ctrl.settings" filters="$ctrl.filters"></${directive}>`; | ||
| }); | ||
| return html; | ||
| }, | ||
| controller: function($scope, $element) { | ||
| } | ||
|
|
||
| }); | ||
|
|
||
| })(angular, CRM.$, CRM._); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@colemanw could we remove
typeandsettingshere and fetch them in the component based onsearchanddisplay?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.
Ah, yea they're probably usually contained within those arrays.
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.
@ufundo actually no, they're not.
searchanddisplayare strings not arrays. The only array passed in is thesettings. So all this stuff needs to be passed thru.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.
So my thinking is they are logically dependent, rather than literally one includes the other.
My first though was something like:
It's an extra api request, and it wont work well in the editor, but it is much more convenient if you are writing html/smarty templates to not have to fetch those things in advance.
Maybe it could be a fallback/lazy option:
That would be more of a follow-up than a blocker.
Uh oh!
There was an error while loading. Please reload this page.
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.
@ufundo it sounds like a good idea, but I think there's 2 potential problems:
'SearchDisplay', 'get'ajax api depending on their permission levels.If we really wanted to solve both problems, the metadata about the search display could be returned as part of the first
searchDisplay.runrequest as an extra SearchDisplayRunResult property... In theory, I haven't tried it, you could fetch metadata about the search AND run the search in the same ajax request.But that's a potentially YAGNI project and we've got bigger priorities IMO.
The real downside to this PR is that it loads ALL searchDisplay code ALL the time (e.g. all of ChartKit, etc). But js is browser-cacheable so probably not worth wringing our hands about.