diff --git a/frappe/core/doctype/user/user.js b/frappe/core/doctype/user/user.js index 0186652813..8c53d6e19b 100644 --- a/frappe/core/doctype/user/user.js +++ b/frappe/core/doctype/user/user.js @@ -37,18 +37,6 @@ frappe.ui.form.on("User", { } }, - role_profiles: function (frm) { - if (frm.doc.role_profiles && frm.doc.role_profiles.length) { - frm.roles_editor.disable = 1; - frm.call("populate_role_profile_roles").then(() => { - frm.roles_editor.show(); - }); - } else { - frm.roles_editor.disable = 0; - frm.roles_editor.show(); - } - }, - module_profile: function (frm) { if (frm.doc.module_profile) { frappe.call({ @@ -431,6 +419,26 @@ frappe.ui.form.on("User Email", { }, }); +frappe.ui.form.on("User Role Profile", { + role_profiles_add: function (frm) { + if (frm.doc.role_profiles.length > 0) { + frm.roles_editor.disable = 1; + frm.call("populate_role_profile_roles").then(() => { + frm.roles_editor.show(); + }); + $(".deselect-all, .select-all").prop("disabled", true); + } + }, + role_profiles_remove: function (frm) { + if (frm.doc.role_profiles.length == 0) { + console.log(frm.doc.role_profiles.length == 0); + frm.roles_editor.disable = 0; + frm.roles_editor.show(); + $(".deselect-all, .select-all").prop("disabled", false); + } + }, +}); + function has_access_to_edit_user() { return has_common(frappe.user_roles, get_roles_for_editing_user()); }