mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-26 02:40:43 -06:00
Fix https://github.com/firefly-iii/firefly-iii/issues/8291 AND fix issue with non-strict rule triggers AND fix behaviour of actions
This commit is contained in:
parent
2b90c20db8
commit
1bd1a9cba3
13
.ci/php-cs-fixer/composer.lock
generated
13
.ci/php-cs-fixer/composer.lock
generated
@ -226,16 +226,16 @@
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.41.1",
|
||||
"version": "v3.42.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6"
|
||||
"reference": "632ef1be3447a9b890bef06147475facee535d0f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8b6ae8dcbaf23f09680643ab832a4a3a260265f6",
|
||||
"reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/632ef1be3447a9b890bef06147475facee535d0f",
|
||||
"reference": "632ef1be3447a9b890bef06147475facee535d0f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -266,7 +266,6 @@
|
||||
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
|
||||
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"symfony/phpunit-bridge": "^6.3.8 || ^7.0",
|
||||
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
@ -305,7 +304,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.1"
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.42.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -313,7 +312,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-12-10T19:59:27+00:00"
|
||||
"time": "2023-12-24T14:38:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
|
@ -680,10 +680,11 @@ trait MetaCollection
|
||||
|
||||
// this method adds a "postFilter" to the collector.
|
||||
$list = $tags->pluck('tag')->toArray();
|
||||
$list = array_map('strtolower', $list);
|
||||
$filter = static function (array $object) use ($list): bool {
|
||||
Log::debug(sprintf('Now in setTags(%s) filter', implode(', ', $list)));
|
||||
$expectedTagCount = count($list);
|
||||
$foundTagCount = 0;
|
||||
$foundTagCount = 0;
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
$transactionTagCount = count($transaction['tags']);
|
||||
app('log')->debug(sprintf('Transaction has %d tag(s)', $transactionTagCount));
|
||||
@ -719,6 +720,7 @@ trait MetaCollection
|
||||
|
||||
// this method adds a "postFilter" to the collector.
|
||||
$list = $tags->pluck('tag')->toArray();
|
||||
$list = array_map('strtolower', $list);
|
||||
$filter = static function (array $object) use ($list): bool {
|
||||
Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list)));
|
||||
foreach ($object['transactions'] as $transaction) {
|
||||
|
@ -325,6 +325,12 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
$total = $total->merge($collection);
|
||||
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
|
||||
++$count;
|
||||
// if trigger says stop processing, do so.
|
||||
if($ruleTrigger->stop_processing && $collection->count() > 0) {
|
||||
app('log')->debug('The trigger says to stop processing, so stop processing other triggers.');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
|
||||
app('log')->debug(sprintf('Done running %d trigger(s)', $count));
|
||||
@ -465,11 +471,14 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
}
|
||||
|
||||
// pick up from the action if it actually acted or not:
|
||||
if ($ruleAction->stop_processing) {
|
||||
app('log')->debug(sprintf('Rule action "%s" asks to break, so break!', $ruleAction->action_type));
|
||||
if ($ruleAction->stop_processing && true === $result) {
|
||||
app('log')->debug(sprintf('Rule action "%s" reports changes AND asks to break, so break!', $ruleAction->action_type));
|
||||
|
||||
return true;
|
||||
}
|
||||
if ($ruleAction->stop_processing && false === $result) {
|
||||
app('log')->debug(sprintf('Rule action "%s" reports NO changes AND asks to break, but we wont break!', $ruleAction->action_type));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -41,14 +41,26 @@ $(function () {
|
||||
console.log('action count is zero, add action.');
|
||||
addNewAction();
|
||||
}
|
||||
|
||||
makeRuleStrict();
|
||||
$('.add_rule_trigger').click(addNewTrigger);
|
||||
$('.add_rule_action').click(addNewAction);
|
||||
$('#ffInput_strict').change(makeRuleStrict);
|
||||
$('.test_rule_triggers').click(testRuleTriggers);
|
||||
$('.remove-trigger').unbind('click').click(removeTrigger);
|
||||
$('.remove-action').unbind('click').click(removeAction);
|
||||
});
|
||||
|
||||
function makeRuleStrict() {
|
||||
var value = $('#ffInput_strict').is(':checked');
|
||||
if(value) {
|
||||
// is checked, stop processing triggers is not relevant.
|
||||
$('.trigger-stop-processing').prop('checked', false);
|
||||
$('.trigger-stop-processing').prop('disabled', true);
|
||||
return;
|
||||
}
|
||||
$('.trigger-stop-processing').prop('disabled', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method triggers when a new trigger must be added to the form.
|
||||
*/
|
||||
@ -181,6 +193,7 @@ function onAddNewAction() {
|
||||
console.log('Trigger updateActionInput() for select ' + select);
|
||||
updateActionInput(select);
|
||||
});
|
||||
makeRuleStrict();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,6 +220,7 @@ function onAddNewTrigger() {
|
||||
console.log('Trigger updateTriggerInput() for select ' + select);
|
||||
updateTriggerInput(select);
|
||||
});
|
||||
makeRuleStrict();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@
|
||||
<td style="width:20%;">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="triggers[{{ count }}][stop_processing]" value="1"
|
||||
<input type="checkbox" class="trigger-stop-processing" name="triggers[{{ count }}][stop_processing]" value="1"
|
||||
{% if oldChecked %}checked{% endif %}
|
||||
/>
|
||||
</label>
|
||||
|
Loading…
Reference in New Issue
Block a user