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

Fix #694 [Reference Data] Parameter types - UI problems + #696 Tab text update #704

Merged
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
19 changes: 19 additions & 0 deletions COMETwebapp/Components/Common/SelectedDataItemForm.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public abstract partial class SelectedDataItemForm : DisposableComponent
/// </summary>
protected EditContext EditFormContext { get; set; }

/// <summary>
/// Gets or sets the custom validation fields names that will be validated immediately
/// </summary>
protected virtual IEnumerable<string> ImmediateValidationFields { get; } = Enumerable.Empty<string>();

/// <summary>
/// Method that is executed when the cancel button is clicked
/// </summary>
Expand Down Expand Up @@ -124,6 +129,20 @@ private void InitializeEditContext(EditContext editFormContext)
this.EditFormContext = editFormContext;
this.MapOfValidationMessages.Clear();
this.EditFormContext.OnFieldChanged += this.OnFieldChangedHandler;

this.ValidateCustomFields();
}

/// <summary>
/// Validate the custom fields contained by the collection <see cref="ImmediateValidationFields" />
/// </summary>
private void ValidateCustomFields()
{
foreach (var fieldStr in this.ImmediateValidationFields)
{
var fieldIdentifier = this.EditFormContext.Field(fieldStr);
this.MapOfValidationMessages[fieldIdentifier] = this.EditFormContext.GetValidationMessages(fieldIdentifier);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace COMETwebapp.Components.ReferenceData.ParameterTypes
{
using System.ComponentModel.DataAnnotations;

using CDP4Common.SiteDirectoryData;

using COMETwebapp.Components.Common;
using COMETwebapp.ViewModels.Components.ReferenceData.ParameterTypes;

Expand All @@ -43,6 +45,17 @@ public partial class ParameterTypeForm : SelectedDataItemForm
[Required]
public IParameterTypeTableViewModel ViewModel { get; set; }

/// <summary>
/// Gets or sets the custom validation fields names that will be validated immediately
/// </summary>
protected override IEnumerable<string> ImmediateValidationFields =>
[
nameof(DerivedQuantityKind.QuantityKindFactor),
nameof(EnumerationParameterType.ValueDefinition),
nameof(SampledFunctionParameterType.DependentParameterType),
nameof(SampledFunctionParameterType.IndependentParameterType)
];

/// <summary>
/// Method that is executed when there is a valid submit
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion COMETwebapp/Components/Tabs/TabsPanelComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@key="tab"/>
}

<TabComponent Text="Open Model"
<TabComponent Text="Select Model"
Icon="typeof(FeatherPlus)"
OnClick="@(() => this.OnOpenTabClick.Invoke())"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ParameterQuantityKindValidator(IValidationService validationService)
this.Include(new ParameterTypeValidator(validationService));
this.RuleFor(x => x.DefaultScale).NotEmpty().Validate(validationService, nameof(QuantityKind.DefaultScale));
this.RuleFor(x => x.QuantityDimensionSymbol).NotEmpty().Validate(validationService, nameof(QuantityKind.QuantityDimensionSymbol));
this.RuleFor(x => x.PossibleScale).NotEmpty().Validate(validationService, nameof(QuantityKind.PossibleScale));
this.RuleFor(x => x.PossibleScale).Validate(validationService, nameof(QuantityKind.PossibleScale));
}
}
}
Loading