mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 03:08:11 +00:00
Updated frontend to access the 'test-rules' functionality
This commit is contained in:
@@ -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.');
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user