Merge pull request #13952 from shariquerik/workspace2-fixes

This commit is contained in:
Suraj Shetty 2021-08-17 15:04:28 +05:30 committed by GitHub
commit 54a331a05e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 22 deletions

View file

@ -14,7 +14,7 @@ context('Workspace 2.0', () => {
it('Create Private Page', () => {
cy.get('.codex-editor__redactor .ce-block');
cy.get('.custom-actions button[data-label="Create%20Page"]').click();
cy.get('.custom-actions button[data-label="Create%20Workspace"]').click();
cy.fill_field('title', 'Test Private Page', 'Data');
cy.fill_field('icon', 'edit', 'Icon');
cy.get_open_dialog().find('.modal-header').click();
@ -29,7 +29,7 @@ context('Workspace 2.0', () => {
cy.wait(500);
cy.get('.codex-editor__redactor .ce-block');
cy.get('.standard-actions .btn-secondary[data-label=Customize]').click();
cy.get('.standard-actions .btn-secondary[data-label=Edit]').click();
});
it('Add New Block', () => {
@ -77,7 +77,7 @@ context('Workspace 2.0', () => {
it('Delete Private Page', () => {
cy.get('.codex-editor__redactor .ce-block');
cy.get('.standard-actions .btn-secondary[data-label=Customize]').click();
cy.get('.standard-actions .btn-secondary[data-label=Edit]').click();
cy.get('.sidebar-item-container[item-name="Test Private Page"]').find('.sidebar-item-control .delete-page').click();
cy.wait(300);

View file

@ -368,7 +368,7 @@ def get_desktop_page(page):
on desk.
Args:
page (string): page name
page (json): page data
Returns:
dict: dictionary of cards, charts and shortcuts to be displayed on website

View file

@ -14,7 +14,7 @@ export default class Card extends Block {
constructor({ data, api, config, readOnly, block }) {
super({ data, api, config, readOnly, block });
this.sections = {};
this.col = this.data.col ? this.data.col : "12";
this.col = this.data.col ? this.data.col : "4";
this.allow_customization = !this.readOnly;
this.options = {
allow_sorting: this.allow_customization,

View file

@ -123,10 +123,10 @@ export default class Paragraph extends Block {
return true;
}
save(toolsContent) {
save() {
this.wrapper = this._element;
return {
text: toolsContent.innerText,
text: this.wrapper.innerHTML,
col: this.get_col(),
};
}
@ -155,6 +155,9 @@ export default class Paragraph extends Block {
return {
text: {
br: true,
b: true,
i: true,
a: true
}
};
}

View file

@ -13,7 +13,7 @@ export default class Shortcut extends Block {
constructor({ data, api, config, readOnly, block }) {
super({ data, api, config, readOnly, block });
this.col = this.data.col ? this.data.col : "12";
this.col = this.data.col ? this.data.col : "4";
this.allow_customization = !this.readOnly;
this.options = {
allow_sorting: this.allow_customization,

View file

@ -32,8 +32,8 @@ frappe.views.Workspace = class Workspace {
'private': {}
};
this.sidebar_categories = [
'Public',
frappe.user.first_name() || 'Private'
'My Workspaces',
'Public'
];
this.tools = {
header: {
@ -357,7 +357,7 @@ frappe.views.Workspace = class Workspace {
let current_page = pages.filter(p => p.title == page.name)[0];
if (!this.is_read_only) {
this.setup_customization_buttons(current_page.is_editable);
this.setup_customization_buttons(current_page);
return;
}
@ -365,20 +365,20 @@ frappe.views.Workspace = class Workspace {
this.page.clear_secondary_action();
this.page.clear_inner_toolbar();
current_page.is_editable && this.page.set_secondary_action(__("Customize"), () => {
current_page.is_editable && this.page.set_secondary_action(__("Edit"), () => {
if (!this.editor || !this.editor.readOnly) return;
this.is_read_only = false;
this.editor.readOnly.toggle();
this.editor.isReady.then(() => {
this.initialize_editorjs_undo();
this.setup_customization_buttons(true);
this.setup_customization_buttons(current_page);
this.show_sidebar_actions();
this.make_sidebar_sortable();
this.make_blocks_sortable();
});
});
this.page.add_inner_button(__("Create Page"), () => {
this.page.add_inner_button(__("Create Workspace"), () => {
this.initialize_new_page();
});
}
@ -389,13 +389,13 @@ frappe.views.Workspace = class Workspace {
this.undo.readOnly = false;
}
setup_customization_buttons(is_editable) {
setup_customization_buttons(page) {
let me = this;
this.page.clear_primary_action();
this.page.clear_secondary_action();
this.page.clear_inner_toolbar();
is_editable && this.page.set_primary_action(
page.is_editable && this.page.set_primary_action(
__("Save Customizations"),
() => {
this.page.clear_primary_action();
@ -424,6 +424,10 @@ frappe.views.Workspace = class Workspace {
}
);
page.name && this.page.add_inner_button(__("Settings"), () => {
frappe.set_route(`workspace/${page.name}`);
});
Object.keys(this.blocks).forEach(key => {
this.page.add_inner_button(`
<span class="block-menu-item-icon">${this.blocks[key].toolbox.icon}</span>
@ -446,7 +450,7 @@ frappe.views.Workspace = class Workspace {
$(`<span class="sidebar-info">${frappe.utils.icon("lock", "sm")}</span>`)
.appendTo(sidebar_control);
sidebar_control.parent().click(() => {
frappe.show_alert({
!this.is_read_only && frappe.show_alert({
message: __("Only Workspace Manager can sort or edit this page"),
indicator: 'info'
}, 5);
@ -498,9 +502,9 @@ frappe.views.Workspace = class Workspace {
prepare_sorted_sidebar(is_public) {
if (is_public) {
this.sorted_public_items = this.sort_sidebar(this.sidebar.find('.standard-sidebar-section').first());
this.sorted_public_items = this.sort_sidebar(this.sidebar.find('.standard-sidebar-section').last());
} else {
this.sorted_private_items = this.sort_sidebar(this.sidebar.find('.standard-sidebar-section').last());
this.sorted_private_items = this.sort_sidebar(this.sidebar.find('.standard-sidebar-section').first());
}
}
@ -578,7 +582,7 @@ frappe.views.Workspace = class Workspace {
if (!this.validate_page(values)) return;
d.hide();
this.initialize_editorjs_undo();
this.setup_customization_buttons(true);
this.setup_customization_buttons({is_editable: true});
this.title = values.title;
this.icon = values.icon;
this.parent = values.parent;
@ -647,7 +651,7 @@ frappe.views.Workspace = class Workspace {
);
$sidebar_item.find('.sidebar-item-control .drag-handle').css('margin-right', '8px');
let $sidebar_section = is_public ? $sidebar[0] : $sidebar[1];
let $sidebar_section = is_public ? $sidebar[1] : $sidebar[0];
if (!parent) {
!is_public && $sidebar.last().removeClass('hidden');

View file

@ -946,7 +946,11 @@ body {
&.new-widget {
align-items: inherit;
}
&.ce-paragraph {
display: block;
}
.paragraph-control {
display: flex;
flex-direction: row-reverse;