From 0a55297f8b71a2e017caafb345b2878979eccd9e Mon Sep 17 00:00:00 2001 From: Salih Date: Tue, 27 Sep 2022 11:18:02 +0300 Subject: [PATCH] =?UTF-8?q?Fixed=20cms-kit=20=C4=B0nvalid=20Date=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/CmsKit/Comments/Index.cshtml | 4 +-- .../Pages/CmsKit/Comments/index.js | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml index 93dfc2aa4d..1bb83f989c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml @@ -15,8 +15,6 @@ PageLayout.Content.Title = L["Comments"].Value; PageLayout.Content.BreadCrumb.Add(L["Menu:CMS"].Value); PageLayout.Content.MenuItemName = CmsKitAdminMenus.Comments.CommentsMenu; - - var defaultStartDate = DateTime.Now.AddDays(-7).Date.ToShortDateString(); } @section styles{ @@ -41,7 +39,7 @@ - + diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js index d3190661eb..728a204f4c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js @@ -5,10 +5,20 @@ $(function (){ var detailsModal = new abp.ModalManager(abp.appPath + "CmsKit/Comments/DetailsModal"); + moment()._locale.preparse = (string) => string; + moment()._locale.postformat = (string) => string; + var getFormattedDate = function ($datePicker) { - return $datePicker.data('date'); + if(!$datePicker.val()) { + return null; + } + var momentDate = moment($datePicker.val(), $datePicker.data('daterangepicker').locale.format); + return momentDate.isValid() ? momentDate.toISOString() : null; }; - + + + var defaultStartDate = moment().add(-7, 'days'); + $("#CreationStartDate").val(defaultStartDate.format('L')); $('.singledatepicker').daterangepicker({ "singleDatePicker": true, @@ -16,25 +26,25 @@ $(function (){ "autoUpdateInput": false, "autoApply": true, "opens": "center", - "drops": "auto", - "minYear": 1901, - "maxYear": 2199, + "drops": "auto" }); + + $('.singledatepicker').attr('autocomplete', 'off'); $('.singledatepicker').on('apply.daterangepicker', function (ev, picker) { $(this).val(picker.startDate.format('l')); - $(this).data('date', picker.startDate.locale('en').format('YYYY-MM-DD')); }); + var filterForm = $('#CmsKitCommentsFilterForm'); var getFilter = function () { var filterObj = filterForm.serializeFormToObject(); - filterObj.creationStartDate = getFormattedDate($('#creationStartDate')); - filterObj.creationEndDate = getFormattedDate($('#creationEndDate')); + filterObj.creationStartDate = getFormattedDate($('#CreationStartDate')); + filterObj.creationEndDate = getFormattedDate($('#CreationEndDate')); return filterObj; };