diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs index 2fb841ec5a..caa5d67957 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiDto.cs @@ -8,5 +8,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending public ExtensionPropertyUiTableDto OnTable { get; set; } public ExtensionPropertyUiFormDto OnCreateForm { get; set; } public ExtensionPropertyUiFormDto OnEditForm { get; set; } + public ExtensionPropertyUiLookupDto Lookup { get; set; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs new file mode 100644 index 0000000000..d7e7237295 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/ExtensionPropertyUiLookupDto.cs @@ -0,0 +1,13 @@ +using System; + +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending +{ + [Serializable] + public class ExtensionPropertyUiLookupDto + { + public string Url { get; set; } + public string ResultListPropertyName { get; set; } + public string DisplayPropertyName { get; set; } + public string ValuePropertyName { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelper.cs index e27235da91..ba3197f04a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelper.cs @@ -22,6 +22,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form public bool DisplayRequiredSymbol { get; set; } = true; public string AutocompleteApiUrl { get; set; } + public string AutocompleteItemsPropertyName { get; set; } public string AutocompleteDisplayPropertyName { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs index c12904edb5..ffa6479470 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs @@ -103,6 +103,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form { output.Attributes.AddClass("auto-complete-select"); output.Attributes.Add("data-autocomplete-api-url", TagHelper.AutocompleteApiUrl); + output.Attributes.Add("data-autocomplete-items-property", TagHelper.AutocompleteItemsPropertyName); output.Attributes.Add("data-autocomplete-display-property", TagHelper.AutocompleteDisplayPropertyName); output.Attributes.Add("data-autocomplete-value-property", TagHelper.AutocompleteValuePropertyName); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index 97e3906a24..099a6a5105 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -78,6 +78,7 @@ var url = $(this).data("autocompleteApiUrl"); var displayName = $(this).data("autocompleteDisplayProperty"); var displayValue = $(this).data("autocompleteValueProperty"); + var itemsPropertyName = $(this).data("autocompleteItemsProperty"); $select.select2({ ajax: { url: url, @@ -90,7 +91,14 @@ }, processResults: function (data) { var retVal = []; - data.forEach(function (item, index) { + var items = []; + if (itemsPropertyName == "") { + items = data; + } + else { + items = data[itemsPropertyName]; + } + items.forEach(function (item, index) { retVal.push({ id: item[displayValue], text: item[displayName] diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs index 76d73820b2..3c51398a8c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs @@ -49,7 +49,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending } FillEnums(objectExtensionsDto); - + return objectExtensionsDto; } @@ -140,6 +140,13 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending OnTable = new ExtensionPropertyUiTableDto { IsVisible = propertyConfig.UI.OnTable.IsVisible + }, + Lookup = new ExtensionPropertyUiLookupDto + { + Url = propertyConfig.UI.Lookup.Url, + ResultListPropertyName = propertyConfig.UI.Lookup.ResultListPropertyName, + DisplayPropertyName = propertyConfig.UI.Lookup.DisplayPropertyName, + ValuePropertyName = propertyConfig.UI.Lookup.ValuePropertyName } } }; diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs index 23492d25ab..ed4447ff51 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/IBasicObjectExtensionPropertyInfo.cs @@ -35,8 +35,5 @@ namespace Volo.Abp.ObjectExtending /// [CanBeNull] public Func DefaultValueFactory { get; set; } - - [NotNull] - public ExtensionPropertyLookupConfiguration LookupConfiguration { get; set; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs index 37eb29d69b..3f366721aa 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyConfiguration.cs @@ -59,9 +59,6 @@ namespace Volo.Abp.ObjectExtending.Modularity [CanBeNull] public Func DefaultValueFactory { get; set; } - [NotNull] - public ExtensionPropertyLookupConfiguration LookupConfiguration { get; set; } - public ExtensionPropertyConfiguration( [NotNull] EntityExtensionConfiguration entityExtensionConfiguration, [NotNull] Type type, @@ -81,7 +78,6 @@ namespace Volo.Abp.ObjectExtending.Modularity Attributes.AddRange(ExtensionPropertyHelper.GetDefaultAttributes(Type)); DefaultValue = TypeHelper.GetDefaultValue(Type); - LookupConfiguration = new ExtensionPropertyLookupConfiguration(); } public object GetDefaultValue() diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs index 7d92f8accd..e781fc8bab 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyLookupConfiguration.cs @@ -2,7 +2,8 @@ { public class ExtensionPropertyLookupConfiguration { - public string ApiUrl { get; set; } + public string Url { get; set; } + public string ResultListPropertyName { get; set; } = "items"; public string DisplayPropertyName { get; set; } = "text"; public string ValuePropertyName { get; set; } = "id"; } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyUiConfiguration.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyUiConfiguration.cs index aa581228bd..0b826a0b3d 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyUiConfiguration.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ExtensionPropertyUiConfiguration.cs @@ -13,11 +13,15 @@ namespace Volo.Abp.ObjectExtending.Modularity [NotNull] public ExtensionPropertyUiFormConfiguration OnEditForm { get; } + [NotNull] + public ExtensionPropertyLookupConfiguration Lookup { get; set; } + public ExtensionPropertyUiConfiguration() { OnTable = new ExtensionPropertyUiTableConfiguration(); OnCreateForm = new ExtensionPropertyUiFormConfiguration(); OnEditForm = new ExtensionPropertyUiFormConfiguration(); + Lookup = new ExtensionPropertyLookupConfiguration(); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs index 0c6d6b5a2d..4f7d1396af 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/Modularity/ModuleExtensionConfigurationHelper.cs @@ -155,7 +155,7 @@ namespace Volo.Abp.ObjectExtending.Modularity property.Validators.AddRange(propertyConfig.Validators); property.DefaultValue = propertyConfig.DefaultValue; property.DefaultValueFactory = propertyConfig.DefaultValueFactory; - property.LookupConfiguration = propertyConfig.LookupConfiguration; + property.Lookup = propertyConfig.UI.Lookup; } ); } diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs index 5b71b0b975..b5da5e6eeb 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs @@ -59,7 +59,7 @@ namespace Volo.Abp.ObjectExtending public Func DefaultValueFactory { get; set; } [NotNull] - public ExtensionPropertyLookupConfiguration LookupConfiguration { get; set; } + public ExtensionPropertyLookupConfiguration Lookup { get; set; } public ObjectExtensionPropertyInfo( [NotNull] ObjectExtensionInfo objectExtension, @@ -76,6 +76,7 @@ namespace Volo.Abp.ObjectExtending Attributes.AddRange(ExtensionPropertyHelper.GetDefaultAttributes(Type)); DefaultValue = TypeHelper.GetDefaultValue(Type); + Lookup = new ExtensionPropertyLookupConfiguration(); } public object GetDefaultValue()