Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions 10.0/Apps/DeveloperBalance/PageModels/ProjectDetailPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,30 @@ private async Task SelectionChanged(object parameter)
{
if (parameter is IEnumerable<object> enumerableParameter)
{
var changed = enumerableParameter.OfType<Tag>().ToList();
var currentSelection = enumerableParameter.OfType<Tag>().ToList();
var previousSelection = AllTags.Where(t => t.IsSelected).ToList();

if (changed.Count == 0 && SelectedTags is not null)
changed = SelectedTags.OfType<Tag>().Except(enumerableParameter.OfType<Tag>()).ToList();
// Handle newly selected tags
foreach (var tag in currentSelection.Except(previousSelection))
{
tag.IsSelected = true;
if (!_project.IsNullOrNew())
{
await _tagRepository.SaveItemAsync(tag, _project.ID);
}
}

// Handle deselected tags
foreach (var tag in previousSelection.Except(currentSelection))
{
tag.IsSelected = false;
if (!_project.IsNullOrNew())
{
await _tagRepository.DeleteItemAsync(tag, _project.ID);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to update SelectedTags to reflect current selection?

SelectedTags = new List<object>(currentSelection);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz Yes, I have updated the SelectedTags in SelectionChanged as suggested, it now reflects the current selection immediately when tags are selected.


if (changed.Count == 1)
await ToggleTag(changed[0]);
SelectedTags = new List<object>(currentSelection);
}
}
}
27 changes: 22 additions & 5 deletions 9.0/Apps/DeveloperBalance/PageModels/ProjectDetailPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,30 @@ private async Task SelectionChanged(object parameter)
{
if (parameter is IEnumerable<object> enumerableParameter)
{
var changed = enumerableParameter.OfType<Tag>().ToList();
var currentSelection = enumerableParameter.OfType<Tag>().ToList();
var previousSelection = AllTags.Where(t => t.IsSelected).ToList();

if (changed.Count == 0 && SelectedTags is not null)
changed = SelectedTags.OfType<Tag>().Except(enumerableParameter.OfType<Tag>()).ToList();
// Handle newly selected tags
foreach (var tag in currentSelection.Except(previousSelection))
{
tag.IsSelected = true;
if (!_project.IsNullOrNew())
{
await _tagRepository.SaveItemAsync(tag, _project.ID);
}
}

// Handle deselected tags
foreach (var tag in previousSelection.Except(currentSelection))
{
tag.IsSelected = false;
if (!_project.IsNullOrNew())
{
await _tagRepository.DeleteItemAsync(tag, _project.ID);
}
}

if (changed.Count == 1)
await ToggleTag(changed[0]);
SelectedTags = new List<object>(currentSelection);
}
}
}
Loading