Skip to content

Commit

Permalink
Merge pull request #110 from ofaruk84/ix-implement-filter-logic
Browse files Browse the repository at this point in the history
IX: Implement optional filter logic
  • Loading branch information
emncnozge authored Dec 5, 2024
2 parents 8ec31e7 + aff5307 commit 0c367b5
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ _pkginfo.txt
# but keep track of directories ending in .cache
!?*.[Cc]ache/

##sln
*.sln

# Others
ClientBin/
~$*
Expand Down
2 changes: 1 addition & 1 deletion SiemensIXBlazor.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
Expand Down
20 changes: 18 additions & 2 deletions SiemensIXBlazor/Components/CategoryFilter/CategoryFilter.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Newtonsoft.Json;
using SiemensIXBlazor.Enums.CategoryFilter;
using SiemensIXBlazor.Interops;
using SiemensIXBlazor.Objects;
using System.Text.Json;
Expand All @@ -24,6 +25,7 @@ public partial class CategoryFilter
private string[] _suggestions = [];
private Lazy<Task<IJSObjectReference>>? moduleTask;
private BaseInterop? _interop;
private LogicalFilterOperator _logicalFilterOperator = LogicalFilterOperator.Equal;

[Parameter, EditorRequired]
public string Id { get; set; } = string.Empty;
Expand All @@ -41,8 +43,12 @@ public FilterState? FilterState
get => _filterState;
set
{
_filterState = value;
InitialParameter("setFilterState", _filterState);
if(value is not null)
{
_filterState = value;
InitialParameter("setFilterState", _filterState);
}

}
}
[Parameter]
Expand Down Expand Up @@ -80,6 +86,15 @@ public string[]? Suggestions
InitialParameter("setSuggestions", new Dictionary<string, string[]> { { "suggestions", _suggestions } });

Check warning on line 86 in SiemensIXBlazor/Components/CategoryFilter/CategoryFilter.razor.cs

View workflow job for this annotation

GitHub Actions / deploy

Possible null reference argument for parameter 'value' in 'void Dictionary<string, string[]>.Add(string key, string[] value)'.
}
}

[Parameter]
public LogicalFilterOperator StaticOperator {
get=>_logicalFilterOperator;
set {

_logicalFilterOperator = value;
InitialParameter("setStaticOperator", _logicalFilterOperator.ToEnumString());
} }
[Parameter]
public EventCallback<FilterState> FilterChangedEvent { get; set; }
[Parameter]
Expand Down Expand Up @@ -130,5 +145,6 @@ private void InitialParameter(string functionName, object param)
}
});
}

}
}
21 changes: 21 additions & 0 deletions SiemensIXBlazor/Enums/CategoryFilter/LogicalFilterEnumExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SiemensIXBlazor.Enums.CategoryFilter
{
public static class LogicalFilterEnumExtension
{
public static string ToEnumString(this LogicalFilterOperator filter)
{
return filter switch
{
LogicalFilterOperator.Equal => "Equal",
LogicalFilterOperator.NotEqual => "Not equal",
_ => throw new ArgumentOutOfRangeException(nameof(filter), filter, null)
};
}
}
}
14 changes: 14 additions & 0 deletions SiemensIXBlazor/Enums/CategoryFilter/LogicalFiterOperator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SiemensIXBlazor.Enums.CategoryFilter
{
public enum LogicalFilterOperator
{
Equal,
NotEqual
}
}
1 change: 0 additions & 1 deletion SiemensIXBlazor/SiemensIXBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@

<ItemGroup>
<Folder Include="wwwroot\js\siemens-ix\" />
<Folder Include="wwwroot\js\interops\" />
<Folder Include="Components\KeyValueList\" />
<Folder Include="Components\KeyValue\" />
<Folder Include="Components\EmptyState\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ export function setSuggestions(id, suggestionsObject) {
console.error("Failed to set suggestions:", error);
}
}

export function setStaticOperator(id, logicalFilter) {
try {
const element = document.getElementById(id);
if (!element) {
throw new Error(`Element with ID ${id} not found`);
}
element.staticOperator = JSON.parse(logicalFilter);
} catch (err) {
console.error("Failed on setting staticOperator", err);
}
}

0 comments on commit 0c367b5

Please sign in to comment.