// Copyright (c) 2022, JINGROW and Contributors
// MIT License. See LICENSE

jingrow.ui.form.on("Role", {
	refresh: function (frm) {
		if (frm.pg.name === "All") {
			frm.dashboard.add_comment(
				__("Role 'All' will be given to all system + website users."),
				"yellow"
			);
		} else if (frm.pg.name === "Desk User") {
			frm.dashboard.add_comment(
				__("Role 'Desk User' will be given to all system users."),
				"yellow"
			);
		}

		frm.set_df_property("is_custom", "read_only", jingrow.session.user !== "Administrator");

		frm.add_custom_button("Role Permissions Manager", function () {
			jingrow.route_options = { role: frm.pg.name };
			jingrow.set_route("permission-manager");
		});
		frm.add_custom_button("Show Users", function () {
			jingrow.route_options = { role: frm.pg.name };
			jingrow.set_route("List", "User", "Report");
		});
	},
});
