Skip to content

Commit b0634f1

Browse files
committed
4.0.1
1 parent 63ef3b3 commit b0634f1

File tree

19 files changed

+242
-47
lines changed

19 files changed

+242
-47
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,7 @@ ASALocalRun/
337337
.localhistory/
338338

339339
# BeatPulse healthcheck temp database
340-
healthchecksdb
340+
healthchecksdb
341+
342+
# macOS File System
343+
*.DS_STORE

.vscode/launch.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/sample/FormHelper.Samples/bin/Debug/net5.0/FormHelper.Samples.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/sample/FormHelper.Samples",
16+
"stopAtEntry": false,
17+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
18+
"serverReadyAction": {
19+
"action": "openExternally",
20+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
21+
},
22+
"env": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"sourceFileMap": {
26+
"/Views": "${workspaceFolder}/Views"
27+
}
28+
},
29+
{
30+
"name": ".NET Core Attach",
31+
"type": "coreclr",
32+
"request": "attach",
33+
"processId": "${command:pickProcess}"
34+
}
35+
]
36+
}

.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/sample/FormHelper.Samples/FormHelper.Samples.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/sample/FormHelper.Samples/FormHelper.Samples.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/sample/FormHelper.Samples/FormHelper.Samples.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ CDN:
4949

5050
ConfigureServices:
5151
```
52-
services.AddFormHelper();
52+
services.AddControllersWithViews().AddFormHelper();
5353
```
5454
*With configuration: (optional)*
5555
```
56-
services.AddFormHelper(new FormHelperConfiguration
57-
{
56+
services.AddControllersWithViews().AddFormHelper(options => {
5857
CheckTheFormFieldsMessage = "Your custom message...",
59-
RedirectDelay = 6000
58+
RedirectDelay = 6000,
59+
EmbeddedFiles = false
6060
});
6161
```
6262
Configure:
@@ -81,7 +81,7 @@ app.UseFormHelper();
8181

8282
// You can use <form asp-formhelper="true"> or <formhelper> to activate formhelper.
8383
// Optional parameters:
84-
// asp-callback="...", asp-beforeSubmit="...", asp-dataType="FormData/Json", asp-enableButtonAfterSuccess="false", asp-resetFormAfterSuccess="true" asp-toastrPosition="ToastrPosition.BottomRight"
84+
// asp-callback="javascriptFunctionName", asp-beforeSubmit="javascriptFunctionName", asp-dataType="FormData/Json", asp-enableButtonAfterSuccess="false", asp-resetFormAfterSuccess="true" asp-toastrPosition="ToastrPosition.BottomRight"
8585
```
8686

8787
**Controller:**
@@ -116,3 +116,22 @@ return FormResult.CreateSuccessResult("Product saved. Please wait...", Url.Actio
116116
```
117117
$("#formId").fillFormFields(yourJsonObject);
118118
```
119+
120+
**Toastr:**
121+
122+
Success:
123+
```
124+
formHelperToastr.success("Text here");
125+
```
126+
Warning:
127+
```
128+
formHelperToastr.warning("Text here");
129+
```
130+
Information:
131+
```
132+
formHelperToastr.information("Text here");
133+
```
134+
Error:
135+
```
136+
formHelperToastr.error("Text here");
137+
```

dist/formhelper.bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formhelper.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/FormHelper.Samples/FormHelper.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
<ItemGroup>
21-
<PackageReference Include="FluentValidation.AspNetCore" Version="9.3.0" />
21+
<PackageReference Include="FluentValidation.AspNetCore" Version="9.5.3" />
2222
</ItemGroup>
2323

2424
</Project>

sample/FormHelper.Samples/Startup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ public Startup(IConfiguration configuration)
2222
public void ConfigureServices(IServiceCollection services)
2323
{
2424
services.AddControllersWithViews()
25+
.AddFormHelper(opt => { opt.CheckTheFormFieldsMessage = "selam"; })
2526
.AddFluentValidation();
2627

2728
// You can add these validators in a separate class.
2829
services.AddTransient<IValidator<ProductFormViewModel>, ProductFormViewModelValidator>();
2930

3031
// Add FormHelper to the project.
31-
services.AddFormHelper();
32+
//services.AddFormHelper();
3233

3334
// Add FormHelper to the project with configurations.
3435
//services.AddFormHelper(new FormHelperConfiguration

sample/FormHelper.Samples/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
<script src="~/js/site.js" asp-append-version="true"></script>
6464

65-
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
65+
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
6666
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
6767
<script src="/formhelper/formhelper.bundle.min.js"></script>
6868
<!-- remote modal -->
Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
22
using Microsoft.Extensions.DependencyInjection;
33
using Microsoft.Extensions.FileProviders;
4+
using System;
45
using System.Reflection;
56

67
namespace FormHelper
78
{
89
public static class ServiceCollectionExtensions
910
{
10-
public static IServiceCollection AddFormHelper(this IServiceCollection services, FormHelperConfiguration config = null)
11+
public static IMvcBuilder AddFormHelper(this IMvcBuilder builder, Action<FormHelperOptions> options = null)
1112
{
12-
if (config == null)
13-
services.AddSingleton<FormHelperConfiguration>();
14-
else
15-
services.AddSingleton(config);
13+
var _options = new FormHelperOptions
14+
{
15+
CheckTheFormFieldsMessage = "Check the form fields.",
16+
RedirectDelay = 1500,
17+
ToastrDefaultPosition = ToastrPosition.TopRight
18+
};
1619

17-
services.Configure<MvcRazorRuntimeCompilationOptions>(opts =>
18-
opts.FileProviders.Add(new EmbeddedFileProvider(typeof(FormHelperHtmlHelpers).GetTypeInfo().Assembly)));
20+
if (options != null)
21+
{
22+
options(_options);
23+
}
1924

20-
return services;
25+
builder.Services.AddSingleton(_options);
26+
27+
if (_options.EmbeddedFiles == true)
28+
{
29+
builder.Services.Configure<MvcRazorRuntimeCompilationOptions>(options =>
30+
{
31+
options.FileProviders.Add(new EmbeddedFileProvider(typeof(FormHelperHtmlHelpers).GetTypeInfo().Assembly));
32+
});
33+
}
34+
35+
return builder;
2136
}
2237
}
2338
}

0 commit comments

Comments
 (0)