mirror of https://github.com/abpframework/abp.git
13 changed files with 3745 additions and 188 deletions
File diff suppressed because it is too large
@ -1,182 +1,173 @@ |
|||||
|
|
||||
|
|
||||
$(function () { |
|
||||
|
|
||||
var l = abp.localization.getResource("CmsKit"); |
$(function () { |
||||
|
|
||||
var commentsService = volo.cmsKit.admin.comments.commentAdmin; |
var l = abp.localization.getResource("CmsKit"); |
||||
|
|
||||
var detailsModal = new abp.ModalManager(abp.appPath + "CmsKit/Comments/DetailsModal"); |
var commentsService = volo.cmsKit.admin.comments.commentAdmin; |
||||
|
|
||||
moment()._locale.preparse = (string) => string; |
var detailsModal = new abp.ModalManager(abp.appPath + "CmsKit/Comments/DetailsModal"); |
||||
moment()._locale.postformat = (string) => string; |
|
||||
|
|
||||
var getFormattedDate = function ($datePicker) { |
|
||||
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, |
|
||||
"showDropdowns": true, |
|
||||
"autoUpdateInput": false, |
|
||||
"autoApply": true, |
|
||||
"opens": "center", |
|
||||
"drops": "auto" |
|
||||
}); |
|
||||
|
|
||||
|
moment()._locale.preparse = (string) => string; |
||||
|
moment()._locale.postformat = (string) => string; |
||||
|
|
||||
|
var getFormattedDate = function ($datePicker) { |
||||
$('.singledatepicker').attr('autocomplete', 'off'); |
if (!$datePicker.val()) { |
||||
|
return null; |
||||
$('.singledatepicker').on('apply.daterangepicker', function (ev, picker) { |
} |
||||
$(this).val(picker.startDate.format('l')); |
var momentDate = moment($datePicker.val(), $datePicker.data('daterangepicker').locale.format); |
||||
}); |
return momentDate.isValid() ? momentDate.toISOString() : null; |
||||
|
}; |
||||
|
|
||||
var filterForm = $('#CmsKitCommentsFilterForm'); |
|
||||
|
$('.singledatepicker').daterangepicker({ |
||||
var getFilter = function () { |
"singleDatePicker": true, |
||||
var filterObj = filterForm.serializeFormToObject(); |
"showDropdowns": true, |
||||
|
"autoUpdateInput": false, |
||||
filterObj.creationStartDate = getFormattedDate($('#CreationStartDate')); |
"autoApply": true, |
||||
filterObj.creationEndDate = getFormattedDate($('#CreationEndDate')); |
"opens": "center", |
||||
|
"drops": "auto" |
||||
return filterObj; |
}); |
||||
}; |
|
||||
|
|
||||
|
|
||||
var _dataTable = $('#CommentsTable').DataTable(abp.libs.datatables.normalizeConfiguration({ |
$('.singledatepicker').attr('autocomplete', 'off'); |
||||
processing: true, |
|
||||
serverSide: true, |
$('.singledatepicker').on('apply.daterangepicker', function (ev, picker) { |
||||
paging: true, |
$(this).val(picker.startDate.format('l')); |
||||
scrollX: true, |
}); |
||||
searching: false, |
|
||||
scrollCollapse: true, |
|
||||
ajax: abp.libs.datatables.createAjax(commentsService.getWaitingCommentsWithReplies, getFilter), |
var filterForm = $('#CmsKitCommentsFilterForm'); |
||||
columnDefs: [ |
|
||||
{ |
var getFilter = function () { |
||||
width: "10%", |
var filterObj = filterForm.serializeFormToObject(); |
||||
title: l("Actions"), |
|
||||
targets: 0, |
filterObj.creationStartDate = getFormattedDate($('#CreationStartDate')); |
||||
orderable: false, |
filterObj.creationEndDate = getFormattedDate($('#CreationEndDate')); |
||||
rowAction: { |
|
||||
items: [ |
return filterObj; |
||||
{ |
}; |
||||
text: function (data) { |
|
||||
return l('Approve'); |
|
||||
}, |
var _dataTable = $('#CommentsTable').DataTable(abp.libs.datatables.normalizeConfiguration({ |
||||
action: function (data) { |
processing: true, |
||||
var newApprovalStatus = true; |
serverSide: true, |
||||
|
paging: true, |
||||
commentsService |
scrollX: true, |
||||
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus }) |
searching: false, |
||||
.then(function () { |
scrollCollapse: true, |
||||
_dataTable.ajax.reloadEx(); |
ajax: abp.libs.datatables.createAjax(commentsService.getWaitingCommentsWithReplies, getFilter), |
||||
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); |
columnDefs: [ |
||||
abp.notify.success(message); |
{ |
||||
}) |
width: "10%", |
||||
.catch(function (error) { |
title: l("Actions"), |
||||
abp.notify.error(error.message); |
targets: 0, |
||||
}); |
orderable: false, |
||||
} |
rowAction: { |
||||
}, |
items: [ |
||||
{ |
{ |
||||
text: function (data) { |
text: function (data) { |
||||
return l('Disapproved') ; |
return l('Approve'); |
||||
|
}, |
||||
|
action: function (data) { |
||||
|
var newApprovalStatus = true; |
||||
|
|
||||
|
commentsService |
||||
|
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus }) |
||||
|
.then(function () { |
||||
|
_dataTable.ajax.reloadEx(); |
||||
|
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); |
||||
|
abp.notify.success(message); |
||||
|
}) |
||||
|
.catch(function (error) { |
||||
|
abp.notify.error(error.message); |
||||
|
}); |
||||
|
} |
||||
}, |
}, |
||||
action: function (data) { |
{ |
||||
var newApprovalStatus = false; |
text: function (data) { |
||||
|
return l('Disapproved'); |
||||
commentsService |
}, |
||||
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus }) |
action: function (data) { |
||||
.then(function () { |
var newApprovalStatus = false; |
||||
_dataTable.ajax.reloadEx(); |
|
||||
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); |
commentsService |
||||
abp.notify.success(message); |
.updateApprovalStatus(data.record.id, { IsApproved: newApprovalStatus }) |
||||
}) |
.then(function () { |
||||
.catch(function (error) { |
_dataTable.ajax.reloadEx(); |
||||
abp.notify.error(error.message); |
var message = newApprovalStatus ? l('ApprovedSuccessfully') : l('ApprovalRevokedSuccessfully'); |
||||
}); |
abp.notify.success(message); |
||||
|
}) |
||||
|
.catch(function (error) { |
||||
|
abp.notify.error(error.message); |
||||
|
}); |
||||
|
} |
||||
} |
} |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
width: "10%", |
||||
|
title: l("Username"), |
||||
|
orderable: false, |
||||
|
data: "author.userName", |
||||
|
render: function (data) { |
||||
|
if (data !== null) { |
||||
|
return GetFilterableDatatableContent('#Author', $.fn.dataTable.render.text().display(data)); //prevent against possible XSS
|
||||
} |
} |
||||
] |
return ""; |
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
width: "10%", |
|
||||
title: l("Username"), |
|
||||
orderable: false, |
|
||||
data: "author.userName", |
|
||||
render: function (data) { |
|
||||
if (data !== null) { |
|
||||
return GetFilterableDatatableContent('#Author', $.fn.dataTable.render.text().display(data)); //prevent against possible XSS
|
|
||||
} |
} |
||||
return ""; |
}, |
||||
} |
{ |
||||
}, |
width: "15%", |
||||
{ |
title: l("EntityType"), |
||||
width: "15%", |
orderable: false, |
||||
title: l("EntityType"), |
data: "entityType", |
||||
orderable: false, |
render: function (data) { |
||||
data: "entityType", |
if (data !== null) { |
||||
render: function (data) { |
return GetFilterableDatatableContent('#EntityType', $.fn.dataTable.render.text().display(data)); |
||||
if (data !== null) { |
} |
||||
return GetFilterableDatatableContent('#EntityType', $.fn.dataTable.render.text().display(data)); |
return ""; |
||||
} |
} |
||||
return ""; |
}, |
||||
} |
{ |
||||
}, |
title: l("Text"), |
||||
{ |
data: "text", |
||||
title: l("Text"), |
orderable: false, |
||||
data: "text", |
render: function (data) { |
||||
orderable: false, |
|
||||
render: function (data) { |
var converter = new showdown.Converter(); |
||||
//var markdownData = marked(data || "");
|
var htmlContent = converter.makeHtml(data); |
||||
//var sanitizedData = DOMPurify.sanitize(markdownData);
|
return (htmlContent); |
||||
data = $.fn.dataTable.render.text().display(data || ""); |
} |
||||
|
}, |
||||
return ( |
{ |
||||
'<span data-toggle="tooltip" title="' + |
width: "15%", |
||||
data + |
title: l("CreationTime"), |
||||
'" style="white-space: normal; word-break: break-all;">' + |
data: "creationTime", |
||||
data + |
orderable: true, |
||||
"</span>" |
dataFormat: "datetime" |
||||
); |
|
||||
} |
} |
||||
}, |
] |
||||
{ |
})); |
||||
width: "15%", |
|
||||
title: l("CreationTime"), |
|
||||
data: "creationTime", |
|
||||
orderable: true, |
|
||||
dataFormat: "datetime" |
|
||||
} |
|
||||
] |
|
||||
})); |
|
||||
|
|
||||
function GetFilterableDatatableContent(filterSelector, data) { |
function GetFilterableDatatableContent(filterSelector, data) { |
||||
return '<span class="datatableCell" data-field="' + filterSelector + '" data-val="' + data + '">' + data + '</span>'; |
return '<span class="datatableCell" data-field="' + filterSelector + '" data-val="' + data + '">' + data + '</span>'; |
||||
} |
} |
||||
|
|
||||
$(document).on('click', '.datatableCell', function () { |
$(document).on('click', '.datatableCell', function () { |
||||
var inputSelector = $(this).attr('data-field'); |
var inputSelector = $(this).attr('data-field'); |
||||
var value = $(this).attr('data-val'); |
var value = $(this).attr('data-val'); |
||||
|
|
||||
$(inputSelector).val(value); |
$(inputSelector).val(value); |
||||
|
|
||||
_dataTable.ajax.reloadEx(); |
_dataTable.ajax.reloadEx(); |
||||
}); |
}); |
||||
|
|
||||
filterForm.submit(function (e) { |
filterForm.submit(function (e) { |
||||
e.preventDefault(); |
e.preventDefault(); |
||||
_dataTable.ajax.reloadEx(); |
_dataTable.ajax.reloadEx(); |
||||
|
}); |
||||
}); |
}); |
||||
}); |
|
||||
Loading…
Reference in new issue