Skip to content

Commit 9ead24b

Browse files
committed
Convert Mailing AB listing to SearchKit display and Afform page
1 parent 5c5dd19 commit 9ead24b

9 files changed

Lines changed: 169 additions & 91 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div af-fieldset="">
2+
<details class="af-container af-layout-inline" af-title="Filters" open="">
3+
<af-field name="name" />
4+
<af-field name="status" />
5+
<af-field name="testing_criteria" />
6+
</details>
7+
<crm-search-display-table search-name="Mailing_AB_Test" display-name="Mailing_AB_Test_Table"></crm-search-display-table>
8+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
use CRM_Mailing_ExtensionUtil as E;
3+
4+
return [
5+
'type' => 'search',
6+
'title' => E::ts('Manage A/B Tests'),
7+
'icon' => 'fa-flask',
8+
'server_route' => 'civicrm/mailing/abtest',
9+
'permission' => [
10+
'access CiviMail',
11+
],
12+
];

ext/civi_mail/ang/crmMailingAB.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44
angular.module('crmMailingAB').config([
55
'$routeProvider',
66
function($routeProvider) {
7-
$routeProvider.when('/abtest', {
8-
templateUrl: '~/crmMailingAB/ListCtrl.html',
9-
controller: 'CrmMailingABListCtrl',
10-
resolve: {
11-
mailingABList: function($route, crmApi) {
12-
return crmApi('MailingAB', 'get', {rowCount: 0});
13-
},
14-
fields: function(crmMetadata) {
15-
return crmMetadata.getFields('MailingAB');
16-
}
17-
}
18-
});
197
$routeProvider.when('/abtest/new', {
208
template: '<p>' + ts('Initializing...') + '</p>',
219
controller: 'CrmMailingABNewCtrl',

ext/civi_mail/ang/crmMailingAB/EditCtrl.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@
105105
};
106106

107107
$scope.leave = function leave() {
108-
$location.path('abtest');
109-
$location.replace();
108+
window.location = CRM.url('civicrm/mailing/abtest');
110109
};
111110

112111
$scope.selectWinner = function selectWinner(mailingName) {

ext/civi_mail/ang/crmMailingAB/ListCtrl.html

Lines changed: 0 additions & 63 deletions
This file was deleted.

ext/civi_mail/ang/crmMailingAB/ListCtrl.js

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
use CRM_Mailing_ExtensionUtil as E;
3+
4+
return [
5+
[
6+
'name' => 'Navigation_afsearchMailingAB',
7+
'entity' => 'Navigation',
8+
'cleanup' => 'unused',
9+
'update' => 'unmodified',
10+
'params' => [
11+
'version' => 4,
12+
'values' => [
13+
'label' => E::ts('Manage A/B Tests'),
14+
'name' => 'afsearchMailingAB',
15+
'url' => 'civicrm/mailing/abtest',
16+
'icon' => 'crm-i fa-flask',
17+
'permission' => [
18+
'access CiviMail',
19+
],
20+
'permission_operator' => 'AND',
21+
'parent_id.name' => 'Mailings',
22+
'weight' => 16,
23+
],
24+
'match' => ['name', 'domain_id'],
25+
],
26+
],
27+
];
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
use CRM_Mailing_ExtensionUtil as E;
3+
4+
return [
5+
[
6+
'name' => 'SavedSearch_Mailing_AB_Test',
7+
'entity' => 'SavedSearch',
8+
'cleanup' => 'unused',
9+
'update' => 'unmodified',
10+
'params' => [
11+
'version' => 4,
12+
'values' => [
13+
'name' => 'Mailing_AB_Test',
14+
'label' => E::ts('Mailing A/B Tests'),
15+
'api_entity' => 'MailingAB',
16+
'api_params' => [
17+
'version' => 4,
18+
'select' => [
19+
'id',
20+
'name',
21+
'status',
22+
'testing_criteria',
23+
'created_date',
24+
],
25+
'orderBy' => [],
26+
'where' => [],
27+
'groupBy' => [],
28+
'join' => [],
29+
'having' => [],
30+
],
31+
],
32+
'match' => ['name'],
33+
],
34+
],
35+
[
36+
'name' => 'SavedSearch_Mailing_AB_Test_SearchDisplay_Mailing_AB_Test_Table',
37+
'entity' => 'SearchDisplay',
38+
'cleanup' => 'unused',
39+
'update' => 'unmodified',
40+
'params' => [
41+
'version' => 4,
42+
'values' => [
43+
'name' => 'Mailing_AB_Test_Table',
44+
'label' => E::ts('Mailing A/B Tests Table'),
45+
'saved_search_id.name' => 'Mailing_AB_Test',
46+
'type' => 'table',
47+
'settings' => [
48+
'description' => '',
49+
'sort' => [
50+
['created_date', 'DESC'],
51+
],
52+
'limit' => 50,
53+
'pager' => [],
54+
'placeholder' => 5,
55+
'columns' => [
56+
[
57+
'type' => 'field',
58+
'key' => 'name',
59+
'label' => 'Name',
60+
'sortable' => TRUE,
61+
],
62+
[
63+
'type' => 'field',
64+
'key' => 'status:label',
65+
'label' => 'Status',
66+
'sortable' => TRUE,
67+
],
68+
[
69+
'type' => 'field',
70+
'key' => 'testing_criteria:label',
71+
'label' => 'Test Type',
72+
'sortable' => TRUE,
73+
],
74+
[
75+
'type' => 'field',
76+
'key' => 'created_date',
77+
'label' => 'Created',
78+
'sortable' => TRUE,
79+
],
80+
[
81+
'links' => [
82+
[
83+
'icon' => 'fa-pencil',
84+
'text' => 'Continue',
85+
'style' => 'default',
86+
'path' => 'civicrm/a/#/abtest/[id]',
87+
'condition' => ['status', '=', 'Draft'],
88+
],
89+
[
90+
'icon' => 'fa-bar-chart',
91+
'text' => E::ts('Results'),
92+
'style' => 'default',
93+
'path' => 'civicrm/a/#/abtest/[id]',
94+
'condition' => ['status', '!=', 'Draft'],
95+
],
96+
],
97+
'type' => 'links',
98+
'alignment' => 'text-right',
99+
],
100+
],
101+
'actions' => FALSE,
102+
'classes' => ['table', 'table-striped'],
103+
'toolbar' => [
104+
[
105+
'path' => 'civicrm/a/#/abtest/new',
106+
'icon' => 'fa-flask',
107+
'text' => 'New A/B Test',
108+
'style' => 'primary',
109+
],
110+
],
111+
],
112+
],
113+
'match' => [
114+
'saved_search_id',
115+
'name',
116+
],
117+
],
118+
],
119+
];

xml/templates/civicrm_navigation.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ VALUES
180180
( @domainID, 'civicrm/admin/options/site_email_address', '{ts escape="sql" skip="true"}Site From Email Addresses{/ts}', 'CiviMail Site From Email Addresses', 'administer CiviCRM', '', @mailinglastID, '1', 1, 8 ),
181181
( @domainID, 'civicrm/sms/send?reset=1', '{ts escape="sql" skip="true"}New SMS{/ts}', 'New SMS', 'send SMS', NULL, @mailinglastID, '1', NULL, 9 ),
182182
( @domainID, 'civicrm/mailing/browse?reset=1&sms=1', '{ts escape="sql" skip="true"}Find Mass SMS{/ts}', 'Find Mass SMS', 'send SMS', NULL, @mailinglastID, '1', 1, 10 ),
183-
( @domainID, 'civicrm/a/#/abtest/new', '{ts escape="sql" skip="true"}New A/B Test{/ts}', 'New A/B Test', 'access CiviMail', '', @mailinglastID, '1', NULL, 15 ),
184-
( @domainID, 'civicrm/a/#/abtest', '{ts escape="sql" skip="true"}Manage A/B Tests{/ts}', 'Manage A/B Tests', 'access CiviMail', '', @mailinglastID, '1', 1, 16 );
183+
( @domainID, 'civicrm/a/#/abtest/new', '{ts escape="sql" skip="true"}New A/B Test{/ts}', 'New A/B Test', 'access CiviMail', '', @mailinglastID, '1', NULL, 15 );
184+
185185

186186
INSERT INTO civicrm_navigation
187187
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight, icon )

0 commit comments

Comments
 (0)