Переглянути джерело

Merge pull request #14224 from shariquerik/wspace-fixes

fix: Workspaces 2.0 fixes
version-14
Rushabh Mehta 3 роки тому
committed by GitHub
джерело
коміт
23afeebb6d
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: 4AEE18F83AFDEB23
4 змінених файлів з 73 додано та 58 видалено
  1. +5
    -4
      frappe/desk/doctype/workspace/workspace.json
  2. +3
    -3
      frappe/desk/doctype/workspace/workspace.py
  3. +61
    -51
      frappe/public/js/frappe/views/workspace/workspace.js
  4. +4
    -0
      frappe/public/scss/desk/desktop.scss

+ 5
- 4
frappe/desk/doctype/workspace/workspace.json Переглянути файл

@@ -165,8 +165,6 @@
"default": "0",
"fieldname": "is_standard",
"fieldtype": "Check",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Is Standard",
"search_index": 1
},
@@ -181,7 +179,6 @@
"depends_on": "eval:doc.extends_another_page == 1 || doc.for_user",
"fieldname": "extends",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Extends",
"options": "Workspace",
"search_index": 1
@@ -228,6 +225,8 @@
"default": "0",
"fieldname": "public",
"fieldtype": "Check",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Public"
},
{
@@ -265,11 +264,13 @@
"label": "Roles"
}
],
"in_create": 1,
"links": [],
"modified": "2021-08-30 18:47:18.227154",
"modified": "2021-09-16 12:01:06.450621",
"modified_by": "Administrator",
"module": "Desk",
"name": "Workspace",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{


+ 3
- 3
frappe/desk/doctype/workspace/workspace.py Переглянути файл

@@ -208,17 +208,17 @@ def save_page(title, icon, parent, public, sb_public_items, sb_private_items, de
if loads(deleted_pages):
return delete_pages(loads(deleted_pages))

return {"name": title, "public": public}
return {"name": title, "public": public, "label": doc.label}

def delete_pages(deleted_pages):
for page in deleted_pages:
if page.get("public") and "Workspace Manager" not in frappe.get_roles():
return {"name": page.get("title"), "public": 1}
return {"name": page.get("title"), "public": 1, "label": page.get("label")}

if frappe.db.exists("Workspace", page.get("name")):
frappe.get_doc("Workspace", page.get("name")).delete(ignore_permissions=True)

return {"name": "Home", "public": 1}
return {"name": "Home", "public": 1, "label": "Home"}

def sort_pages(sb_public_items, sb_private_items):
wspace_public_pages = get_page_list(['name', 'title'], {'public': 1})


+ 61
- 51
frappe/public/js/frappe/views/workspace/workspace.js Переглянути файл

@@ -23,6 +23,7 @@ frappe.views.Workspace = class Workspace {
this.blocks = frappe.wspace_block.blocks;
this.is_read_only = true;
this.new_page = null;
this.pages = {};
this.sorted_public_items = [];
this.sorted_private_items = [];
this.deleted_sidebar_items = [];
@@ -35,42 +36,6 @@ frappe.views.Workspace = class Workspace {
'My Workspaces',
'Public'
];
this.tools = {
header: {
class: this.blocks['header'],
inlineToolbar: true
},
paragraph: {
class: this.blocks['paragraph'],
inlineToolbar: true
},
chart: {
class: this.blocks['chart'],
config: {
page_data: this.page_data || []
}
},
card: {
class: this.blocks['card'],
config: {
page_data: this.page_data || []
}
},
shortcut: {
class: this.blocks['shortcut'],
config: {
page_data: this.page_data || []
}
},
onboarding: {
class: this.blocks['onboarding'],
config: {
page_data: this.page_data || []
}
},
spacer: this.blocks['spacer'],
spacingTune: frappe.wspace_block.tunes['spacing_tune'],
};

this.prepare_container();
this.setup_pages();
@@ -86,7 +51,7 @@ frappe.views.Workspace = class Workspace {
this.body = this.wrapper.find(".layout-main-section");
}

setup_pages() {
setup_pages(reload) {
this.get_pages().then(pages => {
this.all_pages = pages.pages;
this.has_access = pages.has_access;
@@ -115,7 +80,7 @@ frappe.views.Workspace = class Workspace {
this.new_page = null;
}
this.make_sidebar();
frappe.router.route();
reload && this.show();
}
});
}
@@ -236,10 +201,7 @@ frappe.views.Workspace = class Workspace {
return;
}

let page = {
name: this.get_page_to_show().name,
public: this.get_page_to_show().public
};
let page = this.get_page_to_show();
this.page.set_title(`${__(page.name)}`);

this.show_page(page);
@@ -250,6 +212,11 @@ frappe.views.Workspace = class Workspace {
page: page
}).then(data => {
this.page_data = data;

// caching page data
this.pages[page.name] && delete this.pages[page.name];
this.pages[page.name] = data;

if (!this.page_data || Object.keys(this.page_data).length === 0) return;

return frappe.dashboard_utils.get_dashboard_settings().then(settings => {
@@ -260,6 +227,7 @@ frappe.views.Workspace = class Workspace {
chart.chart_settings = chart_config[chart.chart_name] || {};
});
}
this.pages[page.name] = this.page_data;
}
});
});
@@ -281,7 +249,7 @@ frappe.views.Workspace = class Workspace {
return { name: page, public: is_public };
}

