Skip to content

Commit

Permalink
CiviCampaign - Add SearchKit displays to replace Campaign dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Sep 20, 2023
1 parent 26025de commit 737df96
Show file tree
Hide file tree
Showing 11 changed files with 900 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CRM/Campaign/DAO/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Campaign/Survey.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:754f9a2e62e86ff340afea563b561dec)
* (GenCodeChecksum:b517a686715877b8cde6af69122dcc0d)
*/

/**
Expand Down Expand Up @@ -45,6 +45,17 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
*/
public static $_log = FALSE;

/**
* Paths for accessing this entity in the UI.
*
* @var string[]
*/
protected static $_paths = [
'add' => 'civicrm/survey/add?reset=1',
'update' => 'civicrm/survey/configure/main?reset=1&action=update&id=[id]',
'delete' => 'civicrm/survey/delete?reset=1&id=[id]',
];

/**
* Survey id.
*
Expand Down
25 changes: 25 additions & 0 deletions ext/civi_campaign/ang/afsearchCampaignDashboard.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div crm-ui-tab-set>
<div af-fieldset crm-ui-tab crm-title="ts('Campaigns')" id="tab-campaigns">
<fieldset class="af-container af-layout-inline">
<af-field name="title,description" defn="{label: false, data_type: 'String', input_type: 'Text', name: 'title', input_attrs: {placeholder: 'Filter by title/description'}}" />
<af-field name="campaign_type_id" defn="{input_attrs: {multiple: true, placeholder: 'Filter by type'}, label: false}" />
<af-field name="status_id" defn="{input_attrs: {multiple: true, placeholder: 'Filter by status'}, label: false}" />
</fieldset>
<crm-search-display-table search-name="Administer_Campaigns" display-name="Campaigns_Table" total-count="$parent.count"></crm-search-display-table>
</div>
<div af-fieldset crm-ui-tab crm-title="ts('Surveys')" id="tab-surveys">
<fieldset class="af-container af-layout-inline">
<af-field name="title" defn="{label: false, input_attrs: {placeholder: 'Filter by title'}}" />
<af-field name="activity_type_id" defn="{input_attrs: {multiple: true, placeholder: 'Filter by type'}, label: false}" />
<af-field name="campaign_id" defn="{label: false, input_attrs: {placeholder: 'Filter by campaign', autoOpen: true}}" />
</fieldset>
<crm-search-display-table search-name="Administer_Surveys" display-name="Surveys_Table" total-count="$parent.count"></crm-search-display-table>
</div>
<div af-fieldset crm-ui-tab crm-title="ts('Petitions')" id="tab-petitions">
<fieldset class="af-container af-layout-inline">
<af-field name="title" defn="{label: false, input_attrs: {placeholder: 'Filter by title'}}" />
<af-field name="campaign_id" defn="{label: false, input_attrs: {placeholder: 'Filter by campaign', autoOpen: true}}" />
</fieldset>
<crm-search-display-table search-name="Administer_Petitions" display-name="Petitions_Table" total-count="$parent.count"></crm-search-display-table>
</div>
</div>
13 changes: 13 additions & 0 deletions ext/civi_campaign/ang/afsearchCampaignDashboard.aff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "search",
"title": "Campaign Dashboard",
"icon": "fa-table",
"server_route": "civicrm/campaign",
"permission": ["administer CiviCampaign", "manage campaign"],
"permission_operator": "OR",
"navigation": {
"parent": "Campaigns",
"label": "Campaign Dashboard",
"weight": -1
}
}
3 changes: 3 additions & 0 deletions ext/civi_campaign/ang/afsearchSurveyOptionGroup.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div af-fieldset="">
<crm-search-display-table search-name="Administer_Survey_Options" display-name="Administer_Survey_Options_Table" filters="{option_group_id: routeParams.option_group_id}"></crm-search-display-table>
</div>
7 changes: 7 additions & 0 deletions ext/civi_campaign/ang/afsearchSurveyOptionGroup.aff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "search",
"title": "",
"icon": "fa-list-alt",
"server_route": "civicrm/survey/option-group",
"permission": "access CiviCRM"
}
1 change: 1 addition & 0 deletions ext/civi_campaign/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</classloader>
<mixins>
<mixin>scan-classes@1.0.0</mixin>
<mixin>mgd-php@1.0.0</mixin>
</mixins>
<civix>
<namespace>CRM/Campaign</namespace>
Expand Down
212 changes: 212 additions & 0 deletions ext/civi_campaign/managed/SavedSearch_Administer_Campaigns.mgd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
<?php
use CRM_Campaign_ExtensionUtil as E;

return [
[
'name' => 'SavedSearch_Administer_Campaigns',
'entity' => 'SavedSearch',
'cleanup' => 'always',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'Administer_Campaigns',
'label' => E::ts('Administer Campaigns'),
'form_values' => NULL,
'mapping_id' => NULL,
'search_custom_id' => NULL,
'api_entity' => 'Campaign',
'api_params' => [
'version' => 4,
'select' => [
'id',
'title',
'description',
'is_active',
'start_date',
'end_date',
'campaign_type_id:label',
'status_id:label',
],
'orderBy' => [],
'where' => [],
'groupBy' => [],
'join' => [],
'having' => [],
],
'expires_date' => NULL,
'description' => NULL,
],
'match' => [
'name',
],
],
],
[
'name' => 'SavedSearch_Administer_Campaigns_SearchDisplay_Campaigns_Table',
'entity' => 'SearchDisplay',
'cleanup' => 'always',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'Campaigns_Table',
'label' => E::ts('Administer Campaigns'),
'saved_search_id.name' => 'Administer_Campaigns',
'type' => 'table',
'settings' => [
'actions' => FALSE,
'limit' => 50,
'classes' => [
'table',
'table-striped',
],
'pager' => [
'show_count' => TRUE,
'expose_limit' => TRUE,
'hide_single' => TRUE,
],
'placeholder' => 5,
'sort' => [
['is_active', 'DESC'],
['title', 'ASC'],
],
'columns' => [
[
'type' => 'field',
'key' => 'id',
'dataType' => 'String',
'label' => E::ts('Id'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'title',
'dataType' => 'String',
'label' => E::ts('Title'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'description',
'dataType' => 'String',
'label' => E::ts('Description'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'start_date',
'dataType' => 'Date',
'label' => E::ts('Start Date'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'end_date',
'dataType' => 'Date',
'label' => E::ts('End Date'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'campaign_type_id:label',
'dataType' => 'String',
'label' => E::ts('Type'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'status_id:label',
'dataType' => 'String',
'label' => E::ts('Status'),
'sortable' => TRUE,
'editable' => TRUE,
],
[
'type' => 'field',
'key' => 'is_active',
'dataType' => 'Boolean',
'label' => E::ts('Enabled'),
'sortable' => TRUE,
],
[
'size' => 'btn-xs',
'links' => [
[
'path' => '',
'icon' => 'fa-pencil',
'text' => E::ts('Edit'),
'style' => 'default',
'condition' => [],
'entity' => 'Campaign',
'action' => 'update',
'join' => '',
'target' => 'crm-popup',
],
[
'task' => 'enable',
'entity' => 'Campaign',
'target' => 'crm-popup',
'icon' => 'fa-toggle-on',
'text' => E::ts('Enable'),
'style' => 'default',
'condition' => ['is_active', '=', FALSE],
],
[
'task' => 'disable',
'entity' => 'Campaign',
'target' => 'crm-popup',
'icon' => 'fa-toggle-off',
'text' => E::ts('Disable'),
'style' => 'default',
'condition' => ['is_active', '=', TRUE],
],
[
'entity' => 'Campaign',
'action' => 'delete',
'join' => '',
'target' => 'crm-popup',
'icon' => 'fa-trash',
'text' => E::ts('Delete'),
'style' => 'danger small-popup',
'path' => '',
'condition' => [],
],
],
'type' => 'buttons',
'alignment' => 'text-right',
],
],
'toolbar' => [
[
'entity' => 'Campaign',
'action' => 'add',
'target' => 'crm-popup',
'icon' => 'fa-plus',
'text' => E::ts('Add Campaign'),
'style' => 'primary',
],
],
'cssRules' => [
[
'disabled',
'is_active',
'=',
FALSE,
],
],
],
'acl_bypass' => FALSE,
],
'match' => [
'name',
'saved_search_id',
],
],
],
];
Loading

0 comments on commit 737df96

Please sign in to comment.