diff --git a/cypress/integration/list_view.js b/cypress/integration/list_view.js index 7117d8f98d..d6cc16fef1 100644 --- a/cypress/integration/list_view.js +++ b/cypress/integration/list_view.js @@ -51,4 +51,33 @@ context("List View", () => { cy.get(".list-row-container:visible").should("contain", "Approved"); }); }); + + it("Adds a button to each list view row", () => { + // Get a ToDo with a reference name + cy.call("frappe.client.get_value", { + doctype: "ToDo", + filters: { + reference_name: ["is", "set"], + }, + fieldname: "name", + }).then((r) => { + const todo_name = r.message.name; + cy.go_to_list("ToDo"); + + // Check if the 'Open' button is present in the ToDo list view + cy.get(".btn-default[data-name='" + todo_name + "']") + .should((el) => { + expect(el).to.exist; + }) + .click(); + + cy.window() + .its("cur_frm") + .then((frm) => { + // Routes to the reference document + expect(frm.doc.doctype).to.equal("ToDo"); + expect(frm.doc.name).to.not.equal(todo_name); + }); + }); + }); }); diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 763b1b7466..e79dfc1fc1 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -692,7 +692,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { ${__(subject_field.label)} `; - const $columns = this.columns + let $columns = this.columns .map((col) => { let classes = [ "list-row-col ellipsis", @@ -717,6 +717,14 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { }) .join(""); + // Add column for button and dropdown button to the header + if (this.settings.button) { + $columns += ``; + } + if (this.settings.dropdown_button) { + $columns += ``; + } + const right_html = `