show_page(page) {
async show_page(page) {
let section = this.current_page.public ? 'public' : 'private';
if (this.sidebar_items && this.sidebar_items[section] && this.sidebar_items[section][this.current_page.name]) {
this.sidebar_items[section][this.current_page.name][0].firstElementChild.classList.remove("selected");
@@ -316,12 +284,17 @@ frappe.views.Workspace = class Workspace {
this.add_custom_cards_in_content();

$('.item-anchor').addClass('disable-click');
this.get_data(this_page).then(() => {
this.prepare_editorjs();
$('.item-anchor').removeClass('disable-click');
this.$page.find('.codex-editor').removeClass('hidden');
this.$page.find('.workspace-skeleton').remove();
});

if (this.pages && this.pages[this_page.name]) {
this.page_data = this.pages[this_page.name];
} else {
await this.get_data(this_page);
}

this.prepare_editorjs();
$('.item-anchor').removeClass('disable-click');
this.$page.find('.codex-editor').removeClass('hidden');
this.$page.find('.workspace-skeleton').remove();
}
}

@@ -652,7 +625,7 @@ frappe.views.Workspace = class Workspace {
let $sidebar_section = is_public ? $sidebar[1] : $sidebar[0];

if (!parent) {
!is_public && $sidebar.last().removeClass('hidden');
!is_public && $sidebar.first().removeClass('hidden');
$sidebar_item.appendTo($sidebar_section);
} else {
let $item_container = $($sidebar_section).find(`[item-name="${parent}"]`);
@@ -670,6 +643,42 @@ frappe.views.Workspace = class Workspace {
}

initialize_editorjs(blocks) {
this.tools = {
header: {
class: this.blocks['header'],
inlineToolbar: true
},
paragraph: {
class: this.blocks['paragraph'],
inlineToolbar: true
},
chart: {
class: this.blocks['chart'],
config: {
page_data: this.page_data || []
}
},
card: {
class: this.blocks['card'],
config: {
page_data: this.page_data || []
}
},
shortcut: {
class: this.blocks['shortcut'],
config: {
page_data: this.page_data || []
}
},
onboarding: {
class: this.blocks['onboarding'],
config: {
page_data: this.page_data || []
}
},
spacer: this.blocks['spacer'],
spacingTune: frappe.wspace_block.tunes['spacing_tune'],
};
this.editor = new EditorJS({
data: {
blocks: blocks || []
@@ -730,6 +739,7 @@ frappe.views.Workspace = class Workspace {
frappe.dom.unfreeze();
if (res.message) {
me.new_page = res.message;
me.pages[res.message.label] && delete me.pages[res.message.label];
me.title = '';
me.icon = '';
me.parent = '';
@@ -751,7 +761,7 @@ frappe.views.Workspace = class Workspace {
reload() {
this.$page.prepend(frappe.render_template('workspace_loading_skeleton'));
this.$page.find('.codex-editor').addClass('hidden');
this.setup_pages();
this.setup_pages(true);
this.undo.readOnly = true;
}
};

+ 4
- 0
frappe/public/scss/desk/desktop.scss Переглянути файл

@@ -886,6 +886,10 @@ body {
}
}

.codex-editor__loader {
display: none !important;
}

.codex-editor {
min-height: 630px;



Завантаження…
Відмінити
Зберегти