Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue26: Various cast selection bugs #49

Merged
merged 4 commits into from
Nov 28, 2023
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
3 changes: 2 additions & 1 deletion Desktop/Converters/SparseCountByGroups.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Carmen.Desktop.ViewModels;
using Carmen.ShowModel.Applicants;
using Carmen.ShowModel.Structure;
using Carmen.ShowModel;
using System;
using System.Collections;
using System.Collections.Generic;
Expand All @@ -25,7 +26,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
if (parameter is not CollectionViewSource view_source)
throw new ApplicationException("ConverterParameter must be a CollectionViewSource representing the CastGroups.");
if (value is ObservableCollection<CountByGroup> collection && view_source.Source is IList list)
return list.OfType<CastGroup>().Select(g => new NullableCountByGroup(collection, g)).ToList();
return list.OfType<CastGroup>().InOrder().Select(g => new NullableCountByGroup(collection, g)).ToList();
return value;
}

Expand Down
20 changes: 13 additions & 7 deletions Desktop/Pages/SelectCast.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private async void selectCastButton_Click(object sender, RoutedEventArgs e)
};
if (dialog.ShowDialog() != true)
return;
ClearMainPanel();
using var processing = new LoadingOverlay(this).AsSegment(nameof(selectCastButton_Click), "Processing...");
using (processing.Segment(nameof(ISelectionEngine.SelectCastGroups), "Selecting applicants"))
{
Expand Down Expand Up @@ -527,6 +528,12 @@ private static void RemoveFromSameCastSet(SameCastSet set, Applicant[] applicant
}
}

private void ClearMainPanel()
{
selectionList.SelectedItem = null;
RefreshMainPanel();
}

private void selectionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (suitabilityComparer != null)
Expand Down Expand Up @@ -749,7 +756,7 @@ private void SortBySuitability(CollectionViewSource collection)
if (collection.View is ListCollectionView view)
view.CustomSort = suitabilityComparer;
}

private void GroupByCastGroupCheckbox_Changed(object sender, RoutedEventArgs e)
{
if (selectionList?.SelectedItem != null)
Expand Down Expand Up @@ -778,13 +785,12 @@ public int Compare(object? x, object? y)
// sort by cast group (if grouping)
if (GroupByCastGroup)
{
if (a1.CastGroup is not CastGroup cg1)
return int.MinValue;
if (a2.CastGroup is not CastGroup cg2)
return int.MaxValue;
if (cg1.Order > cg2.Order)
// Note: if CastGroup.Order somehow gets set to int.MinValue, it will be considered the same ordering as no cast group
var cg1 = a1.CastGroup?.Order ?? int.MinValue;
var cg2 = a2.CastGroup?.Order ?? int.MinValue;
if (cg1 > cg2)
return 1;
if (cg1.Order < cg2.Order)
if (cg1 < cg2)
return -1;
}
// sort by suitability
Expand Down
2 changes: 1 addition & 1 deletion Desktop/ViewModels/ApplicantForSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ApplicantForSelection : ISelectableApplicant, INotifyPropertyChange
public bool IsSelected
{
get => true; // so that colour images are shown
set => throw new InvalidOperationException();
set { }
}

public string FirstName => Applicant.FirstName;
Expand Down