Skip to content

Commit

Permalink
Merge branch 'release/v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Knijf committed Jan 6, 2021
2 parents ca2d0f8 + b03f943 commit dbb40ff
Show file tree
Hide file tree
Showing 94 changed files with 2,555 additions and 375 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 12 additions & 2 deletions Demo/FormGeneratorDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(RunConfiguration)' == 'Watch' " />

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Bootstrap'">
<DefineConstants>TRACE; BOOTSTRAP;</DefineConstants>
</PropertyGroup>


<ItemGroup>
<Compile Remove="Components\**" />
<Content Remove="Components\**" />
Expand All @@ -16,6 +25,7 @@
<ItemGroup>
<ProjectReference Include="..\VxFormGenerator.Components.Bootstrap\VxFormGenerator.Components.Bootstrap.csproj" />
<ProjectReference Include="..\VxFormGenerator.Components.Plain\VxFormGenerator.Components.Plain.csproj" />
<ProjectReference Include="..\VxFormGeneratorDemoData\VxFormGeneratorDemoData.csproj" />
</ItemGroup>

</Project>
96 changes: 96 additions & 0 deletions Demo/Pages/FormDefinitionForm.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
@page "/definition-form"

@using VxFormGenerator.Core
@using VxFormGenerator.Core.Layout
@using VxFormGeneratorDemoData


<h1>Model Based Form Demo</h1>

<div class="card">
<div class="card-header">
Change form options
</div>
<div class="card-body">

<EditForm Model="Options"
OnSubmit="ChangeLayoutOptions">
<VxFormGenerator.Core.Validation.ObjectGraphDataAnnotationsValidator />
<RenderFormElements></RenderFormElements>
<button class="btn btn-primary" type="submit">Submit</button>
</EditForm>

</div>
</div>
<br />

<div class="card">
<div class="card-header">
Generated by POCO
</div>
<div class="card-body">

<EditForm Model="Model"
OnValidSubmit="HandleValidSubmit"
OnInvalidSubmit="HandleInValidSubmit">
<VxFormGenerator.Core.Validation.ObjectGraphDataAnnotationsValidator />
<RenderFormElements FormLayoutOptions="@OptionsForForm"></RenderFormElements>
<button class="btn btn-primary" type="submit">Submit</button>
</EditForm>
</div>
</div>

<br />

@code{

/// <summary>
/// Model that is used for the form
/// </summary>
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));
}

/// <summary>
/// Will handle the submit action of the form
/// </summary>
/// <param name="context">The model with values as entered in the form</param>
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;
}

}

}
12 changes: 4 additions & 8 deletions Demo/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
@page "/"

@using VxFormGenerator.Core
@using FormGeneratorDemo.Data
@using System.Dynamic

<h1>VxFormGenerator Demo</h1>
<br />

<div class="row">
<div class="col-sm-6">
<div class="col-sm-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Model based form</h5>
<p class="card-text">Render a form with validation based on a POCO</p>
<a href="model-form" class="btn btn-primary">Go to demo</a>
<p class="card-text">Render a form with layout information</p>
<a href="definition-form" class="btn btn-primary">Go to demo</a>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Dynamic based form</h5>
Expand All @@ -28,6 +27,3 @@
</div>
</div>


@code{
}
44 changes: 0 additions & 44 deletions Demo/Pages/ModelForm.razor

This file was deleted.

2 changes: 1 addition & 1 deletion Demo/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
setTimeout(function () {
document.location.reload();
},5000)
},10000)
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion Demo/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="model-form" Match="NavLinkMatch.All">
<NavLink class="nav-link" href="definition-form" Match="NavLinkMatch.All">
<span class="oi oi-task" aria-hidden="true"></span> Model based form
</NavLink>
</li>
Expand Down
9 changes: 8 additions & 1 deletion Demo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
20 changes: 17 additions & 3 deletions Demo/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {

}
12 changes: 12 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

<Project>
<PropertyGroup>
<Deterministic>true</Deterministic>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project>
Binary file added Docs/Advanced_sample_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/complex_sample_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/discord-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions FormGeneratorDemo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit dbb40ff

Please sign in to comment.