0002-manager-move-role-ajax-checkbox-js-to-file-53481.patch
src/authentic2/manager/static/authentic2/manager/js/roles_ajax_checkbox.js | ||
---|---|---|
1 |
(function ($, window, undefined) { |
|
2 |
function fix_underterminate() { |
|
3 |
$('.indeterminate').each(function (i, elem) { |
|
4 |
elem.indeterminate = true; |
|
5 |
}) |
|
6 |
} |
|
7 |
$(document).on('gadjo:content-update', function () { |
|
8 |
fix_underterminate(); |
|
9 |
}); |
|
10 |
$(function () { |
|
11 |
$('body').on('click', 'input.role-member', function (e) { |
|
12 |
e.stopPropagation(); |
|
13 |
}); |
|
14 |
$('body').on('change', 'input.role-member', function (e) { |
|
15 |
var $target = $(e.target); |
|
16 |
var pk = e.target.name.split('-')[1]; |
|
17 |
data = { |
|
18 |
'csrfmiddlewaretoken': window.csrf_token, |
|
19 |
'role': pk, |
|
20 |
'action': ($target.is(':checked') && 'add') || 'remove', |
|
21 |
}; |
|
22 |
console.log(data); |
|
23 |
var $overlay = $('<div class="waiting"/>'); |
|
24 |
$('body')[0].appendChild($overlay[0]); |
|
25 |
$.post(window.location.href, data).done(function () { |
|
26 |
window.update_content(window.location.href); |
|
27 |
$('body')[0].removeChild($overlay[0]); |
|
28 | ||
29 |
}); |
|
30 |
}); |
|
31 |
}) |
|
32 |
})(jQuery, window, undefined); |
src/authentic2/manager/templates/authentic2/manager/user_ou_roles.html | ||
---|---|---|
3 | 3 | |
4 | 4 |
{% block extrascripts %} |
5 | 5 |
{{ block.super }} |
6 |
<script> |
|
7 |
(function ($, window, undefined) { |
|
8 |
function fix_underterminate() { |
|
9 |
$('.indeterminate').each(function (i, elem) { |
|
10 |
elem.indeterminate = true; |
|
11 |
}) |
|
12 |
} |
|
13 |
$(document).on('gadjo:content-update', function () { |
|
14 |
fix_underterminate(); |
|
15 |
}); |
|
16 |
$(function () { |
|
17 |
$('body').on('click', 'input.role-member', function (e) { |
|
18 |
e.stopPropagation(); |
|
19 |
}); |
|
20 |
$('body').on('change', 'input.role-member', function (e) { |
|
21 |
var $target = $(e.target); |
|
22 |
var pk = e.target.name.split('-')[1]; |
|
23 |
data = { |
|
24 |
'csrfmiddlewaretoken': window.csrf_token, |
|
25 |
'role': pk, |
|
26 |
'action': ($target.is(':checked') && 'add') || 'remove', |
|
27 |
}; |
|
28 |
console.log(data); |
|
29 |
var $overlay = $('<div class="waiting"/>'); |
|
30 |
$('body')[0].appendChild($overlay[0]); |
|
31 |
$.post(window.location.href, data).done(function () { |
|
32 |
window.update_content(window.location.href); |
|
33 |
$('body')[0].removeChild($overlay[0]); |
|
34 | ||
35 |
}); |
|
36 |
}); |
|
37 |
}) |
|
38 |
})(jQuery, window, undefined); |
|
39 |
</script> |
|
6 |
<script src="{% static "authentic2/manager/js/roles_ajax_checkbox.js" %}"></script> |
|
40 | 7 |
{% endblock %} |
41 | 8 | |
42 | 9 |
{% block main %} |
43 |
- |