Commit e30c4758 authored by Rich Lott / Artful Robot's avatar Rich Lott / Artful Robot
Browse files

Add processor filter to webhooks list page

parent 9aa21cff
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<div crm-ui-accordion="{title: ts('Filters')}"> <div crm-ui-accordion="{title: ts('Filters')}">
<div class="crm-block"> <div class="crm-block">
<div class="crm-group"> <div class="crm-group">
<div crm-ui-field="{name: 'myForm.statuses', title: ts('Status')}"> <div crm-ui-field="{name: 'myForm.statuses', title: ts('Status')}">
<select type="text" ng-model="$ctrl.statusFilter" > <select type="text" ng-model="$ctrl.statusFilter" >
<option value="">{{ts('- Any -')}}</option> <option value="">{{ts('- Any -')}}</option>
...@@ -16,6 +17,19 @@ ...@@ -16,6 +17,19 @@
</select> </select>
</div> </div>
<div crm-ui-field="{name: 'myForm.processor', title: ts('Processor')}">
<select type="text" ng-model="$ctrl.processorFilter" >
<option value="">{{ts('- Any -')}}</option>
<option ng-repeat="processor in $ctrl.processors"
value="{{processor.id}}"
>{{processor.processorType}}:
{{processor.processorName}}:
{{:: processor.isTest ? ts('Test') : ts('Live') }}
({{ts('%count webhooks', {count:processor.webhooksCount}) }})
</option>
</select>
</div>
<div crm-ui-field="{name: 'myForm.event', title: ts('Event ID')}"> <div crm-ui-field="{name: 'myForm.event', title: ts('Event ID')}">
<input <input
crm-ui-id="myForm.event_id" crm-ui-id="myForm.event_id"
......
...@@ -8,7 +8,17 @@ ...@@ -8,7 +8,17 @@
// If you need to look up data when opening the page, list it out // If you need to look up data when opening the page, list it out
// under "resolve". // under "resolve".
resolve: { } resolve: {
processors: function(crmApi4) {
return crmApi4('PaymentProcessor', 'get', {
select: ["id", "MIN(name) AS processorName", "MIN(payment_processor_type_id:label) AS processorType", "MIN(is_test) AS isTest", "COUNT(paymentprocessor_webhook.id) AS webhooksCount"],
join: [["PaymentprocessorWebhook AS paymentprocessor_webhook", "LEFT", ["id", "=", "paymentprocessor_webhook.payment_processor_id"]]],
groupBy: ["id"],
where: [["is_test", "IS NOT EMPTY"]],
orderBy: {"payment_processor_type_id:label":"ASC", "is_test":"ASC"}
});
}
}
}); });
} }
); );
...@@ -17,15 +27,17 @@ ...@@ -17,15 +27,17 @@
// $scope -- This is the set of variables shared between JS and HTML. // $scope -- This is the set of variables shared between JS and HTML.
// crmApi, crmStatus, crmUiHelp -- These are services provided by civicrm-core. // crmApi, crmStatus, crmUiHelp -- These are services provided by civicrm-core.
// myContact -- The current contact, defined above in config(). // myContact -- The current contact, defined above in config().
angular.module('mjwshared').controller('MjwsharedPaymentprocessorWebhook', function($scope, crmApi4, crmStatus, crmUiHelp) { angular.module('mjwshared').controller('MjwsharedPaymentprocessorWebhook', function($scope, crmApi4, crmStatus, crmUiHelp, processors) {
// The ts() and hs() functions help load strings for this module. // The ts() and hs() functions help load strings for this module.
var ts = $scope.ts = CRM.ts('mjwshared'); var ts = $scope.ts = CRM.ts('mjwshared');
var hs = $scope.hs = crmUiHelp({file: 'CRM/mjwshared/PaymentprocessorWebhook'}); // See: templates/CRM/mjwshared/PaymentprocessorWebhook.hlp var hs = $scope.hs = crmUiHelp({file: 'CRM/mjwshared/PaymentprocessorWebhook'}); // See: templates/CRM/mjwshared/PaymentprocessorWebhook.hlp
// Local variable for this controller (needed when inside a callback fn where `this` is not available). // Local variable for this controller (needed when inside a callback fn where `this` is not available).
var ctrl = this; var ctrl = this;
this.processors = processors;
this.events = []; this.events = [];
this.statusFilter = ''; this.statusFilter = '';
this.processorFilter = '';
this.eventFilter = ''; this.eventFilter = '';
this.paymentProcessor = []; this.paymentProcessor = [];
this.offset = 0; this.offset = 0;
...@@ -55,6 +67,9 @@ ...@@ -55,6 +67,9 @@
if (ctrl.statusFilter) { if (ctrl.statusFilter) {
params.where.push(['status', '=', ctrl.statusFilter]); params.where.push(['status', '=', ctrl.statusFilter]);
} }
if (ctrl.processorFilter) {
params.where.push(['payment_processor_id', '=', ctrl.processorFilter]);
}
if (ctrl.eventFilter) { if (ctrl.eventFilter) {
params.where.push(['event_id', 'LIKE', '%' + ctrl.eventFilter + '%']); params.where.push(['event_id', 'LIKE', '%' + ctrl.eventFilter + '%']);
} }
...@@ -83,7 +98,7 @@ ...@@ -83,7 +98,7 @@
this.changePage = function(dir) { this.changePage = function(dir) {
let newOffset = Math.min(Math.max(ctrl.offset + dir*ctrl.limit, 0), ctrl.resultsCount - 1); let newOffset = Math.min(Math.max(ctrl.offset + dir*ctrl.limit, 0), ctrl.resultsCount - 1);
console.log({newOffset, o: ctrl.offset, dir}); // console.log({newOffset, o: ctrl.offset, dir});
if (newOffset != ctrl.offset) { if (newOffset != ctrl.offset) {
ctrl.offset = newOffset; ctrl.offset = newOffset;
ctrl.load(); ctrl.load();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment