duplicate-field.js
2 years ago
email-reports.js
2 years ago
notices.js
2 years ago
scroll-to-top.js
2 years ago
sticky-sidebar.js
2 years ago
support.js
2 years ago
user-roles.js
2 years ago
user-roles.js
41 lines
| 1 | const $ = jQuery; |
| 2 | |
| 3 | const UserRoles = { |
| 4 | setup: function() { |
| 5 | var self = this; |
| 6 | $('#user-role-select').on('change', function() { |
| 7 | $('.role').removeClass('show'); |
| 8 | $('.role-' + $(this).val()).addClass('show'); |
| 9 | }); |
| 10 | $('#capabilities-form').on('submit', function(e){ |
| 11 | e.preventDefault(); |
| 12 | self.save(); |
| 13 | }); |
| 14 | }, |
| 15 | save: function() { |
| 16 | $('#save-permissions').addClass('saving'); |
| 17 | var capabilities = {}; |
| 18 | |
| 19 | $('.role').each(function(){ |
| 20 | const role = $(this).find('select').attr('name') |
| 21 | const val = $(this).find('select').val() |
| 22 | capabilities[role] = val |
| 23 | }); |
| 24 | |
| 25 | capabilities = JSON.stringify(capabilities); |
| 26 | |
| 27 | var whiteLabel = $('#iawp_white_label').prop('checked'); |
| 28 | |
| 29 | const data = { |
| 30 | ...iawpActions.update_capabilities, |
| 31 | 'capabilities': capabilities, |
| 32 | 'white_label': whiteLabel, |
| 33 | }; |
| 34 | |
| 35 | jQuery.post(ajaxurl, data, function (response) { |
| 36 | $('#save-permissions').removeClass('saving'); |
| 37 | }); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | export { UserRoles }; |