diff --git a/COMET.Web.Common.Tests/Components/CardView/CardViewTestFixture.cs b/COMET.Web.Common.Tests/Components/CardView/CardViewTestFixture.cs index a15c0af5..3ba04fe4 100644 --- a/COMET.Web.Common.Tests/Components/CardView/CardViewTestFixture.cs +++ b/COMET.Web.Common.Tests/Components/CardView/CardViewTestFixture.cs @@ -45,6 +45,8 @@ public class CardViewTestFixture private TestClass testClass2 = new (); private TestClass testClass3 = new (); private TestClass[] testClasses; + private string[] searchFields = new[] { "Id", "Name" }; + private string[] sortFields = new[] { string.Empty, "Id", "Name" }; private static RenderFragment NormalTemplate() { @@ -118,8 +120,8 @@ public void VerifyComponent() Assert.That(cardView.Instance.AllowSort, Is.True); Assert.That(cardView.Instance.AllowSearch, Is.True); Assert.That(cardView.Instance.ItemSize, Is.EqualTo(150)); - Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(new [] {"Id", "Name"})); - Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(new[] { string.Empty, "Id", "Name" })); + Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(this.searchFields)); + Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(this.sortFields)); }); var textBoxParentComponent = component.Find("#search-textbox"); @@ -297,8 +299,8 @@ public void VerifySelectComponent() Assert.That(cardView.Instance.AllowSort, Is.True); Assert.That(cardView.Instance.AllowSearch, Is.True); Assert.That(cardView.Instance.ItemSize, Is.EqualTo(150)); - Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(new[] { "Id", "Name" })); - Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(new[] { string.Empty, "Id", "Name" })); + Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(this.searchFields)); + Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(this.sortFields)); }); var firstCardField = component.Find(".card"); @@ -330,8 +332,8 @@ public async Task VerifySearchComponent() Assert.That(cardView.Instance.AllowSort, Is.True); Assert.That(cardView.Instance.AllowSearch, Is.True); Assert.That(cardView.Instance.ItemSize, Is.EqualTo(150)); - Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(new[] { "Id", "Name" })); - Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(new[] { string.Empty, "Id", "Name" })); + Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(this.searchFields)); + Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(this.sortFields)); }); var textBoxParentComponent = component.Find("#search-textbox"); @@ -395,8 +397,8 @@ public async Task VerifySortComponent() Assert.That(cardView.Instance.AllowSort, Is.True); Assert.That(cardView.Instance.AllowSearch, Is.True); Assert.That(cardView.Instance.ItemSize, Is.EqualTo(150)); - Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(new[] { "Id", "Name" })); - Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(new[] { string.Empty, "Id", "Name" })); + Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(this.searchFields)); + Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(this.sortFields)); Assert.That(cardView.Instance.SelectedSortField == string.Empty); }); diff --git a/COMET.Web.Common/Components/CardView/CardField.cs b/COMET.Web.Common/Components/CardView/CardField.cs index 48de25d7..68ff33ac 100644 --- a/COMET.Web.Common/Components/CardView/CardField.cs +++ b/COMET.Web.Common/Components/CardView/CardField.cs @@ -39,10 +39,10 @@ namespace COMET.Web.Common.Components.CardView public class CardField : ComponentBase { /// - /// The used to read properties from the instance of . + /// The used to read properties from the instance of T. /// This is a static property on a generic type, so it will have different static values for each used generic type in the application /// - private static TypeAccessor typeAccessor { get; set; } + private static TypeAccessor typeAccessor; /// /// Initializes the static properties of this class @@ -71,7 +71,7 @@ static CardField() public T Context { get; set; } /// - /// Gets or sets the FieldName (propertyname of ) to show in the UI + /// Gets or sets the FieldName (propertyname of T) to show in the UI /// [Parameter] public string FieldName { get; set; } diff --git a/COMET.Web.Common/Components/CardView/CardView.razor b/COMET.Web.Common/Components/CardView/CardView.razor index 9c73b84f..b941bd4a 100644 --- a/COMET.Web.Common/Components/CardView/CardView.razor +++ b/COMET.Web.Common/Components/CardView/CardView.razor @@ -31,7 +31,7 @@ - @@ -44,10 +44,10 @@
+ @onclick="@(() => this.SelectItem(@context))">
- + @this.ItemTemplate(@context) diff --git a/COMET.Web.Common/Components/CardView/CardView.razor.cs b/COMET.Web.Common/Components/CardView/CardView.razor.cs index 6ad477ac..3c868352 100644 --- a/COMET.Web.Common/Components/CardView/CardView.razor.cs +++ b/COMET.Web.Common/Components/CardView/CardView.razor.cs @@ -62,12 +62,12 @@ public partial class CardView : DisposableComponent public float MinWidth { get; set; } = 250; /// - /// Gets or sets a collection of propertynames of type to perform search on + /// Gets or sets a collection of propertynames of type T to perform search on /// public HashSet SearchFields { get; private set; } = []; /// - /// Gets or sets a collection of propertynames of type to perform sorting on + /// Gets or sets a collection of propertynames of type T to perform sorting on /// public SortedSet SortFields { get; private set; } = [string.Empty]; @@ -93,7 +93,7 @@ public partial class CardView : DisposableComponent private Virtualize? virtualize; // Reference to the Virtualize component /// - /// The FastMember to use to perform actions on instances of + /// The FastMember to use to perform actions on instances of type T /// private TypeAccessor typeAccessor = TypeAccessor.Create(typeof(T)); @@ -105,7 +105,7 @@ public partial class CardView : DisposableComponent /// /// Gets or sets the term where to search/filter items on /// - private string searchTerm { get; set; } = string.Empty; + public string SearchTerm { get; set; } = string.Empty; /// /// Gets or sets the term where to sort items on @@ -125,23 +125,23 @@ private string GetSelectedClass(T vm) /// /// Set the selected item /// - /// The item - private void selectItem(T item) + /// The item of type T + public void SelectItem(T item) { this.selected = item; } /// - /// Filters the list of items to show in the UI based on the + /// Filters the list of items to show in the UI based on the /// /// The request to perform filtering of the items list /// an waitable - private async ValueTask> LoadItems(ItemsProviderRequest request) + private ValueTask> LoadItems(ItemsProviderRequest request) { // Filter items based on the SearchTerm - var filteredItems = !this.AllowSearch || string.IsNullOrWhiteSpace(this.searchTerm) + var filteredItems = !this.AllowSearch || string.IsNullOrWhiteSpace(this.SearchTerm) ? this.Items - : this.Items.Where(item => this.FilterItem(item, this.searchTerm)).ToList(); + : this.Items.Where(item => this.FilterItem(item, this.SearchTerm)).ToList(); // Return paged items for virtualization var items = filteredItems.Skip(request.StartIndex).Take(request.Count); @@ -151,11 +151,11 @@ private async ValueTask> LoadItems(ItemsProviderRequest r items = items.AsQueryable().OrderBy(this.SelectedSortField); } - return new ItemsProviderResult(items.ToList(), filteredItems.Count); + return new ValueTask>(new ItemsProviderResult(items.ToList(), filteredItems.Count)); } /// - /// Used to filter items based on the + /// Used to filter items based on the /// /// The item to perform searching on /// The string to search for @@ -182,7 +182,7 @@ private bool FilterItem(T item, string query) /// The text from the UI element's event private void OnSearchTextChanged(string value) { - this.searchTerm = value ?? string.Empty; + this.SearchTerm = value ?? string.Empty; this.virtualize?.RefreshDataAsync(); // Tell Virtualize to refresh data } diff --git a/COMETwebapp/ViewModels/Components/SystemRepresentation/IElementDefinitionDetailsViewModel.cs b/COMETwebapp/ViewModels/Components/SystemRepresentation/IElementDefinitionDetailsViewModel.cs index f88364b1..3ed43d4c 100644 --- a/COMETwebapp/ViewModels/Components/SystemRepresentation/IElementDefinitionDetailsViewModel.cs +++ b/COMETwebapp/ViewModels/Components/SystemRepresentation/IElementDefinitionDetailsViewModel.cs @@ -40,6 +40,6 @@ public interface IElementDefinitionDetailsViewModel /// /// A collection of /// - ICollection Rows { get; set; } + ICollection Rows { get; } } }