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

Add SearchKit Reports extension #31458

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
!/ext/message_admin
!/ext/oauth-client
!/ext/search_kit
!/ext/search_kit_reports
!/ext/financialacls
!/ext/contributioncancelactions
!/ext/recaptcha
Expand Down
5 changes: 5 additions & 0 deletions ext/afform/core/Civi/Api4/Afform.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ public static function getFields($checkPermissions = TRUE) {
[
'name' => 'name',
'title' => E::ts('Name'),
'input_type' => 'Text',
],
[
'name' => 'type',
'title' => E::ts('Type'),
'pseudoconstant' => ['optionGroupName' => 'afform_type'],
'default_value' => 'form',
'input_type' => 'Select',
],
[
'name' => 'requires',
Expand All @@ -169,10 +171,12 @@ public static function getFields($checkPermissions = TRUE) {
'name' => 'title',
'title' => E::ts('Title'),
'required' => $self->getAction() === 'create',
'input_type' => 'Text',
],
[
'name' => 'description',
'title' => E::ts('Description'),
'input_type' => 'Text',
],
[
'name' => 'placement',
Expand Down Expand Up @@ -329,6 +333,7 @@ public static function getFields($checkPermissions = TRUE) {
'description' => 'Name of extension which provides this form',
'readonly' => TRUE,
'pseudoconstant' => ['callback' => ['CRM_Core_BAO_Managed', 'getBaseModules']],
'input_type' => 'Select',
];
$fields[] = [
'name' => 'search_displays',
Expand Down
667 changes: 667 additions & 0 deletions ext/search_kit_reports/LICENSE.txt

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions ext/search_kit_reports/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SearchKit_Reports
Extension to provide extra UI for using Afform Search Forms as Reports.

This is an [extension for CiviCRM](https://docs.civicrm.org/sysadmin/en/latest/customize/extensions/), licensed under [AGPL-3.0](LICENSE.txt).

## Getting Started

Enable the extension.

1. Use SearchKit to create a SavedSearch for the data you wish to show in your Report

2. Add a SearchDisplay to your SavedSearch

3. Use FormBuilder to add a Search Form for your SearchDisplay.

4. In FormBuilder, add the "Reports List" tag to the Placements option for your Search Form.

5. Head to Reports >> SearchKit Reports in the menu.

## Known issues

- Check how listing responds to report permissions
8 changes: 8 additions & 0 deletions ext/search_kit_reports/ang/afsearchSearchKitReports.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div af-fieldset="">
<div class="af-container af-layout-inline">
<af-field name="title" />
<af-field name="description" />
<af-field name="base_module" defn="{input_attrs: {multiple: true}}" />
</div>
<crm-search-display-table search-name="SearchKit_Reports" display-name="SearchKit_Reports_Table"></crm-search-display-table>
</div>
12 changes: 12 additions & 0 deletions ext/search_kit_reports/ang/afsearchSearchKitReports.aff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
use CRM_SearchKitReports_ExtensionUtil as E;

return [
'type' => 'search',
'title' => E::ts('SearchKit Reports'),
'icon' => 'fa-list-alt',
'server_route' => 'civicrm/report/search_kit',
'search_displays' => [
'SearchKit_Reports.SearchKit_Reports_Table',
],
];
42 changes: 42 additions & 0 deletions ext/search_kit_reports/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<extension key="search_kit_reports" type="module">
<file>search_kit_reports</file>
<name>search_kit_reports</name>
<description>SearchKit-based Reports UI</description>
<license>AGPL-3.0</license>
<authors>
<author>
<name>Ben</name>
<email>[email protected]</email>
<role>Maintainer</role>
</author>
</authors>
<urls>
<url desc="Main Extension Page">https://FIXME</url>
<url desc="Documentation">https://FIXME</url>
<url desc="Support">https://FIXME</url>
<url desc="Licensing">https://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2024-11-27</releaseDate>
<version>1.0.0</version>
<develStage>alpha</develStage>
<compatibility>
<ver>5.81</ver>
</compatibility>
<comments>SearchKit-based reporting UI</comments>
<classloader>
<psr0 prefix="CRM_" path="."/>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
<civix>
<namespace>CRM/AfformReports</namespace>
<format>24.09.1</format>
<angularModule>afReports</angularModule>
</civix>
<mixins>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
</mixins>
</extension>
27 changes: 27 additions & 0 deletions ext/search_kit_reports/managed/AfformPlacement.mgd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use CRM_SearchKitReports_ExtensionUtil as E;

// Option for Afform.placement field
return [
[
'name' => 'AfformPlacement:reports',
'entity' => 'OptionValue',
'cleanup' => 'always',
'update' => 'always',
'params' => [
'version' => 4,
'values' => [
'option_group_id.name' => 'afform_placement',
'name' => 'reports',
'value' => 'reports',
'label' => E::ts('Reports Listing'),
'is_reserved' => TRUE,
'is_active' => TRUE,
'icon' => 'fa-list-alt',
'description' => E::ts('Include in the SearchKit Reports listing in the UI'),
],
'match' => ['option_group_id', 'name'],
],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
use CRM_SearchKitReports_ExtensionUtil as E;

return [
[
'name' => 'Navigation_afsearchSearchKitReports',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => E::ts('SearchKit Reports'),
'name' => 'afsearchSearchKitReports',
'url' => 'civicrm/report/search_kit',
'icon' => 'crm-i fa-list-alt',
'permission' => [
'access CiviReport',
],
'permission_operator' => 'AND',
'parent_id.name' => 'Reports',
'weight' => 1,
],
'match' => ['name', 'domain_id'],
],
],
];
114 changes: 114 additions & 0 deletions ext/search_kit_reports/managed/SavedSearch_SearchKit_Reports.mgd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
use CRM_SearchKitReports_ExtensionUtil as E;

return [
[
'name' => 'SavedSearch_SearchKit_Reports',
'entity' => 'SavedSearch',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'SearchKit_Reports',
'label' => E::ts('SearchKit Reports'),
'api_entity' => 'Afform',
'api_params' => [
'version' => 4,
'select' => [
'name',
'title',
'description',
'placement:label',
'server_route',
],
'orderBy' => [],
'where' => [
['server_route', 'IS NOT EMPTY'],
['placement:name', 'CONTAINS', 'reports'],
],
],
],
'match' => ['name'],
],
],
[
'name' => 'SavedSearch_SearchKit_Reports_SearchDisplay_SearchKit_Reports_Table',
'entity' => 'SearchDisplay',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'SearchKit_Reports_Table',
'label' => E::ts('SearchKit Reports Table'),
'saved_search_id.name' => 'SearchKit_Reports',
'type' => 'table',
'settings' => [
'description' => E::ts(''),
'sort' => [],
'limit' => 50,
'pager' => [],
'placeholder' => 5,
'columns' => [
[
'type' => 'field',
'key' => 'title',
'dataType' => 'String',
'label' => E::ts('Title'),
'sortable' => TRUE,
'cssRules' => [
['font-bold'],
],
],
[
'type' => 'field',
'key' => 'description',
'dataType' => 'String',
'label' => E::ts('Description'),
'sortable' => TRUE,
],
[
'size' => 'btn-xs',
'links' => [
[
'path' => '[server_route]',
'icon' => 'fa-external-link',
'text' => E::ts('Open'),
'style' => 'info',
'condition' => [],
'task' => '',
'entity' => '',
'action' => '',
'join' => '',
'target' => '',
],
[
'path' => 'civicrm/admin/afform#/edit/[name]',
'icon' => 'fa-pen-to-square',
'text' => E::ts('Edit'),
'style' => 'warning',
'condition' => [],
'task' => '',
'entity' => '',
'action' => '',
'join' => '',
'target' => '',
],
],
'type' => 'buttons',
'alignment' => 'text-right',
],
],
'actions' => FALSE,
'classes' => ['table', 'table-striped'],
'actions_display_mode' => 'menu',
],
],
'match' => [
'saved_search_id',
'name',
],
],
],
];
Loading