Skip to content

Firefly III: a personal finances manager

Reset rule order on index. #3376

James Cole4ebb6de52079
diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.php
index 0233337bc4..0ed7cfa29c 100644
--- a/app/Http/Controllers/Rule/IndexController.php
+++ b/app/Http/Controllers/Rule/IndexController.php
@@ -91,6 +91,7 @@ class IndexController extends Controller
$user = auth()->user();
$this->createDefaultRuleGroup();
$this->createDefaultRule();
+ $this->ruleGroupRepos->resetRuleGroupOrder();
$ruleGroups = $this->ruleGroupRepos->getRuleGroupsWithRules($user);
return view('rules.index', compact('ruleGroups'));
diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php
index 70da98cd32..a7bca56d6c 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepository.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php
@@ -56,7 +56,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
}
/**
- * @param RuleGroup $ruleGroup
+ * @param RuleGroup $ruleGroup
* @param RuleGroup|null $moveTo
*
* @return bool
@@ -98,6 +98,10 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
foreach ($set as $entry) {
$entry->order = $count;
$entry->save();
+
+ // also update rules in group.
+ $this->resetRulesInGroupOrder($entry);
+
++$count;
}
@@ -114,6 +118,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$ruleGroup->rules()->whereNotNull('deleted_at')->update(['order' => 0]);
$set = $ruleGroup->rules()
+ ->orderBy('active','DESC')
->orderBy('order', 'ASC')
->orderBy('updated_at', 'DESC')
->get();
@@ -328,7 +333,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/**
* @param RuleGroup $ruleGroup
- * @param array $data
+ * @param array $data
*
* @return RuleGroup
*/
@@ -353,4 +358,5 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
{
return $this->user->ruleGroups()->where('title', $title)->first();
}
-}
+
+}
\ No newline at end of file