|
@@ -23,6 +23,7 @@ frappe.views.Workspace = class Workspace { |
|
|
this.blocks = frappe.wspace_block.blocks; |
|
|
this.blocks = frappe.wspace_block.blocks; |
|
|
this.is_read_only = true; |
|
|
this.is_read_only = true; |
|
|
this.new_page = null; |
|
|
this.new_page = null; |
|
|
|
|
|
this.pages = {}; |
|
|
this.sorted_public_items = []; |
|
|
this.sorted_public_items = []; |
|
|
this.sorted_private_items = []; |
|
|
this.sorted_private_items = []; |
|
|
this.deleted_sidebar_items = []; |
|
|
this.deleted_sidebar_items = []; |
|
@@ -35,42 +36,6 @@ frappe.views.Workspace = class Workspace { |
|
|
'My Workspaces', |
|
|
'My Workspaces', |
|
|
'Public' |
|
|
'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.prepare_container(); |
|
|
this.setup_pages(); |
|
|
this.setup_pages(); |
|
@@ -86,7 +51,7 @@ frappe.views.Workspace = class Workspace { |
|
|
this.body = this.wrapper.find(".layout-main-section"); |
|
|
this.body = this.wrapper.find(".layout-main-section"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setup_pages() { |
|
|
|
|
|
|
|
|
setup_pages(reload) { |
|
|
this.get_pages().then(pages => { |
|
|
this.get_pages().then(pages => { |
|
|
this.all_pages = pages.pages; |
|
|
this.all_pages = pages.pages; |
|
|
this.has_access = pages.has_access; |
|
|
this.has_access = pages.has_access; |
|
@@ -115,7 +80,7 @@ frappe.views.Workspace = class Workspace { |
|
|
this.new_page = null; |
|
|
this.new_page = null; |
|
|
} |
|
|
} |
|
|
this.make_sidebar(); |
|
|
this.make_sidebar(); |
|
|
frappe.router.route(); |
|
|
|
|
|
|
|
|
reload && this.show(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@@ -236,10 +201,7 @@ frappe.views.Workspace = class Workspace { |
|
|
return; |
|
|
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.page.set_title(`${__(page.name)}`); |
|
|
|
|
|
|
|
|
this.show_page(page); |
|
|
this.show_page(page); |
|
@@ -250,6 +212,11 @@ frappe.views.Workspace = class Workspace { |
|
|
page: page |
|
|
page: page |
|
|
}).then(data => { |
|
|
}).then(data => { |
|
|
this.page_data = 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; |
|
|
if (!this.page_data || Object.keys(this.page_data).length === 0) return; |
|
|
|
|
|
|
|
|
return frappe.dashboard_utils.get_dashboard_settings().then(settings => { |
|
|
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] || {}; |
|
|
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 }; |
|
|
return { name: page, public: is_public }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
show_page(page) { |
|
|
|
|
|
|
|
|
async show_page(page) { |
|
|
let section = this.current_page.public ? 'public' : 'private'; |
|
|
let section = this.current_page.public ? 'public' : 'private'; |
|
|
if (this.sidebar_items && this.sidebar_items[section] && this.sidebar_items[section][this.current_page.name]) { |
|
|
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"); |
|
|
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(); |
|
|
this.add_custom_cards_in_content(); |
|
|
|
|
|
|
|
|
$('.item-anchor').addClass('disable-click'); |
|
|
$('.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]; |
|
|
let $sidebar_section = is_public ? $sidebar[1] : $sidebar[0]; |
|
|
|
|
|
|
|
|
if (!parent) { |
|
|
if (!parent) { |
|
|
!is_public && $sidebar.last().removeClass('hidden'); |
|
|
|
|
|
|
|
|
!is_public && $sidebar.first().removeClass('hidden'); |
|
|
$sidebar_item.appendTo($sidebar_section); |
|
|
$sidebar_item.appendTo($sidebar_section); |
|
|
} else { |
|
|
} else { |
|
|
let $item_container = $($sidebar_section).find(`[item-name="${parent}"]`); |
|
|
let $item_container = $($sidebar_section).find(`[item-name="${parent}"]`); |
|
@@ -670,6 +643,42 @@ frappe.views.Workspace = class Workspace { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
initialize_editorjs(blocks) { |
|
|
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({ |
|
|
this.editor = new EditorJS({ |
|
|
data: { |
|
|
data: { |
|
|
blocks: blocks || [] |
|
|
blocks: blocks || [] |
|
@@ -730,6 +739,7 @@ frappe.views.Workspace = class Workspace { |
|
|
frappe.dom.unfreeze(); |
|
|
frappe.dom.unfreeze(); |
|
|
if (res.message) { |
|
|
if (res.message) { |
|
|
me.new_page = res.message; |
|
|
me.new_page = res.message; |
|
|
|
|
|
me.pages[res.message.label] && delete me.pages[res.message.label]; |
|
|
me.title = ''; |
|
|
me.title = ''; |
|
|
me.icon = ''; |
|
|
me.icon = ''; |
|
|
me.parent = ''; |
|
|
me.parent = ''; |
|
@@ -751,7 +761,7 @@ frappe.views.Workspace = class Workspace { |
|
|
reload() { |
|
|
reload() { |
|
|
this.$page.prepend(frappe.render_template('workspace_loading_skeleton')); |
|
|
this.$page.prepend(frappe.render_template('workspace_loading_skeleton')); |
|
|
this.$page.find('.codex-editor').addClass('hidden'); |
|
|
this.$page.find('.codex-editor').addClass('hidden'); |
|
|
this.setup_pages(); |
|
|
|
|
|
|
|
|
this.setup_pages(true); |
|
|
this.undo.readOnly = true; |
|
|
this.undo.readOnly = true; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |