Browse Source

Merge pull request #14151 from abpframework/salihozkara/daterangepicker

Fixed cms-kit İnvalid Date error
pull/14193/head
Alper Ebiçoğlu 4 years ago
committed by GitHub
parent
commit
317eb03942
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/Index.cshtml
  2. 26
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js

4
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 @@
<abp-column size-lg="_4" size-md="_12">
<abp-row>
<abp-column size-lg="_6" size-md="_6">
<abp-input asp-for="@Model.CreationStartDate" class="singledatepicker" label="@L["StartDate"].Value" value="@defaultStartDate" type="text" />
<abp-input asp-for="@Model.CreationStartDate" class="singledatepicker" label="@L["StartDate"].Value" type="text" />
</abp-column>
<abp-column size-lg="_6" size-md="_6">
<abp-input asp-for="@Model.CreationEndDate" class="singledatepicker" label="@L["EndDate"].Value" type="text" />

26
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;
};

Loading…
Cancel
Save