Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mvc dynamic Form DateTimePicker Error #16561

Merged
merged 6 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public abstract class
where TTagHelper : AbpDatePickerBaseTagHelper<TTagHelper>

{
private readonly IAbpDatePickerOptions _abpDatePickerOptionsImplementation;
private IAbpDatePickerOptions _abpDatePickerOptionsImplementation;

public string Label { get; set; }

Expand Down Expand Up @@ -47,6 +47,11 @@ protected AbpDatePickerBaseTagHelper(AbpDatePickerBaseTagHelperService<TTagHelpe
{
_abpDatePickerOptionsImplementation = new AbpDatePickerOptions();
}

public void SetDatePickerOptions(IAbpDatePickerOptions options)
{
_abpDatePickerOptionsImplementation = options;
}

public string PickerId {
get => _abpDatePickerOptionsImplementation.PickerId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public async override Task ProcessAsync(TagHelperContext context, TagHelperOutpu
AddReadOnlyAttribute(TagHelperOutput);
AddPlaceholderAttribute(TagHelperOutput);
AddInfoTextId(TagHelperOutput);
var optionsAttribute = GetAttributeAndModelExpression<DatePickerOptionsAttribute>(out var modelExpression);
if (optionsAttribute != null)
{
TagHelper.SetDatePickerOptions(optionsAttribute.GetDatePickerOptions(modelExpression.ModelExplorer));
}

// Open and close button
var openButtonContent = TagHelper.OpenButton
Expand Down Expand Up @@ -426,15 +431,6 @@ protected TagHelperAttributeList GetBaseTagAttributes(TagHelperContext context,
attrList.Add(attr);
}

var optionsAttribute = GetAttributeAndModelExpression<DatePickerOptionsAttribute>(out var modelExpression);
if (optionsAttribute != null)
{
foreach (var attr in ConvertDatePickerOptionsToAttributeList(optionsAttribute.GetDatePickerOptions(modelExpression.ModelExplorer)))
{
attrList.Add(attr);
}
}

AddBaseTagAttributes(attrList);

return attrList;
Expand Down Expand Up @@ -591,7 +587,7 @@ protected virtual async Task<string> ProcessButtonAndGetContentAsync(TagHelperCo
abpButtonTagHelper.ButtonType = AbpButtonType.Outline_Secondary;
abpButtonTagHelper.Icon = icon;

abpButtonTagHelper.Disabled = TagHelper.IsDisabled;
abpButtonTagHelper.Disabled = TagHelper.IsDisabled || GetAttribute<DisabledInput>() != null;

if (!visible)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,9 @@
var momentEndDate = getMoment(endDate, options);
if (momentStartDate.isValid()) {
picker.setStartDate(momentStartDate);
picker.setEndDate(momentEndDate);
}
if (momentEndDate.isValid()) {
if (momentEndDate.isValid() && !singleDatePicker) {
picker.setEndDate(momentEndDate);
}
});
Expand Down Expand Up @@ -761,6 +762,7 @@
abp.dom.initializers.initializeForms(args.$el.findWithSelf('form'), true);
abp.dom.initializers.initializeScript(args.$el);
abp.dom.initializers.initializeAutocompleteSelects(args.$el.findWithSelf('.auto-complete-select'));
abp.dom.initializers.initializeDateRangePickers(args.$el);
});

abp.dom.onNodeRemoved(function (args) {
Expand All @@ -772,6 +774,7 @@
abp.event.on('abp.configurationInitialized', function () {
abp.libs.bootstrapDatepicker.normalizeLanguageConfig();
});


$(function () {
abp.dom.initializers.initializeToolTips($('[data-toggle="tooltip"]'));
Expand All @@ -782,7 +785,6 @@
abp.dom.initializers.initializeForms($('form'));
abp.dom.initializers.initializeAutocompleteSelects($('.auto-complete-select'));
$('[data-auto-focus="true"]').first().findWithSelf('input,select').focus();

});

})(jQuery);