Updated frontend to access the 'test-rules' functionality

This commit is contained in:
Robert Horlings
2016-02-17 12:11:00 +01:00
parent c8c69f1a66
commit 5dc556f0af
6 changed files with 52 additions and 1 deletions

View File

@@ -82,4 +82,33 @@ function removeAction(e) {
if($('.rule-action-tbody tr').length == 0) {
addNewAction();
}
}
function testRuleTriggers() {
"use strict";
// Serialize all trigger data
var triggerData = $( ".rule-trigger-tbody" ).find( "input[type=text], input[type=checkbox], select" ).serializeArray();
// Find a list of existing transactions that match these triggers
$.get('rules/rules/test_triggers', triggerData).done(function (data) {
var modal = $( "#testTriggerModal" );
var numTriggers = $( ".rule-trigger-body > tr" ).length;
// Set title and body
modal.find( ".transactions-list" ).html(data.html);
// Show warning if appropriate
if( data.warning ) {
modal.find( ".transaction-warning .warning-contents" ).text(data.warning);
modal.find( ".transaction-warning" ).show();
} else {
modal.find( ".transaction-warning" ).hide();
}
// Show the modal dialog
$( "#testTriggerModal" ).modal();
}).fail(function () {
alert('Cannot get transactions for given triggers.');
});
}