feat(workspace): Allow user to choose a default workspace
This commit is contained in:
parent
ab7487cd17
commit
3ec47b0975
4 changed files with 36 additions and 2 deletions
|
|
@ -1,4 +1,14 @@
|
|||
frappe.ui.form.on("User", {
|
||||
setup: function (frm) {
|
||||
frm.set_query("default_workspace", () => {
|
||||
return {
|
||||
filters: {
|
||||
parent_page: ["is", "not set"],
|
||||
for_user: ["in", [null, frappe.session.user]],
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
before_load: function (frm) {
|
||||
let update_tz_options = function () {
|
||||
frm.fields_dict.time_zone.set_data(frappe.all_timezones);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
"send_welcome_email",
|
||||
"unsubscribed",
|
||||
"user_image",
|
||||
"workspaces_section",
|
||||
"default_workspace",
|
||||
"roles_permissions_tab",
|
||||
"sb1",
|
||||
"role_profile_name",
|
||||
|
|
@ -711,6 +713,18 @@
|
|||
"label": "Role Profiles",
|
||||
"options": "User Role Profile",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "workspaces_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Workspaces"
|
||||
},
|
||||
{
|
||||
"description": "If left empty, the default workspace will be the last visited workspace",
|
||||
"fieldname": "default_workspace",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Workspace",
|
||||
"options": "Workspace"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-user",
|
||||
|
|
@ -773,7 +787,7 @@
|
|||
"link_fieldname": "user"
|
||||
}
|
||||
],
|
||||
"modified": "2024-02-11 13:16:29.574666",
|
||||
"modified": "2024-03-06 11:14:38.424148",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "User",
|
||||
|
|
|
|||
|
|
@ -351,7 +351,12 @@ frappe.views.Workspace = class Workspace {
|
|||
get_page_to_show() {
|
||||
let default_page;
|
||||
|
||||
if (
|
||||
if (frappe.boot.user.default_workspace) {
|
||||
default_page = {
|
||||
name: frappe.boot.user.default_workspace.name,
|
||||
public: frappe.boot.user.default_workspace.public,
|
||||
};
|
||||
} else if (
|
||||
localStorage.current_page &&
|
||||
this.all_pages.filter((page) => page.title == localStorage.current_page).length != 0
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ class UserPermissions:
|
|||
"send_me_a_copy",
|
||||
"user_type",
|
||||
"onboarding_status",
|
||||
"default_workspace",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
|
|
@ -233,6 +234,10 @@ class UserPermissions:
|
|||
if not self.can_read:
|
||||
self.build_permissions()
|
||||
|
||||
if d.get("default_workspace"):
|
||||
public = frappe.get_cached_value("Workspace", d.default_workspace, "public")
|
||||
d.default_workspace = {"name": d.default_workspace, "public": public}
|
||||
|
||||
d.name = self.name
|
||||
d.onboarding_status = frappe.parse_json(d.onboarding_status)
|
||||
d.roles = self.get_roles()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue