Skip to content

Commit

Permalink
Rework warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAxelander committed Mar 14, 2024
1 parent dc99790 commit dbf40f1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
8 changes: 4 additions & 4 deletions OpenBudgeteer.Blazor/Shared/EditBucketDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="col-12 col-sm-6 mb-2">
<label class="form-label">Bucket Group:</label>
<select class="form-select form-select-sm"
@bind:get="DataContext.SelectedBucketGroup.Id.ToString()"
@bind:get="DataContext.SelectedBucketGroup!.Id.ToString()"
@bind:set="BucketGroup_SelectionChanged">
@foreach (var bucketGroup in DataContext.AvailableBucketGroups!)
{
Expand Down Expand Up @@ -75,7 +75,7 @@
<label class="form-label">Background Color:</label>
<select class="form-select form-select-sm" style="background-color: @ColorTranslator.ToHtml(DataContext.Color); color: @ColorTranslator.ToHtml(DataContext.TextColor)"
@bind:get="DataContext.ColorCode"
@bind:set="(value) => { DataContext.ColorCode = value; }">
@bind:set="(value) => { DataContext.ColorCode = value!; }">
@foreach (var color in DataContext.AvailableColors!)
{
<option style="background-color: @ColorTranslator.ToHtml(color); color: @ColorTranslator.ToHtml(DataContext.TextColor)" value="@color.Name">@color.Name</option>
Expand All @@ -86,7 +86,7 @@
<label class="form-label">Text Color:</label>
<select class="form-select form-select-sm" style="background-color: @ColorTranslator.ToHtml(DataContext.Color); color: @ColorTranslator.ToHtml(DataContext.TextColor)"
@bind:get="DataContext.TextColorCode"
@bind:set="(value) => { DataContext.TextColorCode = value; }">
@bind:set="(value) => { DataContext.TextColorCode = value!; }">
@foreach (var color in DataContext.AvailableColors!)
{
<option style="background-color: @ColorTranslator.ToHtml(DataContext.Color); color: @ColorTranslator.ToHtml(color)" value="@color.Name">@color.Name</option>
Expand Down Expand Up @@ -177,6 +177,6 @@
void BucketGroup_SelectionChanged(string? value)
{
if (string.IsNullOrEmpty(value)) return;
DataContext.SelectedBucketGroup = DataContext.AvailableBucketGroups.First(i => i.Id == Guid.Parse(value));
DataContext.SelectedBucketGroup = DataContext.AvailableBucketGroups!.First(i => i.Id == Guid.Parse(value));
}
}
28 changes: 17 additions & 11 deletions OpenBudgeteer.Core/ViewModels/EntityViewModels/BucketViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public BucketVersionViewModel BucketVersion
set => Set(ref _bucketVersion, value);
}

private BucketGroup _selectedBucketGroup;
private BucketGroup? _selectedBucketGroup;
/// <summary>
/// <see cref="BucketGroup"/> to which this Bucket is assigned to
/// </summary>
public BucketGroup SelectedBucketGroup
public BucketGroup? SelectedBucketGroup
{
get => _selectedBucketGroup;
set => Set(ref _selectedBucketGroup, value);
Expand Down Expand Up @@ -319,18 +319,24 @@ protected BucketViewModel(BucketViewModel viewModel) : base(viewModel.ServiceMan
_isProgressBarVisible = viewModel.IsProgressbarVisible;
_isHovered = viewModel.IsHovered;

AvailableColors = new ObservableCollection<Color>();
foreach (var availableColor in viewModel.AvailableColors)
if (viewModel.AvailableColors != null)
{
AvailableColors.Add(availableColor);
AvailableColors = new ObservableCollection<Color>();
foreach (var availableColor in viewModel.AvailableColors)
{
AvailableColors.Add(availableColor);
}
}

AvailableBucketGroups = new ObservableCollection<BucketGroup>();
foreach (var item in viewModel.AvailableBucketGroups)

if (viewModel.AvailableBucketGroups != null)
{
AvailableBucketGroups.Add(item);
AvailableBucketGroups = new ObservableCollection<BucketGroup>();
foreach (var item in viewModel.AvailableBucketGroups)
{
AvailableBucketGroups.Add(item);
}
}

_currentYearMonth = viewModel._currentYearMonth;
}

Expand Down Expand Up @@ -550,7 +556,7 @@ internal override Bucket ConvertToDto()
{
Id = BucketId,
Name = Name,
BucketGroupId = SelectedBucketGroup.Id,
BucketGroupId = SelectedBucketGroup!.Id,
ColorCode = ColorCode,
TextColorCode = TextColorCode,
ValidFrom = ValidFrom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public PartialBucketViewModel(PartialBucketViewModel viewModel) : base(viewModel
_selectedBucketName = viewModel.SelectedBucketName;
_selectedBucketColorCode = viewModel.SelectedBucketColorCode;
_selectedBucketTextColorCode = viewModel.SelectedBucketTextColorCode;
_selectedBucketOutput = viewModel.SelectedBucketOutput;
_amount = viewModel.Amount;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ public void StartModification()

public void CancelModification()
{
if (_oldTransactionViewModelItem == null) return;

SelectedAccount = _oldTransactionViewModelItem.SelectedAccount;
TransactionDate = _oldTransactionViewModelItem.TransactionDate;
Payee = _oldTransactionViewModelItem.Payee;
Expand Down

0 comments on commit dbf40f1

Please sign in to comment.