Skip to content

Commit 52a84ed

Browse files
fix #1206 Show warning when item on second tab is required for derived QuantityKind, Category and Enumerationparametertype
1 parent 4b69aa5 commit 52a84ed

9 files changed

Lines changed: 92 additions & 0 deletions

BasicRdl.Tests/ViewModels/Dialogs/CategoryDialogViewModelTestFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ public void VerifyThatSuperCategoriesAreCorrectlyPopulated()
217217
"a Category may not be a super-category of one of its own descendants");
218218
}
219219

220+
[Test]
221+
public void VerifyThatGuidanceIsShownWhenPermissibleClassListIsEmpty()
222+
{
223+
Assert.IsFalse(this.viewmodel.PermissibleClass.Any());
224+
Assert.IsTrue(this.viewmodel.IsPermissibleClassListEmpty);
225+
226+
this.viewmodel.PermissibleClass.Add(ClassKind.ElementDefinition);
227+
Assert.IsFalse(this.viewmodel.IsPermissibleClassListEmpty);
228+
}
229+
220230
[Test]
221231
public void VerifyThatParameterlessContructorExists()
222232
{

BasicRdl.Tests/ViewModels/Dialogs/DerivedQuantityKindDialogViewModelTestFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ public void VerifyUpdateOkCanExecute()
166166
Assert.IsTrue(((ICommand)this.viewmodel.OkCommand).CanExecute(null));
167167
}
168168

169+
[Test]
170+
public void VerifyThatGuidanceIsShownWhenQuantityKindFactorListIsEmpty()
171+
{
172+
Assert.IsNotEmpty(this.viewmodel.QuantityKindFactor);
173+
Assert.IsFalse(this.viewmodel.IsQuantityKindFactorListEmpty);
174+
175+
this.viewmodel.QuantityKindFactor.Clear();
176+
Assert.IsTrue(this.viewmodel.IsQuantityKindFactorListEmpty);
177+
}
178+
169179
[Test]
170180
public void VerifThatUpdatingContainerPopulatesPossiblePossibleScales()
171181
{

BasicRdl.Tests/ViewModels/Dialogs/EnumerationParameterTypeDialogViewModelTestFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ public void VerifyUpdateOkCanExecute()
128128
Assert.IsFalse(((ICommand)this.viewmodel.OkCommand).CanExecute(null));
129129
}
130130

