Browse Source

Permission Management Module - prettier settings added and js files reformatted

pull/4706/head
Ahmet Çotur 6 years ago
parent
commit
b72d903412
  1. 4
      modules/permission-management/.prettierrc
  2. 495
      modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/permission-management-modal.js

4
modules/permission-management/.prettierrc

@ -0,0 +1,4 @@
{
"singleQuote": true,
"useTabs": true
}

495
modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/permission-management-modal.js

@ -1,233 +1,268 @@
var abp = abp || {}; var abp = abp || {};
(function ($) { (function ($) {
abp.modals = abp.modals || {}; abp.modals = abp.modals || {};
abp.modals.PermissionManagement = function () { abp.modals.PermissionManagement = function () {
function checkParents($tab, $checkBox) { function checkParents($tab, $checkBox) {
var parentName = $checkBox.closest('.custom-checkbox').attr('data-parent-name'); var parentName = $checkBox
if (!parentName) { .closest('.custom-checkbox')
return; .attr('data-parent-name');
} if (!parentName) {
return;
$tab.find('.custom-checkbox') }
.filter('[data-permission-name="' + parentName + '"]')
.find('input[type="checkbox"]') $tab
.each(function () { .find('.custom-checkbox')
var $parent = $(this); .filter('[data-permission-name="' + parentName + '"]')
$parent.prop('checked', true); .find('input[type="checkbox"]')
checkParents($tab, $parent); .each(function () {
}); var $parent = $(this);
} $parent.prop('checked', true);
checkParents($tab, $parent);
function uncheckChildren($tab, $checkBox) { });
var permissionName = $checkBox.closest('.custom-checkbox').attr('data-permission-name'); }
if (!permissionName) {
return; function uncheckChildren($tab, $checkBox) {
} var permissionName = $checkBox
.closest('.custom-checkbox')
$tab.find('.custom-checkbox') .attr('data-permission-name');
.filter('[data-parent-name="' + permissionName + '"]') if (!permissionName) {
.find('input[type="checkbox"]') return;
.each(function () { }
var $child = $(this);
$child.prop('checked', false); $tab
uncheckChildren($tab, $child); .find('.custom-checkbox')
}); .filter('[data-parent-name="' + permissionName + '"]')
} .find('input[type="checkbox"]')
.each(function () {
function handleTabCheckedCheckboxCount($tab) { var $child = $(this);
var newCount = 0; $child.prop('checked', false);
$tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]').each(function () { uncheckChildren($tab, $child);
if ($(this).is(':checked') === true) { });
newCount++; }
}
}); function handleTabCheckedCheckboxCount($tab) {
var newCount = 0;
var $tabTitle = $('#' + $tab.attr('id') + '-tab'); $tab
var title = $tabTitle.html() .find('input[type="checkbox"]')
.replace('<b>','').replace('</b>','') .not('[name="SelectAllInThisTab"]')
.replace('<small>','').replace('</small>',''); .each(function () {
if ($(this).is(':checked') === true) {
var titleSplitted = title.split(' '); newCount++;
if (titleSplitted[titleSplitted.length-1].startsWith('(')){ }
titleSplitted.pop(); });
}
var titleWithoutCount = titleSplitted.join(' '); var $tabTitle = $('#' + $tab.attr('id') + '-tab');
var newTitle = titleWithoutCount + ' (' + (newCount) + ')'; var title = $tabTitle
if (newCount > 0){ .html()
newTitle = '<b>' + newTitle + '</b>' .replace('<b>', '')
} .replace('</b>', '')
else { .replace('<small>', '')
newTitle = '<small>' + newTitle + '</small>' .replace('</small>', '');
}
$tabTitle.html(newTitle) var titleSplitted = title.split(' ');
}; if (titleSplitted[titleSplitted.length - 1].startsWith('(')) {
titleSplitted.pop();
function handleUncheck($tab) { }
var $checkBox = $tab.find('input[name="SelectAllInThisTab"]'); var titleWithoutCount = titleSplitted.join(' ');
var newTitle = titleWithoutCount + ' (' + newCount + ')';
if ($checkBox.is(':checked')) { if (newCount > 0) {
if ($tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]').length > 1) { newTitle = '<b>' + newTitle + '</b>';
$($checkBox).prop('indeterminate', true); } else {
} else { newTitle = '<small>' + newTitle + '</small>';
$checkBox.prop('checked', false); }
} $tabTitle.html(newTitle);
} else if ($checkBox.is(':indeterminate')) { }
var allUnchecked = true;
function handleUncheck($tab) {
$tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]').each(function () { var $checkBox = $tab.find('input[name="SelectAllInThisTab"]');
if ($(this).is(':checked') === true) {
allUnchecked = false; if ($checkBox.is(':checked')) {
} if (
}); $tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]')
.length > 1
if (allUnchecked) { ) {
$($checkBox).prop('indeterminate', false); $($checkBox).prop('indeterminate', true);
$checkBox.prop('checked', false); } else {
} $checkBox.prop('checked', false);
} }
} } else if ($checkBox.is(':indeterminate')) {
var allUnchecked = true;
function handleCheck($tab) {
var $checkBox = $tab.find('input[name="SelectAllInThisTab"]'); $tab
.find('input[type="checkbox"]')
var allChecked = true; .not('[name="SelectAllInThisTab"]')
.each(function () {
$tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]').each(function () { if ($(this).is(':checked') === true) {
if ($(this).is(':checked') === false) { allUnchecked = false;
allChecked = false; }
} });
});
if (allUnchecked) {
if (allChecked) { $($checkBox).prop('indeterminate', false);
$($checkBox).prop('indeterminate', false); $checkBox.prop('checked', false);
$checkBox.prop('checked', true); }
} else { }
$($checkBox).prop('indeterminate', true); }
}
} function handleCheck($tab) {
var $checkBox = $tab.find('input[name="SelectAllInThisTab"]');
function initSelectAllInThisTab() { var allChecked = true;
var tabs = $('.tab-pane');
for (var i = 0; i < tabs.length; i++) { $tab
var $tab = $(tabs[i]); .find('input[type="checkbox"]')
var $checkBox = $tab.find('input[name="SelectAllInThisTab"]'); .not('[name="SelectAllInThisTab"]')
.each(function () {
var allChecked = true; if ($(this).is(':checked') === false) {
var allUnChecked = true; allChecked = false;
}
$tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]').each(function () { });
if ($(this).is(':checked') === true) {
allUnChecked = false; if (allChecked) {
} else { $($checkBox).prop('indeterminate', false);
allChecked = false; $checkBox.prop('checked', true);
} } else {
}); $($checkBox).prop('indeterminate', true);
}
if (allChecked) { }
$($checkBox).prop('checked', true);
} else if (allUnChecked) { function initSelectAllInThisTab() {
$($checkBox).prop('checked', false); var tabs = $('.tab-pane');
} else { for (var i = 0; i < tabs.length; i++) {
$($checkBox).prop('indeterminate', true); var $tab = $(tabs[i]);
} var $checkBox = $tab.find('input[name="SelectAllInThisTab"]');
}
} var allChecked = true;
var allUnChecked = true;
function setSelectAllInAllTabs() {
var $checkBox = $('#SelectAllInAllTabs'); $tab
.find('input[type="checkbox"]')
var anyIndeterminate = false; .not('[name="SelectAllInThisTab"]')
var allChecked = true; .each(function () {
var allUnChecked = true; if ($(this).is(':checked') === true) {
allUnChecked = false;
$('input[name="SelectAllInThisTab"]').each(function () { } else {
if ($(this).is(':checked') === true) { allChecked = false;
allUnChecked = false; }
} else { });
allChecked = false;
} if (allChecked) {
$($checkBox).prop('checked', true);
if ($(this).is(':indeterminate') === true) { } else if (allUnChecked) {
anyIndeterminate = true; $($checkBox).prop('checked', false);
} } else {
}); $($checkBox).prop('indeterminate', true);
}
if (anyIndeterminate) { }
$($checkBox).prop('indeterminate', true); }
return;
} else { function setSelectAllInAllTabs() {
$($checkBox).prop('indeterminate', false); var $checkBox = $('#SelectAllInAllTabs');
}
var anyIndeterminate = false;
if (allChecked) { var allChecked = true;
$($checkBox).prop('checked', true); var allUnChecked = true;
} else if (allUnChecked) {
$($checkBox).prop('checked', false); $('input[name="SelectAllInThisTab"]').each(function () {
} else { if ($(this).is(':checked') === true) {
$($checkBox).prop('indeterminate', true); allUnChecked = false;
} } else {
} allChecked = false;
}
this.initDom = function ($el) {
$el.find('.tab-pane').each(function () { if ($(this).is(':indeterminate') === true) {
var $tab = $(this); anyIndeterminate = true;
handleTabCheckedCheckboxCount($tab); }
$tab.find('input[type="checkbox"]').not('[name="SelectAllInThisTab"]').each(function () { });
var $checkBox = $(this);
$checkBox.change(function () { if (anyIndeterminate) {
if ($checkBox.is(':checked')) { $($checkBox).prop('indeterminate', true);
checkParents($tab, $checkBox); return;
handleCheck($tab); } else {
} else { $($checkBox).prop('indeterminate', false);
uncheckChildren($tab, $checkBox); }
handleUncheck($tab);
} if (allChecked) {
setSelectAllInAllTabs(); $($checkBox).prop('checked', true);
handleTabCheckedCheckboxCount($tab); } else if (allUnChecked) {
}); $($checkBox).prop('checked', false);
}); } else {
}); $($checkBox).prop('indeterminate', true);
}
$('input[name="SelectAllInThisTab"]').change(function () { }
var $checkBox = $(this);
var $tab = $('#' + $checkBox.attr('data-tab-id')); this.initDom = function ($el) {
if ($checkBox.is(':checked')) { $el.find('.tab-pane').each(function () {
$tab.find('input[type="checkbox"]').not(':disabled').prop('checked', true); var $tab = $(this);
} else { handleTabCheckedCheckboxCount($tab);
$tab.find('input[type="checkbox"]').not(':disabled').prop('checked', false); $tab
} .find('input[type="checkbox"]')
$($checkBox).prop('indeterminate', false); .not('[name="SelectAllInThisTab"]')
setSelectAllInAllTabs(); .each(function () {
handleTabCheckedCheckboxCount($tab) var $checkBox = $(this);
}); $checkBox.change(function () {
if ($checkBox.is(':checked')) {
$('input[name="SelectAllInAllTabs"]').change(function () { checkParents($tab, $checkBox);
var $checkBox = $(this); handleCheck($tab);
if ($checkBox.is(':checked')) { } else {
$('.tab-pane input[type="checkbox"]').not(':disabled').prop('checked', true); uncheckChildren($tab, $checkBox);
} else { handleUncheck($tab);
$('.tab-pane input[type="checkbox"]').not(':disabled').prop('checked', false); }
} setSelectAllInAllTabs();
$($checkBox).prop('indeterminate', false); handleTabCheckedCheckboxCount($tab);
});
$el.find('.tab-pane').each(function () { });
handleTabCheckedCheckboxCount($(this)) });
});
}); $('input[name="SelectAllInThisTab"]').change(function () {
var $checkBox = $(this);
$(function () { var $tab = $('#' + $checkBox.attr('data-tab-id'));
$(".custom-scroll-content").mCustomScrollbar({ if ($checkBox.is(':checked')) {
theme: "minimal-dark" $tab
}); .find('input[type="checkbox"]')
$(".custom-scroll-container > .col-4").mCustomScrollbar({ .not(':disabled')
theme: "minimal-dark" .prop('checked', true);
}); } else {
}); $tab
.find('input[type="checkbox"]')
initSelectAllInThisTab(); .not(':disabled')
setSelectAllInAllTabs(); .prop('checked', false);
}; }
}; $($checkBox).prop('indeterminate', false);
setSelectAllInAllTabs();
handleTabCheckedCheckboxCount($tab);
});
$('input[name="SelectAllInAllTabs"]').change(function () {
var $checkBox = $(this);
if ($checkBox.is(':checked')) {
$('.tab-pane input[type="checkbox"]')
.not(':disabled')
.prop('checked', true);
} else {
$('.tab-pane input[type="checkbox"]')
.not(':disabled')
.prop('checked', false);
}
$($checkBox).prop('indeterminate', false);
$el.find('.tab-pane').each(function () {
handleTabCheckedCheckboxCount($(this));
});
});
$(function () {
$('.custom-scroll-content').mCustomScrollbar({
theme: 'minimal-dark',
});
$('.custom-scroll-container > .col-4').mCustomScrollbar({
theme: 'minimal-dark',
});
});
initSelectAllInThisTab();
setSelectAllInAllTabs();
};
};
})(jQuery); })(jQuery);

Loading…
Cancel
Save