From 480060d61703ab725651868669f1073ed9cfc47e Mon Sep 17 00:00:00 2001 From: Alexander van Delft Date: Fri, 13 Dec 2024 13:52:01 +0100 Subject: [PATCH] Changes according to SQ --- .../Components/CardView/CardField.cs | 2 +- .../Components/CardView/CardView.razor | 2 +- .../Components/CardView/CardView.razor.cs | 36 ++++++++----------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/COMET.Web.Common/Components/CardView/CardField.cs b/COMET.Web.Common/Components/CardView/CardField.cs index 24238f25..f2cba9f6 100644 --- a/COMET.Web.Common/Components/CardView/CardField.cs +++ b/COMET.Web.Common/Components/CardView/CardField.cs @@ -138,4 +138,4 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) } } } -} \ No newline at end of file +} diff --git a/COMET.Web.Common/Components/CardView/CardView.razor b/COMET.Web.Common/Components/CardView/CardView.razor index 4f86e930..19b98b0c 100644 --- a/COMET.Web.Common/Components/CardView/CardView.razor +++ b/COMET.Web.Common/Components/CardView/CardView.razor @@ -19,7 +19,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -------------------------------------------------------------------------------> -@namespace COMET.Web.Common.Components +@namespace COMET.Web.Common.Components.CardView @typeparam T @inherits DisposableComponent diff --git a/COMET.Web.Common/Components/CardView/CardView.razor.cs b/COMET.Web.Common/Components/CardView/CardView.razor.cs index 07010003..c249d5b4 100644 --- a/COMET.Web.Common/Components/CardView/CardView.razor.cs +++ b/COMET.Web.Common/Components/CardView/CardView.razor.cs @@ -23,17 +23,15 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace COMET.Web.Common.Components +namespace COMET.Web.Common.Components.CardView { - using COMET.Web.Common.Components.CardView; + using System.Linq.Dynamic.Core; using FastMember; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web.Virtualization; - using System.Linq.Dynamic.Core; - /// /// Component used to show a CardView based on a specific type /// @@ -64,30 +62,30 @@ 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 to perform search on /// - public HashSet SearchFields { get; set; } = []; + public HashSet SearchFields { get; private set; } = []; /// /// Gets or sets a collection of propertynames of type to perform sorting on /// - public SortedSet SortFields { get; set; } = [string.Empty]; + public SortedSet SortFields { get; private set; } = [string.Empty]; /// /// Gets or sets a value indication that sorting is allowed /// - public bool AllowSort { get; set; } = false; + public bool AllowSort { get; set; } /// /// Gets or sets a value indication that searching is allowed /// - public bool AllowSearch { get; set; } = false; + public bool AllowSearch { get; set; } /// /// hold a reference to the previously selected Item. /// Typically used to check for changes in Items collection /// - private ICollection previousItems = null; + private ICollection previousItems; /// /// A reference to the component for loading items @@ -219,22 +217,16 @@ private void OnSearchTextChanged(string value) /// the internal void InitializeCardField(CardField cardField) { - if (cardField.AllowSort) + if (cardField.AllowSort && this.SortFields.Add(cardField.FieldName)) { - if (this.SortFields.Add(cardField.FieldName)) - { - this.AllowSort = true; - this.StateHasChanged(); - } + this.AllowSort = true; + this.StateHasChanged(); } - if (cardField.AllowSearch) + if (cardField.AllowSearch && this.SearchFields.Add(cardField.FieldName)) { - if (this.SearchFields.Add(cardField.FieldName)) - { - this.AllowSearch = true; - this.StateHasChanged(); - } + this.AllowSearch = true; + this.StateHasChanged(); } }