Merge pull request #25257 from cogk/feat-default-workspace
feat(workspace): Allow user to choose a default workspace
This commit is contained in:
commit
d7dbf774e7
5 changed files with 38 additions and 2 deletions
|
|
@ -1,4 +1,14 @@
|
|||
frappe.ui.form.on("User", {
|
||||
setup: function (frm) {
|
||||
frm.set_query("default_workspace", () => {
|
||||
return {
|
||||
filters: {
|
||||
for_user: ["in", [null, frappe.session.user]],
|
||||
title: ["!=", "Welcome Workspace"],
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
before_load: function (frm) {
|
||||
let update_tz_options = function () {
|
||||
frm.fields_dict.time_zone.set_data(frappe.all_timezones);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@
|
|||
"send_me_a_copy",
|
||||
"allowed_in_mentions",
|
||||
"user_emails",
|
||||
"workspace_section",
|
||||
"default_workspace",
|
||||
"sb2",
|
||||
"defaults",
|
||||
"sb3",
|
||||
|
|
@ -711,6 +713,19 @@
|
|||
"label": "Role Profiles",
|
||||
"options": "User Role Profile",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"description": "If left empty, the default workspace will be the last visited workspace",
|
||||
"fieldname": "default_workspace",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Workspace",
|
||||
"options": "Workspace"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "workspace_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Workspace"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-user",
|
||||
|
|
@ -773,7 +788,7 @@
|
|||
"link_fieldname": "user"
|
||||
}
|
||||
],
|
||||
"modified": "2024-02-11 13:16:29.574666",
|
||||
"modified": "2024-03-20 17:15:19.200383",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "User",
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ class User(Document):
|
|||
birth_date: DF.Date | None
|
||||
block_modules: DF.Table[BlockModule]
|
||||
bypass_restrict_ip_check_if_2fa_enabled: DF.Check
|
||||
default_workspace: DF.Link | None
|
||||
defaults: DF.Table[DefaultValue]
|
||||
desk_theme: DF.Literal["Light", "Dark", "Automatic"]
|
||||
document_follow_frequency: DF.Literal["Hourly", "Daily", "Weekly"]
|
||||
|
|
|
|||
|
|
@ -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