mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
User can now re-order triggers and actions.
This commit is contained in:
@@ -12,6 +12,7 @@ namespace FireflyIII\Repositories\Rule;
|
||||
use Auth;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
@@ -76,6 +77,48 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
return $ruleGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $ids
|
||||
* @return bool
|
||||
*/
|
||||
public function reorderRuleTriggers(Rule $rule, array $ids)
|
||||
{
|
||||
$order = 1;
|
||||
foreach ($ids as $triggerId) {
|
||||
/** @var RuleTrigger $trigger */
|
||||
$trigger = $rule->ruleTriggers()->find($triggerId);
|
||||
if (!is_null($trigger)) {
|
||||
$trigger->order = $order;
|
||||
$trigger->save();
|
||||
$order++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $ids
|
||||
* @return bool
|
||||
*/
|
||||
public function reorderRuleActions(Rule $rule, array $ids)
|
||||
{
|
||||
$order = 1;
|
||||
foreach ($ids as $actionId) {
|
||||
/** @var RuleTrigger $trigger */
|
||||
$action = $rule->ruleActions()->find($actionId);
|
||||
if (!is_null($action)) {
|
||||
$action->order = $order;
|
||||
$action->save();
|
||||
$order++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @param RuleGroup $moveTo
|
||||
|
@@ -50,6 +50,20 @@ interface RuleRepositoryInterface
|
||||
*/
|
||||
public function destroyRuleGroup(RuleGroup $ruleGroup, RuleGroup $moveTo = null);
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $ids
|
||||
* @return bool
|
||||
*/
|
||||
public function reorderRuleTriggers(Rule $rule, array $ids);
|
||||
|
||||
/**
|
||||
* @param Rule $rule
|
||||
* @param array $ids
|
||||
* @return bool
|
||||
*/
|
||||
public function reorderRuleActions(Rule $rule, array $ids);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
Reference in New Issue
Block a user