mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 00:27:30 +00:00
Re-order rule groups.
This commit is contained in:
@@ -175,4 +175,44 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @return bool
|
||||
*/
|
||||
public function moveRuleGroupUp(RuleGroup $ruleGroup)
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = Auth::user()->ruleGroups()->where('order', ($order - 1))->first();
|
||||
if ($other) {
|
||||
$other->order = ($other->order + 1);
|
||||
$other->save();
|
||||
}
|
||||
|
||||
$ruleGroup->order = ($ruleGroup->order - 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @return bool
|
||||
*/
|
||||
public function moveRuleGroupDown(RuleGroup $ruleGroup)
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order+1 and give it order-1
|
||||
$other = Auth::user()->ruleGroups()->where('order', ($order + 1))->first();
|
||||
if ($other) {
|
||||
$other->order = ($other->order - 1);
|
||||
$other->save();
|
||||
}
|
||||
|
||||
$ruleGroup->order = ($ruleGroup->order + 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
}
|
@@ -70,4 +70,16 @@ interface RuleRepositoryInterface
|
||||
*/
|
||||
public function moveRuleDown(Rule $rule);
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @return bool
|
||||
*/
|
||||
public function moveRuleGroupUp(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
* @return bool
|
||||
*/
|
||||
public function moveRuleGroupDown(RuleGroup $ruleGroup);
|
||||
|
||||
}
|
Reference in New Issue
Block a user