131+
[Test]
132+
public void VerifyThatGuidanceIsShownWhenValueDefinitionListIsEmpty()
133+
{
134+
Assert.AreEqual(1, this.viewmodel.ValueDefinition.Count);
135+
Assert.IsFalse(this.viewmodel.IsValueDefinitionListEmpty);
136+
137+
this.viewmodel.ValueDefinition.Clear();
138+
Assert.IsTrue(this.viewmodel.IsValueDefinitionListEmpty);
139+
}
140+
131141
[Test]
132142
public void VerifyDialogValidation()
133143
{

BasicRdl/ViewModels/Dialogs/CategoryDialogViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ namespace BasicRdl.ViewModels
5353
[ThingDialogViewModelExport(ClassKind.Category)]
5454
public class CategoryDialogViewModel : CDP4CommonView.CategoryDialogViewModel, IThingDialogViewModel
5555
{
56+
/// <summary>
57+
/// The backing field for <see cref="IsPermissibleClassListEmpty"/>
58+
/// </summary>
59+
private bool isPermissibleClassListEmpty;
60+
5661
/// <summary>
5762
/// Initializes a new instance of the <see cref="CategoryDialogViewModel"/> class.
5863
/// </summary>
@@ -95,6 +100,7 @@ public CategoryDialogViewModel(Category category, IThingTransaction transaction,
95100
: base(category, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
96101
{
97102
this.WhenAnyValue(vm => vm.PermissibleClass).Subscribe(_ => this.UpdateOkCanExecute());
103+
this.PermissibleClass.CountChanged.Subscribe(_ => this.UpdateOkCanExecute());
98104
this.WhenAnyValue(vm => vm.Container).Subscribe(_ => this.PopulateSuperCategory());
99105
}
100106

@@ -108,6 +114,16 @@ public CategoryDialogViewModel(Category category, IThingTransaction transaction,
108114
/// </summary>
109115
public ReactiveList<Category> PossibleSuperCategories { get; set; }
110116

117+
/// <summary>
118+
/// Gets a value indicating whether no <see cref="ClassKind"/> has been selected as permissible class yet. When <c>true</c>
119+
/// the dialog shows guidance that at least one permissible class must be selected on the "Permissible Classes" tab before saving.
120+
/// </summary>
121+
public bool IsPermissibleClassListEmpty
122+
{
123+
get => this.isPermissibleClassListEmpty;
124+
private set => this.RaiseAndSetIfChanged(ref this.isPermissibleClassListEmpty, value);
125+
}
126+
111127
/// <summary>
112128
/// Initializes the list of this dialog
113129
/// </summary>
@@ -162,6 +178,7 @@ protected override void PopulateSuperCategory()
162178
protected override void UpdateOkCanExecute()
163179
{
164180
base.UpdateOkCanExecute();
181+
this.IsPermissibleClassListEmpty = !this.PermissibleClass.Any();
165182
this.OkCanExecute = this.OkCanExecute && this.PermissibleClass.Any();
166183
}
167184

BasicRdl/ViewModels/Dialogs/DerivedQuantityKindDialogViewModel.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public class DerivedQuantityKindDialogViewModel : CDP4CommonView.DerivedQuantity
5555
/// </summary>
5656
private bool isBaseQuantityKind;
5757

58+
/// <summary>
59+
/// The backing field for <see cref="IsQuantityKindFactorListEmpty"/>
60+
/// </summary>
61+
private bool isQuantityKindFactorListEmpty;
62+
5863
/// <summary>
5964
/// Initializes a new instance of the <see cref="DerivedQuantityKindDialogViewModel"/> class.
6065
/// </summary>
@@ -117,12 +122,23 @@ public bool IsBaseQuantityKind
117122
set => this.RaiseAndSetIfChanged(ref this.isBaseQuantityKind, value);
118123
}
119124

125+
/// <summary>
126+
/// Gets a value indicating whether no <see cref="QuantityKindFactor"/> has been added yet. When <c>true</c>
127+
/// the dialog shows guidance that at least one factor must be added on the "Factors" tab before saving.
128+
/// </summary>
129+
public bool IsQuantityKindFactorListEmpty
130+
{
131+
get => this.isQuantityKindFactorListEmpty;
132+
private set => this.RaiseAndSetIfChanged(ref this.isQuantityKindFactorListEmpty, value);
133+
}
134+
120135
/// <summary>
121136
/// Updates the <see cref="OkCanExecute"/> property using validation rules
122137
/// </summary>
123138
protected override void UpdateOkCanExecute()
124139
{
125140
base.UpdateOkCanExecute();
141+
this.IsQuantityKindFactorListEmpty = !this.QuantityKindFactor.Any();
126142
this.OkCanExecute = this.OkCanExecute && this.QuantityKindFactor.Any() && this.SelectedDefaultScale != null;
127143
}
128144

BasicRdl/ViewModels/Dialogs/EnumerationParameterTypeDialogViewModel.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,20 @@ namespace BasicRdl.ViewModels
4040
using CDP4Dal;
4141
using CDP4Dal.Operations;
4242

43+
using ReactiveUI;
44+
4345
/// <summary>
4446
/// The purpose of the <see cref="EnumerationParameterTypeDialogViewModel"/> is to provide a dialog view model
4547
/// for a <see cref="EnumerationParameterType"/>
4648
/// </summary>
4749
[ThingDialogViewModelExport(ClassKind.EnumerationParameterType)]
4850
public class EnumerationParameterTypeDialogViewModel : CDP4CommonView.EnumerationParameterTypeDialogViewModel, IThingDialogViewModel
4951
{
52+
/// <summary>
53+
/// The backing field for <see cref="IsValueDefinitionListEmpty"/>
54+
/// </summary>
55+
private bool isValueDefinitionListEmpty;
56+
5057
/// <summary>
5158
/// Initializes a new instance of the <see cref="EnumerationParameterTypeDialogViewModel"/> class.
5259
/// </summary>
@@ -93,12 +100,23 @@ public EnumerationParameterTypeDialogViewModel(EnumerationParameterType enumerat
93100
this.ValueDefinition.CountChanged.Subscribe(_ => this.UpdateOkCanExecute());
94101
}
95102

103+
/// <summary>
104+
/// Gets a value indicating whether no <see cref="EnumerationValueDefinition"/> has been added yet. When <c>true</c>
105+
/// the dialog shows guidance that at least one value must be added on the "Values" tab before saving.
106+
/// </summary>
107+
public bool IsValueDefinitionListEmpty
108+
{
109+
get => this.isValueDefinitionListEmpty;
110+
private set => this.RaiseAndSetIfChanged(ref this.isValueDefinitionListEmpty, value);
111+
}
112+
96113
/// <summary>
97114
/// Updates the <see cref="DialogViewModelBase{T}.OkCanExecute"/> property using validation rules
98115
/// </summary>
99116
protected override void UpdateOkCanExecute()
100117
{
101118
base.UpdateOkCanExecute();
119+
this.IsValueDefinitionListEmpty = !this.ValueDefinition.Any();
102120
this.OkCanExecute = this.OkCanExecute && this.ValueDefinition.Any();
103121
}
104122
}

BasicRdl/Views/Dialogs/CategoryDialog.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<dx:DXWindow.Resources>
1818
<ResourceDictionary>
1919
<converters:ReactiveClassKindToObjectListConverter x:Key="ReactiveClassKindToObjectListConverter" />
20+
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
2021
<ResourceDictionary.MergedDictionaries>
2122
<ResourceDictionary Source="pack://application:,,,/CDP4Composition;component/CommonView/Resources/CDP4Styles.xaml" />
2223
</ResourceDictionary.MergedDictionaries>
@@ -74,6 +75,8 @@
7475
<items:HyperLinkLayoutGroup />
7576
<items:AdvancedLayoutGroup />
7677
</lc:LayoutGroup>
78+
<items:WarningLayoutItem Visibility="{Binding IsPermissibleClassListEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"
79+
WarningText="At least one Permissible Class must be selected on the 'Permissible Classes' tab before this Category can be saved." />
7780
<items:UserValidationButtonsLayoutGroup />
7881
<items:ErrorMessageLayoutGroup />
7982
</lc:LayoutControl>

BasicRdl/Views/Dialogs/DerivedQuantityKindDialog.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:items="clr-namespace:CDP4CommonView.Items;assembly=CDP4Composition"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
99
xmlns:navigation="clr-namespace:CDP4Composition.Navigation;assembly=CDP4Composition"
10+
xmlns:converters="clr-namespace:CDP4Composition.Converters;assembly=CDP4Composition"
1011
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
1112
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
1213
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
@@ -17,6 +18,7 @@
1718
navigation:DialogCloser.DialogResult="{Binding DialogResult}"
1819
mc:Ignorable="d">
1920
<dx:DXWindow.Resources>
21+
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
2022
</dx:DXWindow.Resources>
2123
<dxlc:LayoutControl Margin="5"
2224
Orientation="Vertical"
@@ -120,6 +122,8 @@
120122
<items:HyperLinkLayoutGroup />
121123
<items:AdvancedLayoutGroup />
122124
</dxlc:LayoutGroup>
125+
<items:WarningLayoutItem Visibility="{Binding IsQuantityKindFactorListEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"
126+
WarningText="At least one Quantity Kind Factor must be added on the 'Factors' tab before this Derived Quantity Kind can be saved." />
123127
<items:UserValidationButtonsLayoutGroup />
124128
<items:ErrorMessageLayoutGroup />
125129
</dxlc:LayoutControl>

BasicRdl/Views/Dialogs/EnumerationParameterTypeDialog.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:items="clr-namespace:CDP4CommonView.Items;assembly=CDP4Composition"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
99
xmlns:navigation="clr-namespace:CDP4Composition.Navigation;assembly=CDP4Composition"
10+
xmlns:converters="clr-namespace:CDP4Composition.Converters;assembly=CDP4Composition"
1011
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
1112
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
1213
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
@@ -16,6 +17,7 @@
1617
navigation:DialogCloser.DialogResult="{Binding DialogResult}"
1718
mc:Ignorable="d">
1819
<dx:DXWindow.Resources>
20+
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
1921
</dx:DXWindow.Resources>
2022
<dxlc:LayoutControl Margin="5"
2123
Orientation="Vertical"
@@ -108,6 +110,8 @@
108110
<items:HyperLinkLayoutGroup />
109111
<items:AdvancedLayoutGroup />
110112
</dxlc:LayoutGroup>
113+
<items:WarningLayoutItem Visibility="{Binding IsValueDefinitionListEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"
114+
WarningText="At least one Value must be added on the 'Values' tab before this Enumeration Parameter Type can be saved." />
111115
<items:UserValidationButtonsLayoutGroup />
112116
<items:ErrorMessageLayoutGroup />
113117
</dxlc:LayoutControl>

0 commit comments

Comments
 (0)