Skip to content

Commit

Permalink
fix: default filter setup on todo list (#25455) (#25464)
Browse files Browse the repository at this point in the history
* fix: default filter setup on todo list

Since `frappe.route_options` is an empty object by default, the condition needs updated from `!frappe.route_options` to `!Object.keys(frappe.route_options).length`.

Also, `allocated_to` is a better default filter for the To Do list compared to the previous `owner` filter.

Further, this contained the only use of `page.add_sidebar_item()` in all of the current Frappe and ERPNext codebase, and that function neither makes sense or works anymore, so it should be removed.

* refactor: remove deprecated add_sidebar_item

* style: format files

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
(cherry picked from commit 396bc41)

Co-authored-by: Kevin Shenk <kevin@avu.nu>
  • Loading branch information
mergify[bot] and batonac committed Mar 15, 2024
1 parent eab5b8d commit 21e1280
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
19 changes: 2 additions & 17 deletions frappe/desk/doctype/todo/todo_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ frappe.listview_settings["ToDo"] = {
add_fields: ["reference_type", "reference_name"],

onload: function (me) {
if (!frappe.route_options) {
if (!Object.keys(frappe.route_options).length) {
frappe.route_options = {
owner: frappe.session.user,
allocated_to: frappe.session.user,
status: "Open",
};
}
Expand All @@ -26,19 +26,4 @@ frappe.listview_settings["ToDo"] = {
frappe.set_route("Form", doc.reference_type, doc.reference_name);
},
},

refresh: function (me) {
if (me.todo_sidebar_setup) return;

// add assigned by me
me.page.add_sidebar_item(
__("Assigned By Me"),
function () {
me.filter_area.add([[me.doctype, "assigned_by", "=", frappe.session.user]]);
},
'.list-link[data-view="Kanban"]'
);

me.todo_sidebar_setup = true;
},
};
21 changes: 0 additions & 21 deletions frappe/public/js/frappe/ui/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,27 +732,6 @@ frappe.ui.Page = class Page {
this.inner_toolbar.empty().addClass("hide");
}

//-- Sidebar --//

add_sidebar_item(label, action, insert_after, prepend) {
var parent = this.sidebar.find(".sidebar-menu.standard-actions");
var li = $("<li>");
var link = $("<a>").html(label).on("click", action).appendTo(li);

if (insert_after) {
li.insertAfter(parent.find(insert_after));
} else {
if (prepend) {
li.prependTo(parent);
} else {
li.appendTo(parent);
}
}
return link;
}

//---//

clear_user_actions() {
this.menu.find(".user-action").remove();
}
Expand Down

0 comments on commit 21e1280

Please sign in to comment.