From 09f1d3ca152266475012297a69bd451b50764d8a Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Tue, 22 Aug 2023 09:50:59 +0200 Subject: [PATCH 1/3] Add InputList control to select values from a dictionary of string The control accepts a dictionary of string that can be searched using an input control. Pages Add and Edit have implemented the control to render the list of Icons found in the Oqtane Shared namespace. --- Oqtane.Client/Modules/Admin/Pages/Add.razor | 23 ++++++++++++-- Oqtane.Client/Modules/Admin/Pages/Edit.razor | 25 +++++++++++++-- .../Modules/Controls/InputList.razor | 31 +++++++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 Oqtane.Client/Modules/Controls/InputList.razor diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 647077d1..561e3d94 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -112,7 +112,7 @@
- +
@@ -215,7 +215,7 @@ private string _url; private string _ispersonalizable = "False"; private string _title; - private string _icon = string.Empty; + private string _icon { get; set; } = string.Empty; private string _themetype = string.Empty; private string _containertype = string.Empty; private string _headcontent; @@ -227,6 +227,7 @@ private RenderFragment ThemeSettingsComponent { get; set; } private bool _refresh = false; protected Page _parent = null; + protected Dictionary IconList = new(); protected override async Task OnInitializedAsync() { @@ -242,6 +243,20 @@ } } + Type iconsType = typeof(Icons); + System.Reflection.FieldInfo[] fields = iconsType.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.GetField); + + foreach (System.Reflection.FieldInfo field in fields) + { + if (field.FieldType == typeof(string)) + { + string fieldName = field.Name; + string fieldValue = (string)field.GetValue(null); + + IconList.Add(fieldName, fieldValue); + } + } + // if admin or user has edit access to parent page if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin) || (_parent != null && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, _parent.PermissionList))) { @@ -482,4 +497,8 @@ NavigationManager.NavigateTo(NavigateUrl()); } } + private void IconChanged(string NewIcon) + { + _icon = NewIcon; + } } diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 67ec9e59..d02547fe 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -124,7 +124,7 @@
- +
@@ -292,7 +292,7 @@ private string _url; private string _ispersonalizable; private string _title; - private string _icon; + private string _icon { get; set; } private string _themetype; private string _containertype = "-"; private Type _themeSettingsType; @@ -312,7 +312,7 @@ private bool _refresh = false; protected Page _page = null; protected Page _parent = null; - + protected Dictionary IconList = new(); protected override async Task OnInitializedAsync() { try @@ -352,6 +352,20 @@ _icon = _page.Icon; _ispersonalizable = _page.IsPersonalizable.ToString(); + Type iconsType = typeof(Icons); + System.Reflection.FieldInfo[] fields = iconsType.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.GetField); + + foreach (System.Reflection.FieldInfo field in fields) + { + if (field.FieldType == typeof(string)) + { + string fieldName = field.Name; + string fieldValue = (string)field.GetValue(null); + + IconList.Add(fieldName, fieldValue); + } + } + // appearance _title = _page.Title; _themetype = _page.ThemeType; @@ -660,4 +674,9 @@ } } + private void IconChanged(string NewIcon) + { + _icon = NewIcon; + } + } diff --git a/Oqtane.Client/Modules/Controls/InputList.razor b/Oqtane.Client/Modules/Controls/InputList.razor new file mode 100644 index 00000000..678bc4ac --- /dev/null +++ b/Oqtane.Client/Modules/Controls/InputList.razor @@ -0,0 +1,31 @@ +@namespace Oqtane.Modules.Controls +@using System.Linq.Expressions; +@inherits ModuleControlBase + + + @foreach(var iv in InputValues) + { + + } + + +@code { + [Parameter] + public string Value { get; set; } + [EditorRequired] + [Parameter] + public Dictionary InputValues { get; set; } + [EditorRequired] + [Parameter] + public EventCallback ValueChanged { get; set; } + + protected void OnChange(ChangeEventArgs e) + { + if (string.IsNullOrWhiteSpace(e.Value.ToString())) { return; } + Value = e.Value.ToString(); + if (ValueChanged.HasDelegate) + { + ValueChanged.InvokeAsync(Value); + } + } +} \ No newline at end of file From 471f7184fb4db8adbdb9bc68bbd8b66aec528086 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Wed, 23 Aug 2023 07:47:35 +0200 Subject: [PATCH 2/3] Added Icon Preview Added an icon preview to the icon selecting control --- Oqtane.Client/Modules/Admin/Pages/Add.razor | 5 ++++- Oqtane.Client/Modules/Admin/Pages/Edit.razor | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index 561e3d94..e934ed9d 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -111,9 +111,12 @@
-
+
+
+ +
diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index d02547fe..f6471eea 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -123,7 +123,10 @@
-
+
+ +
+
From ddb2fe4b03ecc13c22c0499b2d4588feb0503910 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Wed, 23 Aug 2023 07:49:50 +0200 Subject: [PATCH 3/3] Update Edit.razor Moved Icon to the end of control --- Oqtane.Client/Modules/Admin/Pages/Edit.razor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index f6471eea..bf5f6c0f 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -123,12 +123,12 @@
-
- -
+
+ +