Browse Source

RRegister `ajax.reloadEx()` method to Datatables.

pull/17067/head
maliming 3 years ago
parent
commit
add4234635
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 33
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
  2. 8
      modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/index.js
  3. 12
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/index.js
  4. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/index.js
  5. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/details.js
  6. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js
  7. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/index.js
  8. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Index.js
  9. 8
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js
  10. 8
      modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/index.js
  11. 6
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js
  12. 6
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/index.js
  13. 6
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.js

33
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js

@ -72,7 +72,7 @@ var abp = abp || {};
}; };
var _createButtonDropdown = function (record, field, tableInstance) { var _createButtonDropdown = function (record, field, tableInstance) {
if(field.items.length === 1) { if (field.items.length === 1) {
var firstItem = field.items[0]; var firstItem = field.items[0];
if (!getVisibilityValue(firstItem.visible, record, tableInstance)) { if (!getVisibilityValue(firstItem.visible, record, tableInstance)) {
return ""; return "";
@ -174,7 +174,7 @@ var abp = abp || {};
$dropdownButton.prependTo($container); $dropdownButton.prependTo($container);
if(bootstrap){ if (bootstrap) {
new bootstrap.Dropdown($dropdownButton, { new bootstrap.Dropdown($dropdownButton, {
popperConfig(defaultBsPopperConfig) { popperConfig(defaultBsPopperConfig) {
defaultBsPopperConfig.strategy = "fixed"; defaultBsPopperConfig.strategy = "fixed";
@ -329,6 +329,19 @@ var abp = abp || {};
} }
}); });
$.fn.dataTable.Api.register('ajax.reloadEx()', function (callback, resetPaging) {
var table = this;
if (callback || resetPaging) {
table.ajax.reload(callback, resetPaging);
return;
}
table.ajax.reload(function (data) {
if (data.data.length <= 0) {
table.page(0).draw(false);
}
}, false);
});
})(); })();
/************************************************************************ /************************************************************************
@ -336,7 +349,7 @@ var abp = abp || {};
*************************************************************************/ *************************************************************************/
(function () { (function () {
datatables.createAjax = function (serverMethod, inputAction, responseCallback, cancelPreviousRequest) { datatables.createAjax = function (serverMethod, inputAction, responseCallback, cancelPreviousRequest) {
responseCallback = responseCallback || function(result) { responseCallback = responseCallback || function (result) {
return { return {
recordsTotal: result.totalCount, recordsTotal: result.totalCount,
recordsFiltered: result.totalCount, recordsFiltered: result.totalCount,
@ -374,7 +387,7 @@ var abp = abp || {};
} }
//Text filter //Text filter
if(settings.oInit.searching !== false){ if (settings.oInit.searching !== false) {
if (requestData.search && requestData.search.value !== "") { if (requestData.search && requestData.search.value !== "") {
input.filter = requestData.search.value; input.filter = requestData.search.value;
} else { } else {
@ -383,7 +396,7 @@ var abp = abp || {};
} }
if (callback) { if (callback) {
if(cancelPreviousRequest && promise && promise.jqXHR) { if (cancelPreviousRequest && promise && promise.jqXHR) {
promise.jqXHR.abort(); promise.jqXHR.abort();
} }
promise = serverMethod(input); promise = serverMethod(input);
@ -440,7 +453,7 @@ var abp = abp || {};
configuration.language = datatables.defaultConfigurations.language(); configuration.language = datatables.defaultConfigurations.language();
if(!configuration.dom){ if (!configuration.dom) {
configuration.dom = datatables.defaultConfigurations.dom; configuration.dom = datatables.defaultConfigurations.dom;
} }
@ -454,7 +467,7 @@ var abp = abp || {};
datatables.defaultRenderers = datatables.defaultRenderers || {}; datatables.defaultRenderers = datatables.defaultRenderers || {};
datatables.defaultRenderers['boolean'] = function(value) { datatables.defaultRenderers['boolean'] = function (value) {
if (value) { if (value) {
return '<i class="fa fa-check"></i>'; return '<i class="fa fa-check"></i>';
} else { } else {
@ -463,7 +476,7 @@ var abp = abp || {};
}; };
var ISOStringToDateTimeLocaleString = function (format) { var ISOStringToDateTimeLocaleString = function (format) {
return function(data) { return function (data) {
var date = luxon var date = luxon
.DateTime .DateTime
.fromISO(data, { .fromISO(data, {
@ -474,7 +487,7 @@ var abp = abp || {};
}; };
datatables.defaultRenderers['date'] = function (value) { datatables.defaultRenderers['date'] = function (value) {
if(!value) { if (!value) {
return value; return value;
} else { } else {
return (ISOStringToDateTimeLocaleString())(value); return (ISOStringToDateTimeLocaleString())(value);
@ -482,7 +495,7 @@ var abp = abp || {};
}; };
datatables.defaultRenderers['datetime'] = function (value) { datatables.defaultRenderers['datetime'] = function (value) {
if(!value) { if (!value) {
return value; return value;
} else { } else {
return (ISOStringToDateTimeLocaleString(luxon.DateTime.DATETIME_SHORT))(value); return (ISOStringToDateTimeLocaleString(luxon.DateTime.DATETIME_SHORT))(value);

8
modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/index.js

@ -48,7 +48,7 @@ $(function () {
volo.blogging.admin.blogManagement volo.blogging.admin.blogManagement
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
}, },
@ -65,7 +65,7 @@ $(function () {
volo.blogging.admin.blogManagement volo.blogging.admin.blogManagement
.clearCache(data.record.id) .clearCache(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}) })
} }
} }
@ -98,10 +98,10 @@ $(function () {
}); });
_createModal.onClose(function () { _createModal.onClose(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
_editModal.onResult(function () { _editModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
}); });

12
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/index.js

@ -58,7 +58,7 @@ $(function () {
blogsService blogsService
.publish(data.record.id) .publish(data.record.id)
.then(function () { .then(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyPublished')); abp.notify.success(l('SuccessfullyPublished'));
checkHasBlogPostWaitingForReview(); checkHasBlogPostWaitingForReview();
}); });
@ -77,7 +77,7 @@ $(function () {
blogsService blogsService
.sendToReview(data.record.id) .sendToReview(data.record.id)
.then(function () { .then(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
abp.notify.success(l('BlogPostSendToReviewSuccessMessage', data.record.title)); abp.notify.success(l('BlogPostSendToReviewSuccessMessage', data.record.title));
}); });
} }
@ -94,7 +94,7 @@ $(function () {
blogsService blogsService
.draft(data.record.id) .draft(data.record.id)
.then(function () { .then(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullySaved')); abp.notify.success(l('SuccessfullySaved'));
checkHasBlogPostWaitingForReview(); checkHasBlogPostWaitingForReview();
}); });
@ -110,7 +110,7 @@ $(function () {
blogsService blogsService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
} }
@ -152,7 +152,7 @@ $(function () {
$('#CmsKitBlogPostsWrapper form.page-search-form').submit(function (e) { $('#CmsKitBlogPostsWrapper form.page-search-form').submit(function (e) {
e.preventDefault(); e.preventDefault();
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
$('#AbpContentToolbar button[name=CreateBlogPost]').on('click', function (e) { $('#AbpContentToolbar button[name=CreateBlogPost]').on('click', function (e) {
@ -163,7 +163,7 @@ $(function () {
$('#button-show-waiting-for-review').on('click', function (e) { $('#button-show-waiting-for-review').on('click', function (e) {
e.preventDefault(); e.preventDefault();
$statusFilter.val(blogPostStatus.SendToReview); $statusFilter.val(blogPostStatus.SendToReview);
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
function checkHasBlogPostWaitingForReview(){ function checkHasBlogPostWaitingForReview(){

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Blogs/index.js

@ -48,7 +48,7 @@ $(function () {
blogsService blogsService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
} }
@ -75,10 +75,10 @@ $(function () {
}); });
createModal.onResult(function () { createModal.onResult(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
updateModal.onResult(function () { updateModal.onResult(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
}); });

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/details.js

@ -74,7 +74,7 @@ $(function (){
commentsService commentsService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
} }
@ -137,11 +137,11 @@ $(function (){
$(inputSelector).val(value); $(inputSelector).val(value);
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
filterForm.submit(function (e){ filterForm.submit(function (e){
e.preventDefault(); e.preventDefault();
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
}); });

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Comments/index.js

@ -82,7 +82,7 @@ $(function (){
commentsService commentsService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
} }
@ -167,11 +167,11 @@ $(function (){
$(inputSelector).val(value); $(inputSelector).val(value);
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
filterForm.submit(function (e){ filterForm.submit(function (e){
e.preventDefault(); e.preventDefault();
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
}); });

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Pages/index.js

@ -42,7 +42,7 @@ $(function () {
pagesService pagesService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
} }
@ -55,7 +55,7 @@ $(function () {
.setAsHomePage(data.record.id) .setAsHomePage(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
data.record.isHomePage ? data.record.isHomePage ?
abp.notify.warn(l('RemovedSettingAsHomePage')) abp.notify.warn(l('RemovedSettingAsHomePage'))
: abp.notify.success(l('CompletedSettingAsHomePage')); : abp.notify.success(l('CompletedSettingAsHomePage'));
@ -97,7 +97,7 @@ $(function () {
$('#CmsKitPagesWrapper form.page-search-form').submit(function (e) { $('#CmsKitPagesWrapper form.page-search-form').submit(function (e) {
e.preventDefault(); e.preventDefault();
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
$('#AbpContentToolbar button[name=CreatePage]').on('click', function (e) { $('#AbpContentToolbar button[name=CreatePage]').on('click', function (e) {

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/Tags/Index.js

@ -63,7 +63,7 @@ $(function () {
$('#CmsKitTagsWrapper form.page-search-form').on('submit', function (e) { $('#CmsKitTagsWrapper form.page-search-form').on('submit', function (e) {
e.preventDefault(); e.preventDefault();
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
$('#AbpContentToolbar button[name=NewButton]').on('click', function (e) { $('#AbpContentToolbar button[name=NewButton]').on('click', function (e) {
@ -72,10 +72,10 @@ $(function () {
}); });
createModal.onResult(function () { createModal.onResult(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
updateModal.onResult(function () { updateModal.onResult(function () {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
}); });

8
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js

@ -182,7 +182,7 @@ $(function () {
.removeFromCache(data.record.id) .removeFromCache(data.record.id)
.then(function () { .then(function () {
abp.notify.success(l('RemovedFromCache')); abp.notify.success(l('RemovedFromCache'));
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
}, },
}, },
@ -200,7 +200,7 @@ $(function () {
.reindex(data.record.id) .reindex(data.record.id)
.then(function () { .then(function () {
abp.message.success(l('ReindexCompleted')); abp.message.success(l('ReindexCompleted'));
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
}, },
} }
@ -281,13 +281,13 @@ $(function () {
$("#FilterForm input[type='text']").keypress(function (e) { $("#FilterForm input[type='text']").keypress(function (e) {
if (e.which === 13) { if (e.which === 13) {
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
} }
}); });
$('#SearchButton').click(function (e) { $('#SearchButton').click(function (e) {
e.preventDefault(); e.preventDefault();
dataTable.ajax.reload(); dataTable.ajax.reloadEx();
}); });
$("#AdvancedFilterSectionToggler").click(function (e) { $("#AdvancedFilterSectionToggler").click(function (e) {

8
modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Projects/index.js

@ -56,7 +56,7 @@ $(function () {
volo.docs.admin.projectsAdmin volo.docs.admin.projectsAdmin
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
}, },
@ -89,7 +89,7 @@ $(function () {
projectId: data.record.id, projectId: data.record.id,
}) })
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
}, },
}, },
@ -168,10 +168,10 @@ $(function () {
}); });
_createModal.onClose(function () { _createModal.onClose(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
_editModal.onResult(function () { _editModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
}); });

6
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js

@ -62,7 +62,7 @@
_identityRoleAppService _identityRoleAppService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
}, },
@ -128,11 +128,11 @@
); );
_createModal.onResult(function () { _createModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
_editModal.onResult(function () { _editModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
$('#AbpContentToolbar button[name=CreateRole]').click(function (e) { $('#AbpContentToolbar button[name=CreateRole]').click(function (e) {

6
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/index.js

@ -96,7 +96,7 @@
_identityUserAppService _identityUserAppService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
}, },
@ -163,11 +163,11 @@
); );
_createModal.onResult(function () { _createModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
_editModal.onResult(function () { _editModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
$('#AbpContentToolbar button[name=CreateUser]').click(function (e) { $('#AbpContentToolbar button[name=CreateUser]').click(function (e) {

6
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Pages/TenantManagement/Tenants/Index.js

@ -56,7 +56,7 @@
_tenantAppService _tenantAppService
.delete(data.record.id) .delete(data.record.id)
.then(function () { .then(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
abp.notify.success(l('SuccessfullyDeleted')); abp.notify.success(l('SuccessfullyDeleted'));
}); });
}, },
@ -102,11 +102,11 @@
); );
_createModal.onResult(function () { _createModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
_editModal.onResult(function () { _editModal.onResult(function () {
_dataTable.ajax.reload(); _dataTable.ajax.reloadEx();
}); });
$('#AbpContentToolbar button[name=CreateTenant]').click(function (e) { $('#AbpContentToolbar button[name=CreateTenant]').click(function (e) {

Loading…
Cancel
Save