diff --git a/Desktop/Converters/CollapsedIfNull.cs b/Desktop/Converters/CollapsedIfNull.cs
new file mode 100644
index 00000000..e146399d
--- /dev/null
+++ b/Desktop/Converters/CollapsedIfNull.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Carmen.Desktop.Converters
+{
+ ///
+ /// Convert an object value to a Visibility based on whether or not it is null.
+ /// If ConverterParameter is set to a type, then the value must be this type to be considered not null.
+ ///
+ public class CollapsedIfNull : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null)
+ return Visibility.Collapsed;
+ if (parameter is Type type && !(value.GetType() == type || value.GetType().IsSubclassOf(type)))
+ return Visibility.Collapsed;
+ return Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ => throw new NotImplementedException();
+ }
+}
diff --git a/Desktop/Converters/HideIfNull.cs b/Desktop/Converters/HideIfNull.cs
index 014b3435..ae27aa47 100644
--- a/Desktop/Converters/HideIfNull.cs
+++ b/Desktop/Converters/HideIfNull.cs
@@ -18,9 +18,9 @@ public class HideIfNull : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
- return Visibility.Hidden;
+ return Visibility.Collapsed;
if (parameter is Type type && !(value.GetType() == type || value.GetType().IsSubclassOf(type)))
- return Visibility.Hidden;
+ return Visibility.Collapsed;
return Visibility.Visible;
}
diff --git a/Desktop/Pages/SelectCast.xaml.cs b/Desktop/Pages/SelectCast.xaml.cs
index 57e5d167..be5b9cf2 100644
--- a/Desktop/Pages/SelectCast.xaml.cs
+++ b/Desktop/Pages/SelectCast.xaml.cs
@@ -441,38 +441,16 @@ private async Task RemoveFromList(IList list, Applicant[] applicants)
private void List_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
- //TODO changing the selection status via >/>>/<< doesn't update details window
var list_box = (ListBox)sender;
- if (list_box.SelectedItem is not Applicant applicant)
- return;
- if (selectionList.SelectedItem is CastGroup cg)
- {
- ShowDetailsWindow(new ApplicantForCastGroup(applicant, criterias, cg));
- e.Handled = true;
- }
- else if (selectionList.SelectedItem is AlternativeCast ac)
+ if (list_box.SelectedItem is Applicant applicant)
{
- ShowDetailsWindow(new ApplicantForAlternativeCast(applicant, criterias, ac));
- e.Handled = true;
- }
- else if (selectionList.SelectedItem is Tag tag)
- {
- ShowDetailsWindow(new ApplicantForTag(applicant, criterias, tag));
+ ShowDetailsWindow(new ApplicantForSelection(applicant, criterias));
e.Handled = true;
}
}
Dictionary detailsWindows = new();
- void CloseDetailsWindows()
- {
- foreach (var window in detailsWindows.Values)
- {
- window.Close();
- }
- detailsWindows.Clear();
- }
-
void ShowDetailsWindow(ApplicantForSelection afs)
{
if (!detailsWindows.TryGetValue(afs.Applicant, out var window) || window.IsClosed)
@@ -491,7 +469,11 @@ void ShowDetailsWindow(ApplicantForSelection afs)
protected override void DisposeInternal()
{
- CloseDetailsWindows();
+ foreach (var window in detailsWindows.Values)
+ {
+ window.Close();
+ }
+ detailsWindows.Clear();
base.DisposeInternal();
}
@@ -549,7 +531,6 @@ private void selectionList_SelectionChanged(object sender, SelectionChangedEvent
{
if (suitabilityComparer != null)
suitabilityComparer.SelectedCastGroupOrTag = selectionList.SelectedItem;
- CloseDetailsWindows();
RefreshMainPanel();
}
diff --git a/Desktop/ViewModels/ApplicantForAlternativeCast.cs b/Desktop/ViewModels/ApplicantForAlternativeCast.cs
deleted file mode 100644
index 88035fc1..00000000
--- a/Desktop/ViewModels/ApplicantForAlternativeCast.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Carmen.ShowModel.Applicants;
-using Carmen.ShowModel.Criterias;
-using Carmen.ShowModel.Structure;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Carmen.Desktop.ViewModels
-{
- internal class ApplicantForAlternativeCast : ApplicantForSelection
- {
- readonly AlternativeCast alternativeCast;
-
- public override string SelectionText => $"Assign {FirstName} to {alternativeCast.Name}";
-
- public override bool IsSelected
- {
- get => alternativeCast.Members.Contains(Applicant);
- set
- {
- if (value)
- {
- if (!alternativeCast.Members.Contains(Applicant))
- {
- Applicant.AlternativeCast = alternativeCast;
- alternativeCast.Members.Add(Applicant);
- }
- }
- else
- {
- if (alternativeCast.Members.Contains(Applicant))
- {
- Applicant.AlternativeCast = null;
- alternativeCast.Members.Remove(Applicant);
- }
- }
- OnPropertyChanged();
- }
- }
-
- public ApplicantForAlternativeCast(Applicant applicant, Criteria[] criterias, AlternativeCast alternative_cast)
- : base(applicant, criterias)
- {
- alternativeCast = alternative_cast;
- }
- }
-}
diff --git a/Desktop/ViewModels/ApplicantForCastGroup.cs b/Desktop/ViewModels/ApplicantForCastGroup.cs
deleted file mode 100644
index cb346ec2..00000000
--- a/Desktop/ViewModels/ApplicantForCastGroup.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Carmen.ShowModel.Applicants;
-using Carmen.ShowModel.Criterias;
-using Carmen.ShowModel.Structure;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Carmen.Desktop.ViewModels
-{
- internal class ApplicantForCastGroup : ApplicantForSelection
- {
- readonly CastGroup castGroup;
-
- public override string SelectionText => $"Select {FirstName} into {castGroup.Name}";
-
- public override bool IsSelected
- {
- get => castGroup.Members.Contains(Applicant);
- set
- {
- if (value)
- {
- if (!castGroup.Members.Contains(Applicant))
- {
- Applicant.CastGroup = castGroup;
- castGroup.Members.Add(Applicant);
- }
- }
- else
- {
- if (castGroup.Members.Contains(Applicant))
- {
- Applicant.CastGroup = null;
- castGroup.Members.Remove(Applicant);
- }
- }
- OnPropertyChanged();
- }
- }
-
- public ApplicantForCastGroup(Applicant applicant, Criteria[] criterias, CastGroup cast_group)
- : base(applicant, criterias)
- {
- castGroup = cast_group;
- }
- }
-}
diff --git a/Desktop/ViewModels/ApplicantForRole.cs b/Desktop/ViewModels/ApplicantForRole.cs
index 406eecd1..4b4eed93 100644
--- a/Desktop/ViewModels/ApplicantForRole.cs
+++ b/Desktop/ViewModels/ApplicantForRole.cs
@@ -97,7 +97,7 @@ public IEnumerable UnavailabilityReasons
public string CommaSeparatedIneligibilityReason => string.Join(", ", IneligibilityReasons);
- public string SelectionText => $"Allocate {RoleName} to {FirstName}";
+ public string? SelectionText => $"Allocate {RoleName} to {FirstName}";
public ApplicantForRole(IAllocationEngine engine, Applicant applicant, Role role, Criteria[] primary_criterias)
{
diff --git a/Desktop/ViewModels/ApplicantForSelection.cs b/Desktop/ViewModels/ApplicantForSelection.cs
index cb6c8e5c..793b6c72 100644
--- a/Desktop/ViewModels/ApplicantForSelection.cs
+++ b/Desktop/ViewModels/ApplicantForSelection.cs
@@ -13,23 +13,27 @@
namespace Carmen.Desktop.ViewModels
{
- public abstract class ApplicantForSelection : ISelectableApplicant, INotifyPropertyChanged
+ public class ApplicantForSelection : ISelectableApplicant, INotifyPropertyChanged
{
public Applicant Applicant { get; init; }
public Criteria[] PrimaryCriterias { get; init; }
public event PropertyChangedEventHandler? PropertyChanged;
- public abstract bool IsSelected { get; set; }
+ public bool IsSelected
+ {
+ get => true; // so that colour images are shown
+ set => throw new InvalidOperationException();
+ }
public string FirstName => Applicant.FirstName;
public string LastName => Applicant.LastName;
public IEnumerable ExistingRoles => Enumerable.Empty();
public IEnumerable UnavailabilityReasons => Enumerable.Empty();
- public IEnumerable IneligibilityReasons => Enumerable.Empty(); //TODO populate ineligability
+ public IEnumerable IneligibilityReasons => Enumerable.Empty();
- public abstract string SelectionText { get; }
+ public string? SelectionText => null; // this hides the checkbox completely
public ApplicantForSelection(Applicant applicant, Criteria[] criterias)
{
diff --git a/Desktop/ViewModels/ApplicantForTag.cs b/Desktop/ViewModels/ApplicantForTag.cs
deleted file mode 100644
index df556f73..00000000
--- a/Desktop/ViewModels/ApplicantForTag.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using Carmen.ShowModel.Applicants;
-using Carmen.ShowModel.Criterias;
-using Carmen.ShowModel.Structure;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Carmen.Desktop.ViewModels
-{
- internal class ApplicantForTag : ApplicantForSelection
- {
- readonly Tag tag;
-
- public override string SelectionText => $"Apply {tag.Name} to {FirstName}";
-
- public override bool IsSelected
- {
- get => tag.Members.Contains(Applicant);
- set
- {
- if (value)
- {
- if (!tag.Members.Contains(Applicant))
- {
- tag.Members.Add(Applicant);
- }
- }
- else
- {
- if (tag.Members.Contains(Applicant))
- {
- tag.Members.Remove(Applicant);
- }
- }
- OnPropertyChanged();
- }
- }
-
- public ApplicantForTag(Applicant applicant, Criteria[] criterias, Tag tag)
- : base(applicant, criterias)
- {
- this.tag = tag;
- }
- }
-}
diff --git a/Desktop/ViewModels/ISelectableApplicant.cs b/Desktop/ViewModels/ISelectableApplicant.cs
index 096657f7..3f836236 100644
--- a/Desktop/ViewModels/ISelectableApplicant.cs
+++ b/Desktop/ViewModels/ISelectableApplicant.cs
@@ -15,7 +15,7 @@ public interface ISelectableApplicant
bool IsSelected { get; set; }
string FirstName { get; }
string LastName { get; }
- string SelectionText { get; }
+ string? SelectionText { get; }
IEnumerable ExistingRoles { get; }
IEnumerable UnavailabilityReasons { get; }
IEnumerable IneligibilityReasons { get; }
diff --git a/Desktop/Windows/ApplicantDetailsWindow.xaml b/Desktop/Windows/ApplicantDetailsWindow.xaml
index a1c86395..f9a6cdf7 100644
--- a/Desktop/Windows/ApplicantDetailsWindow.xaml
+++ b/Desktop/Windows/ApplicantDetailsWindow.xaml
@@ -24,6 +24,7 @@
+
@@ -157,7 +158,7 @@
-
+