-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathfeature-management-modal.js
More file actions
105 lines (92 loc) · 3.94 KB
/
Copy pathfeature-management-modal.js
File metadata and controls
105 lines (92 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var abp = abp || {};
(function ($) {
abp.modals = abp.modals || {};
let l = abp.localization.getResource("AbpFeatureManagement");
// The toolbars, menus and bundles are rendered on the server, so a full page
// load is the only way to reflect the new features on the current page. An empty
// provider key means the features of the current host or tenant were changed.
function reloadPageIfCurrentFeaturesChanged(providerKey) {
if (!providerKey) {
window.location.reload();
}
}
abp.modals.FeatureManagement = function () {
abp.ResourceLoader.loadScript('/client-proxies/featureManagement-proxy.js');
$('#ResetToDefaults').click(function (e) {
abp.message.confirm(l('AreYouSureToResetToDefault'))
.then(function (confirmed) {
if (confirmed) {
let providerName = $('#ProviderName').val();
let prodiverKey = $('#ProviderKey').val();
volo.abp.featureManagement.features.delete(providerName, prodiverKey).then(function () {
$("#FeatureManagementForm").get(0).reset();
abp.notify.success(l('SavedSuccessfully'));
$('#featureManagmentModal').modal('hide');
reloadPageIfCurrentFeaturesChanged(prodiverKey);
});
}
});
});
function checkParents($tab, $element, className) {
let parentName = $element
.closest(className)
.attr('data-parent-name');
if (!parentName) {
return;
}
$tab.find('.custom-checkbox')
.filter('[data-feature-name="' + parentName + '"]')
.find('input[type="checkbox"]')
.each(function () {
let $parent = $(this);
$parent.prop('checked', true);
checkParents($tab, $parent, className);
});
}
function uncheckChildren($tab, $checkBox) {
let featureName = $checkBox
.closest('.custom-checkbox')
.attr('data-feature-name');
if (!featureName) {
return;
}
$tab.find('.custom-checkbox')
.filter('[data-parent-name="' + featureName + '"]')
.find('input[type="checkbox"]')
.each(function () {
let $child = $(this);
$child.prop('checked', false);
uncheckChildren($tab, $child);
});
}
this.initDom = function ($el) {
let initialValues = $el.serialize();
$el.on('abp-ajax-success', function () {
if ($el.serialize() !== initialValues) {
reloadPageIfCurrentFeaturesChanged($el.find('#ProviderKey').val());
}
});
$el.find('.tab-pane').each(function () {
let $tab = $(this);
$tab.find('input[type="checkbox"]')
.each(function () {
let $checkBox = $(this);
$checkBox.change(function () {
if ($checkBox.is(':checked')) {
checkParents($tab, $checkBox, '.custom-checkbox')
} else {
uncheckChildren($tab, $checkBox);
}
});
});
$tab.find('.form-control')
.each(function () {
let $element = $(this);
$element.change(function () {
checkParents($tab, $element, '.form-group')
});
});
});
};
};
})(jQuery);