Smaller rule list

This commit is contained in:
James Cole 2023-12-25 06:32:43 +01:00
parent b84604a4db
commit 4723d9dd30
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
5 changed files with 49 additions and 8 deletions

View File

@ -133,7 +133,7 @@ class ApplyRules extends Command
// start running rules.
$this->friendlyLine(sprintf('Will apply %d rule(s) to your transaction(s).', $count));
// file the rule(s)
// fire the rule(s)
$ruleEngine->fire();
$this->friendlyLine('');

View File

@ -100,8 +100,16 @@ class SearchRuleEngine implements RuleEngineInterface
// if rules and no rule groups, file each rule separately.
if (0 !== $this->rules->count()) {
app('log')->debug(sprintf('SearchRuleEngine:: found %d rule(s) to fire.', $this->rules->count()));
/** @var Rule $rule */
foreach ($this->rules as $rule) {
$this->fireRule($rule);
$result = $this->fireRule($rule);
if (true === $result && $rule->stop_processing) {
app('log')->debug(sprintf('Rule #%d has triggered and executed, but calls to stop processing. Since not in the context of a group, do not stop.', $rule->id));
}
if (false === $result && $rule->stop_processing) {
app('log')->debug(sprintf('Rule #%d has triggered and changed nothing, but calls to stop processing. Do not stop.', $rule->id));
}
}
app('log')->debug('SearchRuleEngine:: done processing all rules!');

View File

@ -97,6 +97,35 @@ $(function () {
}
);
// show rule triggers
$('.rule-triggers-show').click(function (e) {
var obj = $(e.currentTarget);
$('.rule-trigger-list[data-id="' + obj.data('id') + '"]').show();
$('.rule-triggers-show[data-id="' + obj.data('id') + '"]').hide();
});
$('.rule-trigger-list').each(function(i,v) {
var obj = $(v);
if(obj.data('count') > 2) {
obj.hide();
$('.rule-triggers-show[data-id="' + obj.data('id') + '"]').show();
}
});
// show rule actions
$('.rule-actions-show').click(function (e) {
var obj = $(e.currentTarget);
$('.rule-action-list[data-id="' + obj.data('id') + '"]').show();
$('.rule-actions-show[data-id="' + obj.data('id') + '"]').hide();
});
$('.rule-action-list').each(function(i,v) {
var obj = $(v);
if(obj.data('count') > 1) {
obj.hide();
$('.rule-actions-show[data-id="' + obj.data('id') + '"]').show();
}
});
$('.move-group').click(moveRuleGroup);
$('.duplicate-rule').click(duplicateRule);

View File

@ -721,6 +721,8 @@ return [
// rules
'is_not_rule_trigger' => 'Not',
'cannot_fire_inactive_rules' => 'You cannot execute inactive rules.',
'show_triggers' => 'Show triggers',
'show_actions' => 'Show actions',
'rules' => 'Rules',
'rule_name' => 'Name of rule',
'rule_triggers' => 'Rule triggers when',

View File

@ -125,11 +125,11 @@
{% endif %}
><br/>{{ rule.description|default('')|markdown }}</small>
{% endif %}
<small><br/>{% if rule.strict %}<span class="text-danger">{{ 'rule_is_strict'|_ }}</span>{% else %}<span class="text-success">{{ 'rule_is_not_strict'|_ }}</span>{% endif %}</small>
<small>({% if rule.strict %}<span class="text-danger">{{ 'rule_is_strict'|_ }}</span>{% else %}<span class="text-success">{{ 'rule_is_not_strict'|_ }}</span>{% endif %})</small>
</td>
<td class="hidden-xs">
{% if rule.ruleTriggers.count() > 0 %}
<ul class="small" data-id="{{ rule.id }}">
<ul class="small rule-trigger-list" data-count="{{ rule.ruleTriggers.count() }}" data-id="{{ rule.id }}">
{% for trigger in rule.ruleTriggers %}
{% if trigger.trigger_type != "user_action" %}
<li
@ -146,11 +146,12 @@
{% endif %}
{% endfor %}
</ul>
<span class="small rule-triggers-show" style="cursor:pointer;display:none;" data-id="{{ rule.id }}">{{ 'show_triggers'|_ }}</span>
{% endif %}
</td>
<td class="hidden-xs">
{% if rule.ruleActions.count() > 0 %}
<ul class="small" data-id="{{ rule.id }}">
<ul class="small rule-action-list" data-count="{{ rule.ruleActions.count() }}" data-id="{{ rule.id }}">
{% for action in rule.ruleActions %}
<li
{% if not rule.active %}
@ -163,6 +164,7 @@
</li>
{% endfor %}
</ul>
<span class="small rule-actions-show" style="cursor:pointer;display:none;" data-id="{{ rule.id }}">{{ 'show_actions'|_ }}</span>
{% endif %}
</td>
</tr>