Skip to content

Commit

Permalink
örnek form ve grid yapısı oluşturuldu.
Browse files Browse the repository at this point in the history
  • Loading branch information
sinanbozkus committed Jun 30, 2021
1 parent cf3526b commit f169a61
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/FormHelper/FormHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>FormHelper</PackageId>
<Version>4.0.1</Version>
<Version>4.1.0-betazç</Version>
<Authors>Sinan BOZKUS</Authors>
<projectUrl>https://github.com/sinanbozkus/FormHelper</projectUrl>
<RepositoryUrl>https://github.com/sinanbozkus/FormHelper</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/FormHelper/Scripts/formhelper.bundle.min.js

Large diffs are not rendered by default.

30 changes: 17 additions & 13 deletions src/FormHelper/Scripts/formhelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
warning: 'warning'
};

var formHelperToastr = {
var fhToastr = {
clear: clear,
remove: remove,
error: error,
Expand All @@ -28,7 +28,7 @@

var previousToast;

return formHelperToastr;
return fhToastr;

////////////////

Expand Down Expand Up @@ -438,7 +438,7 @@
}

function getOptions() {
return $.extend({}, getDefaults(), formHelperToastr.options);
return $.extend({}, getDefaults(), fhToastr.options);
}

function removeToast($toastElement) {
Expand All @@ -460,7 +460,7 @@
if (typeof module !== 'undefined' && module.exports) { //Node
module.exports = factory(require('jquery'));
} else {
window.formHelperToastr = factory(window.jQuery);
window.fhToastr = factory(window.jQuery);
}
}));

Expand Down Expand Up @@ -531,8 +531,8 @@
// });

if (!validationResult) {
if (formHelperToastr) {
formHelperToastr.error(options.checkTheFormFieldsMessage, null, toastrOptions);
if (fhToastr) {
fhToastr.error(options.checkTheFormFieldsMessage, null, toastrOptions);
validator.focusInvalid();
}
return false;
Expand Down Expand Up @@ -597,16 +597,16 @@
if (hasMessage) {

if (result.status === 1) {
formHelperToastr.success(result.message, null, toastrOptions);
fhToastr.success(result.message, null, toastrOptions);
} else if (result.status === 2) {
formHelperToastr.info(result.message, null, toastrOptions);
fhToastr.info(result.message, null, toastrOptions);
} else if (result.status === 3) {
formHelperToastr.warning(result.message, null, toastrOptions);
fhToastr.warning(result.message, null, toastrOptions);
} else if (result.status === 4) {
formHelperToastr.error(result.message, null, toastrOptions);
fhToastr.error(result.message, null, toastrOptions);
}
} else if (result.isSucceed === false) {
formHelperToastr.error(options.checkTheFormFieldsMessage, null, toastrOptions);
fhToastr.error(options.checkTheFormFieldsMessage, null, toastrOptions);
}

if (result.validationErrors && result.validationErrors.length > 0) {
Expand Down Expand Up @@ -649,7 +649,7 @@
},
error: function (request, status, error) {
console.error(request.responseText);
formHelperToastr.error(request.responseText, null, toastrOptions);
fhToastr.error(request.responseText, null, toastrOptions);
}
});

Expand Down Expand Up @@ -701,6 +701,10 @@

};

$.fn.resetFormFields = function() {
this[0].reset();
}

$.fn.fillFormFields = function (data, callbacks) {

var that = this;
Expand All @@ -713,7 +717,7 @@
if (options.data !== null) {
$.each(options.data, function (k, v) {

if (options.callbacks !== null && options.callbacks.hasOwnProperty(k)) {
if (options.callbacks !== null && options.callbacks?.hasOwnProperty(k)) {
options.callbacks[k](v);
} else {
$('[name="' + k + '"]', that).val(v);
Expand Down
2 changes: 1 addition & 1 deletion src/FormHelper/Scripts/formhelper.min.js

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion src/FormHelper/TagHelpers/FormTagHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ public FormHelperTagHelper(IHtmlGenerator generator) : base(generator)

[HtmlAttributeName("asp-enableButtonAfterSuccess")]
public bool EnableButtonAfterSuccess { get; set; } = false;

[HtmlAttributeName("asp-resetFormAfterSuccess")]
public bool ResetFormAfterSuccess { get; set; } = true;

[HtmlAttributeName("asp-toastrPosition")]
public ToastrPosition? ToastrPosition { get; set; }

[HtmlAttributeName("asp-addLoadEventListener")]
public bool? AddLoadEventListener { get; set; }


public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var usedFormHelperTag = output.TagName == "formhelper";
Expand Down Expand Up @@ -89,7 +96,21 @@ public async override Task ProcessAsync(TagHelperContext context, TagHelperOutpu
output.Attributes.Add("enableButtonAfterSuccess", EnableButtonAfterSuccess);
output.Attributes.Add("resetFormAfterSuccess", ResetFormAfterSuccess);
output.Attributes.Add("checkTheFormFieldsMessage", configuration.CheckTheFormFieldsMessage);
output.PostElement.AppendHtml($"<script>window.addEventListener('load',function () {{$('#{formId}').UseFormHelper();}});</script>");

if (AddLoadEventListener.HasValue)
{
if (AddLoadEventListener.Value == true)
output.PostElement.AppendHtml($"<script>window.addEventListener('load',function () {{$('#{formId}').UseFormHelper();}});</script>");
else
output.PostElement.AppendHtml($"<script>$('#{formId}').UseFormHelper();</script>");
}
else
{
if (configuration.AddLoadEventListener == true)
output.PostElement.AppendHtml($"<script>window.addEventListener('load',function () {{$('#{formId}').UseFormHelper();}});</script>");
else
output.PostElement.AppendHtml($"<script>$('#{formId}').UseFormHelper();</script>");
}

if (usedFormHelperTag)
{
Expand Down
1 change: 1 addition & 0 deletions src/FormHelper/Types/FormHelperOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class FormHelperOptions
public int RedirectDelay { get; set; } = 1500;
public ToastrPosition ToastrDefaultPosition = ToastrPosition.TopRight;
public bool EmbeddedFiles {get; set;} = true;
public bool AddLoadEventListener { get; set; } = true;
}
}

0 comments on commit f169a61

Please sign in to comment.