52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
function postPutAccessRights(IsNotExist) {
|
|
loader = $('#overlay, #loader').css('z-index', 1070);
|
|
|
|
const selectedItems = Object.values(selectedProductsMap);
|
|
if (selectedItems.length === 0) {
|
|
showToast('warning', 'Please select items for access first!', 'User access failed', 4000);
|
|
return;
|
|
}
|
|
|
|
const userRightsList = selectedItems.map(item => {
|
|
return {
|
|
UserAccessId: item.userAccessId,
|
|
ContAccId: item.contAccId,
|
|
AccessTypeId: item.accessTypeId,
|
|
IsActive: true,
|
|
};
|
|
});
|
|
console.log(userRightsList);
|
|
|
|
showConfirmation({
|
|
title: 'User Access Rights',
|
|
message: 'Are you sure you want to proceed? This action cannot be undone.',
|
|
type: 'warning',
|
|
confirmText: 'Yes',
|
|
cancelText: 'No'
|
|
}).then((confirmed) => {
|
|
|
|
if (confirmed) {
|
|
$.ajax({
|
|
url: '/Account/PutPostUserAccess',
|
|
type: 'POST',
|
|
data: { userRightsList, IsNotExist, UserId },
|
|
success: function (response) {
|
|
if (response.success) {
|
|
closeModal('modalAccess');
|
|
accessDataTable.ajax.reload();
|
|
showToast('success', 'Access rights saved!', 'User access', 4000);
|
|
} else {
|
|
showToast('error', response.response, 'User access failed', 4000);
|
|
accessDataTable.ajax.reload();
|
|
}
|
|
},
|
|
beforeSend: function () {
|
|
loader.show();
|
|
},
|
|
complete: function () {
|
|
loader.hide();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} |