diff --git a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor index e2e16b55..467f0d82 100644 --- a/Oqtane.Client/Modules/Admin/Profiles/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Profiles/Edit.razor @@ -2,6 +2,7 @@ @inherits ModuleBase @inject NavigationManager NavigationManager @inject IProfileService ProfileService +@inject ISettingService SettingService @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer @@ -56,9 +57,25 @@
- +
- +
+ @if (_optiontype == "Settings") + { + + } + else + { + + } + +
@@ -95,7 +112,7 @@
@SharedLocalizer["Cancel"] - @if (PageState.QueryString.ContainsKey("id")) + @if (PageState.QueryString.ContainsKey("id")) {

@@ -116,6 +133,8 @@ private string _rows = "1"; private string _defaultvalue = string.Empty; private string _options = string.Empty; + private string _optiontype = "Settings"; + private List _entitynames; private string _validation = string.Empty; private string _autocomplete = string.Empty; private string _isrequired = "False"; @@ -133,6 +152,8 @@ { try { + _entitynames = await SettingService.GetEntityNamesAsync(); + if (PageState.QueryString.ContainsKey("id")) { _profileid = Int32.Parse(PageState.QueryString["id"]); @@ -148,6 +169,11 @@ _rows = profile.Rows.ToString(); _defaultvalue = profile.DefaultValue; _options = profile.Options; + if (_options.StartsWith("EntityName:")) + { + _optiontype = "Options"; + _options = _options.Substring(11); + } _validation = profile.Validation; _autocomplete = profile.Autocomplete; _isrequired = profile.IsRequired.ToString(); @@ -166,6 +192,18 @@ } } + private void ToggleOptionType() + { + if (_optiontype == "Options") + { + _optiontype = "Settings"; + } + else + { + _optiontype = "Options"; + } + } + private async Task SaveProfile() { validated = true; @@ -193,7 +231,14 @@ profile.MaxLength = int.Parse(_maxlength); profile.Rows = int.Parse(_rows); profile.DefaultValue = _defaultvalue; - profile.Options = _options; + if (_optiontype == "Options" && !string.IsNullOrEmpty(_options)) + { + profile.Options = "EntityName:" + _options; + } + else + { + profile.Options = _options; + } profile.Validation = _validation; profile.Autocomplete = _autocomplete; profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired)); diff --git a/Oqtane.Client/Resources/Modules/Admin/Profiles/Edit.resx b/Oqtane.Client/Resources/Modules/Admin/Profiles/Edit.resx index d67a4f7a..4810d519 100644 --- a/Oqtane.Client/Resources/Modules/Admin/Profiles/Edit.resx +++ b/Oqtane.Client/Resources/Modules/Admin/Profiles/Edit.resx @@ -157,7 +157,7 @@ The default value for this profile item - A comma delimited list of options. Options can contain a key and value if they are seperated by a colon (ie. key:value). You can also dynamically load your options from custom Settings (ie. 'EntityName:Countries'). + A comma delimited list of options. Options can contain a key and value if they are seperated by a colon (ie. key:value). You can also dynamically load your options from Settings. Should a user be required to provide a value for this profile item? @@ -201,4 +201,10 @@ Autocomplete: + + Options + + + Settings + diff --git a/Oqtane.Server/Controllers/SettingController.cs b/Oqtane.Server/Controllers/SettingController.cs index 207b8a80..041c70cf 100644 --- a/Oqtane.Server/Controllers/SettingController.cs +++ b/Oqtane.Server/Controllers/SettingController.cs @@ -308,7 +308,7 @@ namespace Oqtane.Controllers // GET: api//entitynames [HttpGet("entitynames")] - [Authorize(Roles = RoleNames.Host)] + [Authorize(Roles = RoleNames.Admin)] public IEnumerable GetEntityNames() { return _settings.GetEntityNames(); @@ -316,7 +316,7 @@ namespace Oqtane.Controllers // GET: api//entityids?entityname=x [HttpGet("entityids")] - [Authorize(Roles = RoleNames.Host)] + [Authorize(Roles = RoleNames.Admin)] public IEnumerable GetEntityIds(string entityName) { return _settings.GetEntityIds(entityName);