fix: updating workspace of public page fix
This commit is contained in:
parent
afd44ea349
commit
a8a813623b
7 changed files with 49 additions and 17 deletions
|
|
@ -110,9 +110,18 @@ class Workspace:
|
|||
def get_page_for_user(self, wiki=False):
|
||||
filters = {
|
||||
'extends': self.page_name,
|
||||
'for_user': frappe.session.user
|
||||
'public': 1,
|
||||
'for_wiki': wiki
|
||||
}
|
||||
user_pages = frappe.get_all("Workspace", filters=filters, limit=1)
|
||||
if user_pages:
|
||||
return frappe.get_cached_doc("Workspace", user_pages[0])
|
||||
|
||||
filters = {
|
||||
'extends': self.page_name,
|
||||
'for_user': frappe.session.user,
|
||||
'for_wiki': wiki
|
||||
}
|
||||
filters['for_wiki'] = wiki
|
||||
user_pages = frappe.get_all("Workspace", filters=filters, limit=1)
|
||||
if user_pages:
|
||||
return frappe.get_cached_doc("Workspace", user_pages[0])
|
||||
|
|
@ -476,11 +485,19 @@ def get_custom_workspace_for_user(page, wiki=False):
|
|||
Returns:
|
||||
Object: Document object
|
||||
"""
|
||||
if wiki:
|
||||
filters = {
|
||||
'extends': page,
|
||||
'public': 1
|
||||
}
|
||||
pages = frappe.get_list("Workspace", filters=filters)
|
||||
if pages:
|
||||
return frappe.get_doc("Workspace", pages[0])
|
||||
filters = {
|
||||
'extends': page,
|
||||
'for_user': frappe.session.user
|
||||
'for_user': frappe.session.user,
|
||||
'for_wiki': wiki
|
||||
}
|
||||
filters['for_wiki'] = wiki
|
||||
pages = frappe.get_list("Workspace", filters=filters)
|
||||
if pages:
|
||||
return frappe.get_doc("Workspace", pages[0])
|
||||
|
|
@ -549,7 +566,7 @@ def save_customization(page, config):
|
|||
|
||||
return True
|
||||
|
||||
def save_new_widget(page, blocks, new_widgets):
|
||||
def save_new_widget(page, blocks, new_widgets, public=False):
|
||||
original_page = frappe.get_doc("Workspace", page)
|
||||
page_doc = get_custom_workspace_for_user(page, True)
|
||||
|
||||
|
|
@ -569,6 +586,7 @@ def save_new_widget(page, blocks, new_widgets):
|
|||
"charts": original_page.charts,
|
||||
"shortcuts": original_page.shortcuts,
|
||||
"links": original_page.links,
|
||||
"public": public
|
||||
})
|
||||
|
||||
widgets = _dict(loads(new_widgets))
|
||||
|
|
|
|||
|
|
@ -63,13 +63,16 @@ def save_wiki_page(title, parent, public, sb_items, deleted_pages, new_widgets,
|
|||
else:
|
||||
doc = frappe.get_doc("Internal Wiki", frappe.session.user)
|
||||
doc.wiki_pages.extend([new_doc])
|
||||
doc.save(ignore_permissions=True)
|
||||
else:
|
||||
# update the content of Internal Wiki Page of current user
|
||||
doc = frappe.get_doc("Internal Wiki", frappe.session.user)
|
||||
for d in doc.wiki_pages:
|
||||
if d.title == title:
|
||||
d.content = blocks
|
||||
doc.save(ignore_permissions=True)
|
||||
for page in ["Default", frappe.session.user]:
|
||||
if frappe.db.exists("Internal Wiki", page):
|
||||
doc = frappe.get_doc("Internal Wiki", page)
|
||||
for d in doc.wiki_pages:
|
||||
if d.title == title:
|
||||
d.content = blocks
|
||||
break
|
||||
doc.save(ignore_permissions=True)
|
||||
|
||||
if json.loads(deleted_pages):
|
||||
return delete_pages(json.loads(deleted_pages))
|
||||
|
|
@ -78,7 +81,7 @@ def save_wiki_page(title, parent, public, sb_items, deleted_pages, new_widgets,
|
|||
sort_pages(json.loads(sb_items))
|
||||
|
||||
if json.loads(new_widgets):
|
||||
save_new_widget(title, blocks, new_widgets)
|
||||
save_new_widget(title, blocks, new_widgets, public)
|
||||
|
||||
return title
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
"pin_to_bottom",
|
||||
"hide_custom",
|
||||
"for_wiki",
|
||||
"public",
|
||||
"section_break_2",
|
||||
"charts_label",
|
||||
"charts",
|
||||
|
|
@ -222,10 +223,16 @@
|
|||
"fieldname": "for_wiki",
|
||||
"fieldtype": "Check",
|
||||
"label": "For Wiki"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "public",
|
||||
"fieldtype": "Check",
|
||||
"label": "Public"
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2021-06-02 15:35:08.963507",
|
||||
"modified": "2021-06-09 14:50:41.204381",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Workspace",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default class Block {
|
|||
let block_data = this.config.page_data[block+'s'].items.find(obj => {
|
||||
return obj.label == block_name;
|
||||
});
|
||||
if (!block_data) return;
|
||||
if (!block_data) return false;
|
||||
this.wrapper.innerHTML = '';
|
||||
block_data.in_customize_mode = !this.readOnly;
|
||||
this.block_widget = new frappe.widget.SingleWidgetGroup({
|
||||
|
|
@ -25,6 +25,7 @@ export default class Block {
|
|||
if (!this.readOnly) {
|
||||
this.block_widget.customize();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
rendered() {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ export default class Card extends Block {
|
|||
this.new('card', 'links');
|
||||
|
||||
if (this.data && this.data.card_name) {
|
||||
this.make('card', this.data.card_name, 'links');
|
||||
let has_data = this.make('card', this.data.card_name, 'links');
|
||||
if (!has_data) return;
|
||||
}
|
||||
|
||||
if (!this.readOnly) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ export default class Chart extends Block {
|
|||
this.new('chart');
|
||||
|
||||
if (this.data && this.data.chart_name) {
|
||||
this.make('chart', this.data.chart_name);
|
||||
let has_data = this.make('chart', this.data.chart_name);
|
||||
if (!has_data) return;
|
||||
}
|
||||
|
||||
if (!this.readOnly) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ export default class Shortcut extends Block {
|
|||
this.new('shortcut');
|
||||
|
||||
if (this.data && this.data.shortcut_name) {
|
||||
this.make('shortcut', this.data.shortcut_name);
|
||||
let has_data = this.make('shortcut', this.data.shortcut_name);
|
||||
if (!has_data) return;
|
||||
}
|
||||
|
||||
if (!this.readOnly) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue