fix: sidebar sorting only in edit mode

This commit is contained in:
sokumon 2025-01-02 15:31:14 +05:30
parent 6a861fc3c8
commit 04fd2317ae
3 changed files with 13 additions and 7 deletions

View file

@ -347,14 +347,19 @@ frappe.ui.Sidebar = class Sidebar {
$child_item_section.toggleClass("hidden");
});
}
toggle_sorting() {
this.sorting_items.forEach((item) => {
var state = item.option("disabled");
item.option("disabled", !state);
});
}
setup_sorting() {
if (!this.has_access) return;
this.sorting_items = [];
for (let container of this.$sidebar.find(".nested-container")) {
Sortable.create(container, {
this.sorting_items[this.sorting_items.length] = Sortable.create(container, {
group: "sidebar-items",
fitler: ".divider",
disabled: true,
onEnd: () => {
let sidebar_items = [];
for (let container of this.$sidebar.find(".nested-container")) {

View file

@ -79,9 +79,8 @@ frappe.breadcrumbs = {
frappe.workspace_map[breadcrumbs.workspace]?.app &&
frappe.workspace_map[breadcrumbs.workspace]?.app != frappe.current_app
) {
frappe.app.sidebar.apps_switcher.set_current_app(
frappe.workspace_map[breadcrumbs.workspace].app
);
let app = frappe.workspace_map[breadcrumbs.workspace].app;
frappe.app.sidebar.apps_switcher.set_current_app(app);
}
this.toggle(true);

View file

@ -95,6 +95,7 @@ frappe.views.Workspace = class Workspace {
this.editor.isReady.then(() => {
this.setup_customization_buttons(this._page);
this.make_blocks_sortable();
frappe.app.sidebar.toggle_sorting();
});
});
}
@ -342,6 +343,7 @@ frappe.views.Workspace = class Workspace {
this.editor.readOnly.toggle();
this.is_read_only = true;
});
frappe.app.sidebar.toggle_sorting();
},
null,
__("Saving")