diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a6bd16c Binary files /dev/null and b/.DS_Store differ diff --git a/Demo/FormGeneratorDemo.csproj b/Demo/FormGeneratorDemo.csproj index ffa4432..ac68408 100644 --- a/Demo/FormGeneratorDemo.csproj +++ b/Demo/FormGeneratorDemo.csproj @@ -1,11 +1,20 @@ - + - netcoreapp3.1 + net5.0 + + TRACE + + + + TRACE; BOOTSTRAP; + + + @@ -16,6 +25,7 @@ + diff --git a/Demo/Pages/FormDefinitionForm.razor b/Demo/Pages/FormDefinitionForm.razor new file mode 100644 index 0000000..01d1556 --- /dev/null +++ b/Demo/Pages/FormDefinitionForm.razor @@ -0,0 +1,96 @@ +@page "/definition-form" + +@using VxFormGenerator.Core +@using VxFormGenerator.Core.Layout +@using VxFormGeneratorDemoData + + +

Model Based Form Demo

+ +
+
+ Change form options +
+
+ + + + + + + +
+
+
+ +
+
+ Generated by POCO +
+
+ + + + + + +
+
+ +
+ +@code{ + + /// + /// Model that is used for the form + /// + private object Model = new FeedingSession(); + private VxFormLayoutOptionsAnnotated Options = new VxFormLayoutOptionsAnnotated(); + private VxFormLayoutOptions OptionsForForm = new VxFormLayoutOptions(); + + protected override void OnInitialized() + { + base.OnInitialized(); + + ChangeLayoutOptions(new EditContext(Options)); + } + + /// + /// Will handle the submit action of the form + /// + /// The model with values as entered in the form + private void HandleValidSubmit(EditContext context) + { + // save your changes + } + + private void HandleInValidSubmit(EditContext context) + { + + + } + + private void ChangeLayoutOptions(EditContext context) + { + var options = ((VxFormLayoutOptionsAnnotated)context.Model); + OptionsForForm = options.ToFormLayoutOptions(); + + switch (options.FormRenderKind) + { + case TypeOfForm.SIMPLE: + Model = new FeedingSession(); + break; + case TypeOfForm.ADVANCED: + Model = new AddressViewModel(); + break; + case TypeOfForm.COMPLEX: + Model = new OrderViewModel(); + break; + } + + } + +} diff --git a/Demo/Pages/Index.razor b/Demo/Pages/Index.razor index c8cf4c0..fab95a7 100644 --- a/Demo/Pages/Index.razor +++ b/Demo/Pages/Index.razor @@ -1,23 +1,22 @@ @page "/" @using VxFormGenerator.Core -@using FormGeneratorDemo.Data @using System.Dynamic

VxFormGenerator Demo


-
+
Model based form
-

Render a form with validation based on a POCO

- Go to demo +

Render a form with layout information

+ Go to demo
-
+
Dynamic based form
@@ -28,6 +27,3 @@
- -@code{ -} diff --git a/Demo/Pages/ModelForm.razor b/Demo/Pages/ModelForm.razor deleted file mode 100644 index e829dc1..0000000 --- a/Demo/Pages/ModelForm.razor +++ /dev/null @@ -1,44 +0,0 @@ -@page "/model-form" - -@using VxFormGenerator.Core -@using FormGeneratorDemo.Data - -

Model Based Form Demo

- -
-
-
Generated by POCO
- - - - - -
-
- -@code{ - - /// - /// Model that is used for the form - /// - private FeedingSession Model = new FeedingSession(); - - - /// - /// Will handle the submit action of the form - /// - /// The model with values as entered in the form - private void HandleValidSubmit(EditContext context) - { - // save your changes - } - - private void HandleInValidSubmit(EditContext context) - { - - - } - -} diff --git a/Demo/Pages/_Host.cshtml b/Demo/Pages/_Host.cshtml index b0f41ab..6065814 100644 --- a/Demo/Pages/_Host.cshtml +++ b/Demo/Pages/_Host.cshtml @@ -36,7 +36,7 @@ Blazor.defaultReconnectionHandler._reconnectCallback = function (d) { setTimeout(function () { document.location.reload(); - },5000) + },10000) } diff --git a/Demo/Shared/NavMenu.razor b/Demo/Shared/NavMenu.razor index 6805522..4af134c 100644 --- a/Demo/Shared/NavMenu.razor +++ b/Demo/Shared/NavMenu.razor @@ -13,7 +13,7 @@ diff --git a/Demo/Startup.cs b/Demo/Startup.cs index efbbe13..99a2ece 100644 --- a/Demo/Startup.cs +++ b/Demo/Startup.cs @@ -5,7 +5,14 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using VxFormGenerator.Settings.Bootstrap; + +#if BOOTSTRAP + using VxFormGenerator.Settings.Bootstrap; +#else + using VxFormGenerator.Settings.Plain; +#endif + + namespace FormGeneratorDemo { diff --git a/Demo/wwwroot/css/site.css b/Demo/wwwroot/css/site.css index 3a0aab8..a8b79fd 100644 --- a/Demo/wwwroot/css/site.css +++ b/Demo/wwwroot/css/site.css @@ -117,9 +117,9 @@ app { /*Added bootstrap override, so the hardcoded field statuses will work with bootstrap validation message otherwise we needed to patch all the form elements*/ -.form-control.invalid ~ .invalid-feedback, -.form-control.invalid ~ .invalid-tooltip, -.was-validated .form-control:invalid ~ .invalid-feedback, +.form-control.invalid ~ .invalid-feedback, +.form-control.invalid ~ .invalid-tooltip, +.was-validated .form-control:invalid ~ .invalid-feedback, .was-validated .form-control:invalid ~ .invalid-tooltip { display: block; } @@ -197,3 +197,17 @@ app { .line-height-checkbox { line-height: 1.5em; } + + +fieldset:not(:last-child) { + margin-bottom: 16px; +} + +.form-control-plain { + width: 100%; + display: block; +} + +.form-group-plain { + +} diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..31b5e2b --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,12 @@ + + + + true + + + + + <_Parameter1>$(MSBuildProjectName).Tests + + + diff --git a/Docs/Advanced_sample_form.png b/Docs/Advanced_sample_form.png new file mode 100644 index 0000000..706bbea Binary files /dev/null and b/Docs/Advanced_sample_form.png differ diff --git a/Docs/complex_sample_form.png b/Docs/complex_sample_form.png new file mode 100644 index 0000000..1beafa1 Binary files /dev/null and b/Docs/complex_sample_form.png differ diff --git a/Docs/discord-logo.png b/Docs/discord-logo.png new file mode 100644 index 0000000..c4061b6 Binary files /dev/null and b/Docs/discord-logo.png differ diff --git a/FormGeneratorDemo.sln b/FormGeneratorDemo.sln index caffc97..98fc48f 100644 --- a/FormGeneratorDemo.sln +++ b/FormGeneratorDemo.sln @@ -16,6 +16,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGenerator.Core.Tests", "VxFormGenerator.Core.Tests\VxFormGenerator.Core.Tests.csproj", "{73AE376A-E7AA-4C7B-972C-6CAD787364D3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VxFormGeneratorDemoData", "VxFormGeneratorDemoData\VxFormGeneratorDemoData.csproj", "{17AC6DF2-4B77-4463-9EB8-D445A858C2F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +42,14 @@ Global {5BB684AC-3B47-4492-9AE6-8FA93567E53A}.Debug|Any CPU.Build.0 = Debug|Any CPU {5BB684AC-3B47-4492-9AE6-8FA93567E53A}.Release|Any CPU.ActiveCfg = Release|Any CPU {5BB684AC-3B47-4492-9AE6-8FA93567E53A}.Release|Any CPU.Build.0 = Release|Any CPU + {73AE376A-E7AA-4C7B-972C-6CAD787364D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73AE376A-E7AA-4C7B-972C-6CAD787364D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73AE376A-E7AA-4C7B-972C-6CAD787364D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73AE376A-E7AA-4C7B-972C-6CAD787364D3}.Release|Any CPU.Build.0 = Release|Any CPU + {17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17AC6DF2-4B77-4463-9EB8-D445A858C2F7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index 8de842c..8723d89 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,135 @@ You can render a form that is based on a dynamic `ExpandoObject`. The developer +### Layout + +The form generator supports layout structuring based on meta-data defined at model level. + +````C# + // Add label to row 2 + [VxFormRowLayout(Id = 2, Label = "Adress")] + public class AddressViewModel + { + [Display(Name = "Firstname")] + // Add element to row 1 with automatic width based on number of items in a row + [VxFormElementLayout(RowId = 1)] + public string SurName { get; set; } + // Add element to row 1 with automatic width based on number of items in a row and define a placeholder + [VxFormElementLayout(RowId = 1, Placeholder = "Your Lastname")] + [Display(Name = "Lastname")] + public string LastName { get; set; } + + [Display(Name = "Street")] + // Add element to row 2 and set the width to 9 of 12 columns + [VxFormElementLayout(RowId = 2, ColSpan = 9)] + [MinLength(5)] + public string Street { get; set; } + + [Display(Name = "Number")] + // Add element to row 2 and set the width to 3 of 12 columns + [VxFormElementLayout(RowId = 2, ColSpan = 3)] + public string Number { get; set; } + + [Display(Name = "Country"), + // Show Placeholder + VxFormElementLayout(Placeholder = "The country you live")] + public string Country { get; set; } + + [Display(Name = "State")] + [MinLength(5)] + public string State { get; set; } + + } +```` +![Another nice form!](https://github.com/Aaltuj/VxFormGenerator/blob/master/Docs/Advanced_sample_form.png) + +There is also support for nested models. + +```C# + public class OrderViewModel + { + // Indicate that this property type should be rendered as a separate elements in the form and give it a label + [VxFormGroup(Label = "Delivery")] + // Use this to valdidate a complex object + [ValidateComplexType] + public AddressViewModel Address { get; set; } = new AddressViewModel(); + + // Indicate that this property type should be rendered as a separate elements in the form and give it a label + [VxFormGroup(Label = "Invoice")] + // Use this to valdidate a complex object + [ValidateComplexType] + public AddressViewModel BillingAddress { get; set; } = new AddressViewModel(); + + [Display(Name = "Send insured")] + public bool Valid { get; set; } = true; + + [Display(Name = "What color box")] + public VxColor Color { get; set; } + } + } +``` +![Another Another nice form!](https://github.com/Aaltuj/VxFormGenerator/blob/master/Docs/complex_sample_form.png) + + +#### Layout options + +The form support multiple rendering options: + +Set options **Global** + +``` + public void ConfigureServices(IServiceCollection services) + { + services.AddRazorPages(); + services.AddServerSideBlazor(); + services.AddVxFormGenerator(new VxFormLayoutOptions() { LabelOrientation = LabelOrientation.TOP }); + } +``` + +Set options at **Component** level, these options override the global one. + +```html + + +@code{ + private VxFormLayoutOptions OptionsForForm = new VxFormLayoutOptions(); +} +``` + +#### Possible options + +*Set the label position for the form* + +**Label position**: Top | Left | None + +*Set the placeholder policy for the form* + +**Placeholder Policy**: Explicit | Implicit | None | ExplicitFallbackToLabels | ImplicitFallbackToLabels + +*Set the trigger for showing validation state* + +**Validation Policy**: OnlyValid | OnlyInvalid | BothValidAndInvalid + + + +### Run demo + +Run the demo so you can see the options and effects interactively: + +1. `git clone https://github.com/Aaltuj/VxFormGenerator.git` +2. `cd VxFormGenerator ` +3. `run.cmd` on Windows or `bash run.sh` on Linux/Mac +4. navigate to `http://localhost:5000/definition-form` + + + ### Apply your own styling -> This is a work in progress \ No newline at end of file +> This is a work in progress + + + +### Contact + +Discord [Server](https://discord.gg/pyCtvFdTdV) + diff --git a/VxFormGenerator.Components.Bootstrap/BootstrapFormElement.razor b/VxFormGenerator.Components.Bootstrap/BootstrapFormElement.razor deleted file mode 100644 index d03dc3d..0000000 --- a/VxFormGenerator.Components.Bootstrap/BootstrapFormElement.razor +++ /dev/null @@ -1,19 +0,0 @@ -@namespace VxFormGenerator.Form - -@typeparam TFormElement -@inherits BootstrapFormElementComponent - - -
- @if (!string.IsNullOrWhiteSpace(Label)) - { - - } -
- @CreateComponent() - - - -
-
- diff --git a/VxFormGenerator.Components.Bootstrap/BootstrapFormElement.razor.cs b/VxFormGenerator.Components.Bootstrap/BootstrapFormElement.razor.cs deleted file mode 100644 index 32f7d1d..0000000 --- a/VxFormGenerator.Components.Bootstrap/BootstrapFormElement.razor.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using VxFormGenerator.Core; - -namespace VxFormGenerator.Form -{ - - public class BootstrapFormElementComponent : FormElementBase - { - public BootstrapFormElementComponent() - { - DefaultFieldClasses = new List() { "form-control"}; - CssClasses = new List() { "form-group", "row" }; - } - } -} diff --git a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputNumber.razor b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputNumber.razor deleted file mode 100644 index 64f5cf7..0000000 --- a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputNumber.razor +++ /dev/null @@ -1,11 +0,0 @@ -@namespace VxFormGenerator.Form.Components.Bootstrap - -@using VxFormGenerator.Core.Validation -@using Microsoft.AspNetCore.Components.Forms - -@typeparam TValue -@inherits VxFormGenerator.Form.Components.Bootstrap.BootstrapInputNumberComponent - - diff --git a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputNumber.razor.cs b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputNumber.razor.cs deleted file mode 100644 index 87b9b6c..0000000 --- a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputNumber.razor.cs +++ /dev/null @@ -1,8 +0,0 @@ - -namespace VxFormGenerator.Form.Components.Bootstrap -{ - public class BootstrapInputNumberComponent : Microsoft.AspNetCore.Components.Forms.InputNumber - { - - } -} diff --git a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.razor.cs b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.cs similarity index 64% rename from VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.razor.cs rename to VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.cs index 0c4832a..b8bc421 100644 --- a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.razor.cs +++ b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.cs @@ -3,9 +3,9 @@ namespace VxFormGenerator.Form.Components.Bootstrap { - public class BootstrapInputSelectWithOptionsComponent: InputSelectWithOptions + public class BootstrapInputSelectWithOptions: InputSelectWithOptions { - public BootstrapInputSelectWithOptionsComponent() + public BootstrapInputSelectWithOptions() { this.AdditionalAttributes = new Dictionary() { { "class", "custom-select" } }; } diff --git a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.razor b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.razor deleted file mode 100644 index 6146fc8..0000000 --- a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputSelectWithOptions.razor +++ /dev/null @@ -1,12 +0,0 @@ -@namespace VxFormGenerator.Form.Components.Bootstrap -@using VxFormGenerator.Core.Validation - -@typeparam TValue -@inherits BootstrapInputSelectWithOptionsComponent - - - - - diff --git a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputText.razor b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputText.razor deleted file mode 100644 index c4aa71c..0000000 --- a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputText.razor +++ /dev/null @@ -1,11 +0,0 @@ - -@namespace VxFormGenerator.Form.Components.Bootstrap - -@using Microsoft.AspNetCore.Components.Forms -@using VxFormGenerator.Core.Validation - -@inherits BootstrapInputTextComponent - - diff --git a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputText.razor.cs b/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputText.razor.cs deleted file mode 100644 index 70432f0..0000000 --- a/VxFormGenerator.Components.Bootstrap/Components/BootstrapInputText.razor.cs +++ /dev/null @@ -1,9 +0,0 @@ - -namespace VxFormGenerator.Form.Components.Bootstrap -{ - public class BootstrapInputTextComponent : Microsoft.AspNetCore.Components.Forms.InputText - { - - } -} - diff --git a/VxFormGenerator.Components.Bootstrap/Properties/launchSettings.json b/VxFormGenerator.Components.Bootstrap/Properties/launchSettings.json new file mode 100644 index 0000000..844e021 --- /dev/null +++ b/VxFormGenerator.Components.Bootstrap/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54318/", + "sslPort": 44371 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "VxFormGenerator.Components.Bootstrap": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/VxFormGenerator.Components.Bootstrap/Render/BootstrapFormElement.razor b/VxFormGenerator.Components.Bootstrap/Render/BootstrapFormElement.razor new file mode 100644 index 0000000..772ffd6 --- /dev/null +++ b/VxFormGenerator.Components.Bootstrap/Render/BootstrapFormElement.razor @@ -0,0 +1,19 @@ +@namespace VxFormGenerator.Render.Bootstrap + +@typeparam TFormElement +@inherits BootstrapFormElementComponent + + +
+ @if (!string.IsNullOrWhiteSpace(FormColumnDefinition.RenderOptions.Label) && FormColumnDefinition.RenderOptions.ShowLabel) + { + + } + + @CreateComponent() + + + + +
+ diff --git a/VxFormGenerator.Components.Bootstrap/Render/BootstrapFormElement.razor.cs b/VxFormGenerator.Components.Bootstrap/Render/BootstrapFormElement.razor.cs new file mode 100644 index 0000000..47a2050 --- /dev/null +++ b/VxFormGenerator.Components.Bootstrap/Render/BootstrapFormElement.razor.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using VxFormGenerator.Core; + +namespace VxFormGenerator.Render.Bootstrap +{ + + public class BootstrapFormElementComponent : FormElementBase + { + public BootstrapFormElementComponent() + { + + } + + protected override void OnInitialized() + { + base.OnInitialized(); + + + } + protected override void OnParametersSet() + { + base.OnParametersSet(); + + + DefaultFieldClasses = new List() { "form-control" }; + CssClasses = new List() { "form-group" }; + } + } +} diff --git a/VxFormGenerator.Components.Bootstrap/VxBootstapFormServiceCollectionExtention.cs b/VxFormGenerator.Components.Bootstrap/VxBootstapFormServiceCollectionExtention.cs deleted file mode 100644 index 2d5cacb..0000000 --- a/VxFormGenerator.Components.Bootstrap/VxBootstapFormServiceCollectionExtention.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using VxFormGenerator.Repository.Bootstrap; - -namespace VxFormGenerator.Settings.Bootstrap -{ - public static class ServiceCollectionExtensions - { - public static void AddVxFormGenerator(this IServiceCollection services, VxBootstrapRepository repository = null, VxBootstrapFormOptions options = null) - { - FormGeneratorServiceServiceCollectionExtension.AddVxFormGenerator(services, repository ?? new VxBootstrapRepository(), options ?? new VxBootstrapFormOptions()); - } - } -} diff --git a/VxFormGenerator.Components.Bootstrap/VxBootstrapFormComponentsRepository.cs b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormComponentsRepository.cs index 66d9611..0534cb8 100644 --- a/VxFormGenerator.Components.Bootstrap/VxBootstrapFormComponentsRepository.cs +++ b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormComponentsRepository.cs @@ -18,19 +18,18 @@ public VxBootstrapRepository() _ComponentDict = new Dictionary() { - { typeof(string), typeof(BootstrapInputText) }, + { typeof(string), typeof(InputText) }, { typeof(DateTime), typeof(InputDate<>) }, { typeof(bool), typeof(BootstrapInputCheckbox) }, { typeof(Enum), typeof(BootstrapInputSelectWithOptions<>) }, { typeof(ValueReferences), typeof(BootstrapInputCheckboxMultiple<>) }, - { typeof(decimal), typeof(BootstrapInputNumber<>) }, - { typeof(int), typeof(BootstrapInputNumber<>) }, + { typeof(decimal), typeof(InputNumber<>) }, + { typeof(int), typeof(InputNumber<>) }, { typeof(VxColor), typeof(InputColor) } }; _DefaultComponent = null; - } } diff --git a/VxFormGenerator.Components.Bootstrap/VxBootstrapFormCssClassProvider.cs b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormCssClassProvider.cs new file mode 100644 index 0000000..babdc23 --- /dev/null +++ b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormCssClassProvider.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Components.Forms; + +namespace VxFormGenerator.Settings.Bootstrap +{ + public class VxBootstrapFormCssClassProvider : VxFormCssClassProviderBase + { + public override VxFormCssClassAttribute CssClassAttribute { get => new VxFormCssClassAttribute() { Valid = "is-valid", Invalid = "is-invalid" }; } + + public override string GetFieldCssClass(EditContext editContext, in FieldIdentifier fieldIdentifier) + { + return base.GetFieldCssClass(editContext, fieldIdentifier); + } + } +} diff --git a/VxFormGenerator.Components.Bootstrap/VxBootstrapFormOptions.cs b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormOptions.cs index aa3c50e..c3f00e3 100644 --- a/VxFormGenerator.Components.Bootstrap/VxBootstrapFormOptions.cs +++ b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormOptions.cs @@ -1,16 +1,29 @@ -using System; +using Microsoft.AspNetCore.Components.Forms; +using System; using VxFormGenerator.Core; using VxFormGenerator.Form; +using VxFormGenerator.Render.Bootstrap; +using VxFormGenerator.Render.Plain; namespace VxFormGenerator.Settings.Bootstrap { public class VxBootstrapFormOptions : IFormGeneratorOptions { + /// + /// + /// public Type FormElementComponent { get; set; } + /// + /// + /// + public FieldCssClassProvider FieldCssClassProvider { get; set; } + public Type FormGroupElement { get; set; } public VxBootstrapFormOptions() { FormElementComponent = typeof(BootstrapFormElement<>); + FormGroupElement = typeof(VxFormGroup); + FieldCssClassProvider = new VxBootstrapFormCssClassProvider(); } } } diff --git a/VxFormGenerator.Components.Bootstrap/VxBootstrapFormServiceCollectionExtention.cs b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormServiceCollectionExtention.cs new file mode 100644 index 0000000..bd37a3c --- /dev/null +++ b/VxFormGenerator.Components.Bootstrap/VxBootstrapFormServiceCollectionExtention.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.DependencyInjection; +using VxFormGenerator.Repository.Bootstrap; + +namespace VxFormGenerator.Settings.Bootstrap +{ + public static class ServiceCollectionExtensions + { + public static void AddVxFormGenerator(this IServiceCollection services, Core.Layout.VxFormLayoutOptions vxFormLayoutOptions = null, VxBootstrapRepository repository = null, VxBootstrapFormOptions options = null) + { + FormGeneratorServiceServiceCollectionExtension.AddVxFormGenerator(services, + vxFormLayoutOptions ?? new Core.Layout.VxFormLayoutOptions(), + repository ?? new VxBootstrapRepository(), + options ?? new VxBootstrapFormOptions() + ); + } + } +} diff --git a/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj b/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj index 2195b47..a53047f 100644 --- a/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj +++ b/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj @@ -1,11 +1,9 @@ - + - netstandard2.1 - 3.0 - true + net5.0 true - 0.1.1 + 0.4.0 Alex Knijf Alex Knijf Codershop @@ -17,12 +15,11 @@ Form generator, Blazor, POCOS VxFormGenerator.Components.Bootstrap VxFormGenerator.Components.Bootstrap - 0.0.6.0 - - + + diff --git a/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj.user b/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj.user new file mode 100644 index 0000000..cff74a9 --- /dev/null +++ b/VxFormGenerator.Components.Bootstrap/VxFormGenerator.Components.Bootstrap.csproj.user @@ -0,0 +1,6 @@ + + + + IIS Express + + \ No newline at end of file diff --git a/VxFormGenerator.Components.Plain/Components/InputCheckboxMultiple.razor.cs b/VxFormGenerator.Components.Plain/Components/InputCheckboxMultiple.razor.cs index f2287cc..7efd6b9 100644 --- a/VxFormGenerator.Components.Plain/Components/InputCheckboxMultiple.razor.cs +++ b/VxFormGenerator.Components.Plain/Components/InputCheckboxMultiple.razor.cs @@ -12,13 +12,13 @@ public class InputCheckboxMultipleComponent : VxInputBase /// [Parameter] public RenderFragment ChildContent { get; set; } - List Checkboxes = new List(); + List Checkboxes = new List(); /// protected override bool TryParseValueFromString(string value, out T result, out string validationErrorMessage) => throw new NotImplementedException($"This component does not parse string inputs. Bind to the '{nameof(CurrentValue)}' property, not '{nameof(CurrentValueAsString)}'."); - internal void RegisterCheckbox(VxInputCheckboxComponent checkbox) + internal void RegisterCheckbox(VxInputCheckbox checkbox) { Checkboxes.Add(checkbox); diff --git a/VxFormGenerator.Components.Plain/Components/InputSelectWithOptions.cs b/VxFormGenerator.Components.Plain/Components/InputSelectWithOptions.cs index 95b9211..cda71d7 100644 --- a/VxFormGenerator.Components.Plain/Components/InputSelectWithOptions.cs +++ b/VxFormGenerator.Components.Plain/Components/InputSelectWithOptions.cs @@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Rendering; using System; +using System.Collections.Generic; +using VxFormGenerator.Components.Plain.Models; using VxFormGenerator.Core; namespace VxFormGenerator.Form.Components.Plain @@ -25,14 +27,18 @@ public static void RenderChildren(RenderTreeBuilder builder, int index, object d // when type is a enum present them as an