Merge pull request #16561 from abpframework/issue-16494-1

Fix Mvc dynamic Form DateTimePicker Error
pull/16564/head
Yunus Emre Kalkan 2 years ago committed by GitHub
commit fd96b47201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,7 +9,7 @@ public abstract class
where TTagHelper : AbpDatePickerBaseTagHelper<TTagHelper> where TTagHelper : AbpDatePickerBaseTagHelper<TTagHelper>
{ {
private readonly IAbpDatePickerOptions _abpDatePickerOptionsImplementation; private IAbpDatePickerOptions _abpDatePickerOptionsImplementation;
public string Label { get; set; } public string Label { get; set; }
@ -47,6 +47,11 @@ public abstract class
{ {
_abpDatePickerOptionsImplementation = new AbpDatePickerOptions(); _abpDatePickerOptionsImplementation = new AbpDatePickerOptions();
} }
public void SetDatePickerOptions(IAbpDatePickerOptions options)
{
_abpDatePickerOptionsImplementation = options;
}
public string PickerId { public string PickerId {
get => _abpDatePickerOptionsImplementation.PickerId; get => _abpDatePickerOptionsImplementation.PickerId;

@ -84,6 +84,11 @@ public abstract class AbpDatePickerBaseTagHelperService<TTagHelper> : AbpTagHelp
AddReadOnlyAttribute(TagHelperOutput); AddReadOnlyAttribute(TagHelperOutput);
AddPlaceholderAttribute(TagHelperOutput); AddPlaceholderAttribute(TagHelperOutput);
AddInfoTextId(TagHelperOutput); AddInfoTextId(TagHelperOutput);
var optionsAttribute = GetAttributeAndModelExpression<DatePickerOptionsAttribute>(out var modelExpression);
if (optionsAttribute != null)
{
TagHelper.SetDatePickerOptions(optionsAttribute.GetDatePickerOptions(modelExpression.ModelExplorer));
}
// Open and close button // Open and close button
var openButtonContent = TagHelper.OpenButton var openButtonContent = TagHelper.OpenButton
@ -426,15 +431,6 @@ public abstract class AbpDatePickerBaseTagHelperService<TTagHelper> : AbpTagHelp
attrList.Add(attr); 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); AddBaseTagAttributes(attrList);
return attrList; return attrList;
@ -591,7 +587,7 @@ public abstract class AbpDatePickerBaseTagHelperService<TTagHelper> : AbpTagHelp
abpButtonTagHelper.ButtonType = AbpButtonType.Outline_Secondary; abpButtonTagHelper.ButtonType = AbpButtonType.Outline_Secondary;
abpButtonTagHelper.Icon = icon; abpButtonTagHelper.Icon = icon;
abpButtonTagHelper.Disabled = TagHelper.IsDisabled; abpButtonTagHelper.Disabled = TagHelper.IsDisabled || GetAttribute<DisabledInput>() != null;
if (!visible) if (!visible)
{ {

@ -643,8 +643,9 @@
var momentEndDate = getMoment(endDate, options); var momentEndDate = getMoment(endDate, options);
if (momentStartDate.isValid()) { if (momentStartDate.isValid()) {
picker.setStartDate(momentStartDate); picker.setStartDate(momentStartDate);
picker.setEndDate(momentEndDate);
} }
if (momentEndDate.isValid()) { if (momentEndDate.isValid() && !singleDatePicker) {
picker.setEndDate(momentEndDate); picker.setEndDate(momentEndDate);
} }
}); });
@ -761,6 +762,7 @@
abp.dom.initializers.initializeForms(args.$el.findWithSelf('form'), true); abp.dom.initializers.initializeForms(args.$el.findWithSelf('form'), true);
abp.dom.initializers.initializeScript(args.$el); abp.dom.initializers.initializeScript(args.$el);
abp.dom.initializers.initializeAutocompleteSelects(args.$el.findWithSelf('.auto-complete-select')); abp.dom.initializers.initializeAutocompleteSelects(args.$el.findWithSelf('.auto-complete-select'));
abp.dom.initializers.initializeDateRangePickers(args.$el);
}); });
abp.dom.onNodeRemoved(function (args) { abp.dom.onNodeRemoved(function (args) {
@ -772,6 +774,7 @@
abp.event.on('abp.configurationInitialized', function () { abp.event.on('abp.configurationInitialized', function () {
abp.libs.bootstrapDatepicker.normalizeLanguageConfig(); abp.libs.bootstrapDatepicker.normalizeLanguageConfig();
}); });
$(function () { $(function () {
abp.dom.initializers.initializeToolTips($('[data-toggle="tooltip"]')); abp.dom.initializers.initializeToolTips($('[data-toggle="tooltip"]'));
@ -782,7 +785,6 @@
abp.dom.initializers.initializeForms($('form')); abp.dom.initializers.initializeForms($('form'));
abp.dom.initializers.initializeAutocompleteSelects($('.auto-complete-select')); abp.dom.initializers.initializeAutocompleteSelects($('.auto-complete-select'));
$('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); $('[data-auto-focus="true"]').first().findWithSelf('input,select').focus();
}); });
})(jQuery); })(jQuery);

Loading…
Cancel
Save