Merge pull request #23678 from niraj2477/gh-20969

feat(List View): Add button to remove multiple assignments
This commit is contained in:
mergify[bot] 2024-01-13 07:57:17 +00:00 committed by GitHub
commit 4655c6c1e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 1 deletions

View file

@ -25,6 +25,7 @@ context("List View", () => {
"Edit",
"Export",
"Assign To",
"Clear Assignment",
"Apply Assignment Rule",
"Add Tags",
"Print",
@ -35,7 +36,7 @@ context("List View", () => {
cy.get(".list-header-subject > .list-subject > .list-check-all").click();
cy.findByRole("button", { name: "Actions" }).click();
cy.get(".dropdown-menu li:visible .dropdown-item")
.should("have.length", 9)
.should("have.length", 10)
.each((el, index) => {
cy.wrap(el).contains(actions[index]);
})

View file

@ -175,6 +175,20 @@ def remove(doctype, name, assign_to, ignore_permissions=False):
)
@frappe.whitelist()
def remove_multiple(doctype, names, ignore_permissions=False):
docname_list = json.loads(names)
for name in docname_list:
assignments = get({"doctype": doctype, "name": name})
if not assignments:
continue
for assignment in assignments:
remove(doctype, name, assignment.get("owner"), ignore_permissions)
@frappe.whitelist()
def close(doctype: str, name: str, assign_to: str, ignore_permissions=False):
if assign_to != frappe.session.user:

View file

@ -196,6 +196,27 @@ export default class BulkOperations {
}
}
clear_assignment(docnames, done) {
if (docnames.length > 0) {
frappe
.call({
method: "frappe.desk.form.assign_to.remove_multiple",
args: {
doctype: this.doctype,
names: docnames,
ignore_permissions: true,
},
freeze: true,
freeze_message: "Removing assignments...",
})
.then(() => {
done();
});
} else {
frappe.msgprint(__("Select records for removing assignment"));
}
}
apply_assignment_rule(docnames, done) {
if (docnames.length > 0) {
frappe

View file

@ -1814,6 +1814,30 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
};
};
const bulk_assignment_clear = () => {
return {
label: __("Clear Assignment", null, "Button in list view actions menu"),
action: () => {
frappe.confirm(
"Are you sure you want to clear the assignments?",
() => {
this.disable_list_update = true;
bulk_operations.clear_assignment(this.get_checked_items(true), () => {
this.disable_list_update = false;
this.clear_checked_items();
this.refresh();
});
},
() => {
this.clear_checked_items();
this.refresh();
}
);
},
standard: true,
};
};
const bulk_assignment_rule = () => {
return {
label: __("Apply Assignment Rule", null, "Button in list view actions menu"),
@ -1982,6 +2006,8 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
// bulk assignment
actions_menu_items.push(bulk_assignment());
actions_menu_items.push(bulk_assignment_clear());
actions_menu_items.push(bulk_assignment_rule());
actions_menu_items.push(bulk_add_tags());