From b335898a8c48a296c8a67bf9f1d0f2ec8829a664 Mon Sep 17 00:00:00 2001 From: Salih Date: Sun, 7 May 2023 15:49:25 +0300 Subject: [PATCH 1/6] Fix Mvc dynamic Form DateTimePicker Error --- .../bootstrap/dom-event-handlers.js | 21 +++++++++++-------- .../bootstrap/modal-manager.js | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index 945df5d0c6f..f62dbdb011a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -772,17 +772,20 @@ abp.event.on('abp.configurationInitialized', function () { abp.libs.bootstrapDatepicker.normalizeLanguageConfig(); }); + + abp.dom.initializers.initializeAll = function ($rootNode) { + abp.dom.initializers.initializeToolTips($rootNode.findWithSelf('[data-toggle="tooltip"]')); + abp.dom.initializers.initializePopovers($rootNode.findWithSelf('[data-toggle="popover"]')); + abp.dom.initializers.initializeTimeAgos($rootNode.findWithSelf('.timeago')); + abp.dom.initializers.initializeDatepickers($rootNode); + abp.dom.initializers.initializeDateRangePickers($rootNode); + abp.dom.initializers.initializeForms($rootNode.findWithSelf('form')); + abp.dom.initializers.initializeAutocompleteSelects($rootNode.findWithSelf('.auto-complete-select')); + $rootNode.findWithSelf('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); + }; $(function () { - abp.dom.initializers.initializeToolTips($('[data-toggle="tooltip"]')); - abp.dom.initializers.initializePopovers($('[data-toggle="popover"]')); - abp.dom.initializers.initializeTimeAgos($('.timeago')); - abp.dom.initializers.initializeDatepickers($(document)); - abp.dom.initializers.initializeDateRangePickers($(document)); - abp.dom.initializers.initializeForms($('form')); - abp.dom.initializers.initializeAutocompleteSelects($('.auto-complete-select')); - $('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); - + abp.dom.initializers.initializeAll($(document)); }); })(jQuery); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js index e5248811764..9a198690500 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js @@ -66,6 +66,7 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f } function _initAndShowModal() { + abp.dom.initializers.initializeAll(_$modalContainer); _$modal = _$modalContainer.find('.modal'); _$form = _$modalContainer.find('form'); if (_$form.length) { From 1ee99e371013195289aa5849ed48658df795abd5 Mon Sep 17 00:00:00 2001 From: Salih Date: Sun, 7 May 2023 15:50:01 +0300 Subject: [PATCH 2/6] Fix single datepicker end date assignment bug --- .../bootstrap/dom-event-handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index f62dbdb011a..8157778059d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -644,7 +644,7 @@ if (momentStartDate.isValid()) { picker.setStartDate(momentStartDate); } - if (momentEndDate.isValid()) { + if (momentEndDate.isValid() && !singleDatePicker) { picker.setEndDate(momentEndDate); } }); From 9209cafffcac37d901222764c9cca44bd54feb03 Mon Sep 17 00:00:00 2001 From: Salih Date: Mon, 8 May 2023 10:38:04 +0300 Subject: [PATCH 3/6] Fix DatePickerOptions --- .../DatePicker/AbpDatePickerBaseTagHelper.cs | 7 ++++++- .../AbpDatePickerBaseTagHelperService.cs | 14 +++++-------- .../bootstrap/dom-event-handlers.js | 21 +++++++++---------- .../bootstrap/modal-manager.js | 1 - 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelper.cs index 10923f25af6..7f9c34fb7ab 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelper.cs @@ -9,7 +9,7 @@ public abstract class where TTagHelper : AbpDatePickerBaseTagHelper { - private readonly IAbpDatePickerOptions _abpDatePickerOptionsImplementation; + private IAbpDatePickerOptions _abpDatePickerOptionsImplementation; public string Label { get; set; } @@ -47,6 +47,11 @@ protected AbpDatePickerBaseTagHelper(AbpDatePickerBaseTagHelperService _abpDatePickerOptionsImplementation.PickerId; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs index c1ecc4b32dd..3d7c857dbd4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs @@ -84,6 +84,11 @@ public async override Task ProcessAsync(TagHelperContext context, TagHelperOutpu AddReadOnlyAttribute(TagHelperOutput); AddPlaceholderAttribute(TagHelperOutput); AddInfoTextId(TagHelperOutput); + var optionsAttribute = GetAttributeAndModelExpression(out var modelExpression); + if (optionsAttribute != null) + { + TagHelper.SetDatePickerOptions(optionsAttribute.GetDatePickerOptions(modelExpression.ModelExplorer)); + } // Open and close button var openButtonContent = TagHelper.OpenButton @@ -426,15 +431,6 @@ protected TagHelperAttributeList GetBaseTagAttributes(TagHelperContext context, attrList.Add(attr); } - var optionsAttribute = GetAttributeAndModelExpression(out var modelExpression); - if (optionsAttribute != null) - { - foreach (var attr in ConvertDatePickerOptionsToAttributeList(optionsAttribute.GetDatePickerOptions(modelExpression.ModelExplorer))) - { - attrList.Add(attr); - } - } - AddBaseTagAttributes(attrList); return attrList; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index 8157778059d..aec8582651c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -643,6 +643,7 @@ var momentEndDate = getMoment(endDate, options); if (momentStartDate.isValid()) { picker.setStartDate(momentStartDate); + picker.setEndDate(momentEndDate); } if (momentEndDate.isValid() && !singleDatePicker) { picker.setEndDate(momentEndDate); @@ -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) { @@ -773,19 +775,16 @@ abp.libs.bootstrapDatepicker.normalizeLanguageConfig(); }); - abp.dom.initializers.initializeAll = function ($rootNode) { - abp.dom.initializers.initializeToolTips($rootNode.findWithSelf('[data-toggle="tooltip"]')); - abp.dom.initializers.initializePopovers($rootNode.findWithSelf('[data-toggle="popover"]')); - abp.dom.initializers.initializeTimeAgos($rootNode.findWithSelf('.timeago')); - abp.dom.initializers.initializeDatepickers($rootNode); - abp.dom.initializers.initializeDateRangePickers($rootNode); - abp.dom.initializers.initializeForms($rootNode.findWithSelf('form')); - abp.dom.initializers.initializeAutocompleteSelects($rootNode.findWithSelf('.auto-complete-select')); - $rootNode.findWithSelf('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); - }; $(function () { - abp.dom.initializers.initializeAll($(document)); + abp.dom.initializers.initializeToolTips($(document).findWithSelf('[data-toggle="tooltip"]')); + abp.dom.initializers.initializePopovers($(document).findWithSelf('[data-toggle="popover"]')); + abp.dom.initializers.initializeTimeAgos($(document).findWithSelf('.timeago')); + abp.dom.initializers.initializeDatepickers($(document)); + abp.dom.initializers.initializeDateRangePickers($(document)); + abp.dom.initializers.initializeForms($(document).findWithSelf('form')); + abp.dom.initializers.initializeAutocompleteSelects($(document).findWithSelf('.auto-complete-select')); + $(document).findWithSelf('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); }); })(jQuery); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js index 9a198690500..e5248811764 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js @@ -66,7 +66,6 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f } function _initAndShowModal() { - abp.dom.initializers.initializeAll(_$modalContainer); _$modal = _$modalContainer.find('.modal'); _$form = _$modalContainer.find('form'); if (_$form.length) { From 2f9e2c54c5c4ac8a59ffdff45af04d5c25783f69 Mon Sep 17 00:00:00 2001 From: Salih Date: Mon, 8 May 2023 10:38:04 +0300 Subject: [PATCH 4/6] Fix DatePickerOptions From 02cdb681fb33e767eaa57c8afe5b793cf9b84e0e Mon Sep 17 00:00:00 2001 From: Salih Date: Mon, 15 May 2023 10:25:29 +0300 Subject: [PATCH 5/6] Update disabled input --- .../Form/DatePicker/AbpDatePickerBaseTagHelperService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs index 3d7c857dbd4..6e5f0ad2f7a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/DatePicker/AbpDatePickerBaseTagHelperService.cs @@ -587,7 +587,7 @@ protected virtual async Task ProcessButtonAndGetContentAsync(TagHelperCo abpButtonTagHelper.ButtonType = AbpButtonType.Outline_Secondary; abpButtonTagHelper.Icon = icon; - abpButtonTagHelper.Disabled = TagHelper.IsDisabled; + abpButtonTagHelper.Disabled = TagHelper.IsDisabled || GetAttribute() != null; if (!visible) { From aa65debbafc091c636ed9c44318ecd06836e24ff Mon Sep 17 00:00:00 2001 From: Salih Date: Mon, 15 May 2023 10:57:58 +0300 Subject: [PATCH 6/6] Update dom-event-handlers.js --- .../bootstrap/dom-event-handlers.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index aec8582651c..6501c23a14c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -777,14 +777,14 @@ $(function () { - abp.dom.initializers.initializeToolTips($(document).findWithSelf('[data-toggle="tooltip"]')); - abp.dom.initializers.initializePopovers($(document).findWithSelf('[data-toggle="popover"]')); - abp.dom.initializers.initializeTimeAgos($(document).findWithSelf('.timeago')); + abp.dom.initializers.initializeToolTips($('[data-toggle="tooltip"]')); + abp.dom.initializers.initializePopovers($('[data-toggle="popover"]')); + abp.dom.initializers.initializeTimeAgos($('.timeago')); abp.dom.initializers.initializeDatepickers($(document)); abp.dom.initializers.initializeDateRangePickers($(document)); - abp.dom.initializers.initializeForms($(document).findWithSelf('form')); - abp.dom.initializers.initializeAutocompleteSelects($(document).findWithSelf('.auto-complete-select')); - $(document).findWithSelf('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); + abp.dom.initializers.initializeForms($('form')); + abp.dom.initializers.initializeAutocompleteSelects($('.auto-complete-select')); + $('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); }); })(jQuery);