Skip to content

Commit

Permalink
Fix #282
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAxelander committed Jan 11, 2025
1 parent ee83f98 commit 2812b74
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.9.1 (2025-01-09)

### :beetle: Bug Fixes

* Unable to move a Bucket Group [#282](https://github.com/TheAxelander/OpenBudgeteer/issues/282)

## 1.9 (2025-01-04)

### :gear: Features & Enhancements
Expand Down
2 changes: 1 addition & 1 deletion OpenBudgeteer.Blazor/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</button>
<span class="navbar-brand flex-fill ms-2 fs-5">OpenBudgeteer</span>
<span class="navbar-text ms-3 d-none d-md-block">Database: @CurrentDatabase</span>
<span class="navbar-text ms-3 d-none d-md-block">Version: 1.9.0 (<a href="https://github.com/TheAxelander/OpenBudgeteer/blob/master/CHANGELOG.md" target="_blank">Change Log</a>)</span>
<span class="navbar-text ms-3 d-none d-md-block">Version: 1.9.1 (<a href="https://github.com/TheAxelander/OpenBudgeteer/blob/master/CHANGELOG.md" target="_blank">Change Log</a>)</span>
</div>
</header>
<div class="container-fluid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,33 @@ public override void Delete(Guid id)

public BucketGroup Move(Guid bucketGroupId, int positions)
{
var bucketGroup = Get(bucketGroupId);
if (positions == 0) return bucketGroup;

// Create in an interim List for later use
// Create in an interim list to handle position updates
var existingBucketGroups = new ObservableCollection<BucketGroup>();
foreach (var group in GetAll().ToList())
{
existingBucketGroups.Add(group);
}

// Re-use existing reference in interim list of passed Bucket Group (see #282)
var bucketGroup = existingBucketGroups.First(i => i.Id == bucketGroupId);
if (positions == 0) return bucketGroup;

// Calculate new target position
var bucketGroupCount = existingBucketGroups.Count();
var targetPosition = bucketGroup.Position + positions;
if (targetPosition < 1) targetPosition = 1;
if (targetPosition > bucketGroupCount) targetPosition = bucketGroupCount;
if (targetPosition == bucketGroup.Position) return bucketGroup; // Group is already at the end or top. No further action

// Move Group in interim List
// Move Group in interim list
existingBucketGroups.Move(bucketGroup.Position - 1, targetPosition - 1);

// Update Position number
// Update Position number for each group
var newPosition = 1;
foreach (var group in existingBucketGroups)
{
group.Position = newPosition;
_bucketGroupRepository.Update(group);
if (group.Id == bucketGroupId) bucketGroup = group; // Use correct object reference for final return
newPosition++;
}

Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

| Version | Supported |
|-------------| ------------------ |
| 1.9 | :white_check_mark: |
| 1.9.1 | :white_check_mark: |
| pre-release | :white_check_mark: |
| < 1.9 | :x: |
| < 1.9.1 | :x: |

## Reporting a Vulnerability

Expand Down

0 comments on commit 2812b74

Please sign in to comment.