Переглянути джерело

feat: custom __link_options (#17699) (#17838)

* feat: custom __link_optins

* chore: linter fixes

* test: add ui test for custom link option

(cherry picked from commit 1aa3f75d4c)

Co-authored-by: Himanshu <himanshuwarekar@yahoo.com>
version-14
mergify[bot] 2 роки тому
committed by GitHub
джерело
коміт
10faee0a04
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: 4AEE18F83AFDEB23
2 змінених файлів з 36 додано та 1 видалено
  1. +26
    -0
      cypress/integration/control_link.js
  2. +10
    -1
      frappe/public/js/frappe/form/controls/link.js

+ 26
- 0
cypress/integration/control_link.js Переглянути файл

@@ -310,4 +310,30 @@ context("Control Link", () => {
expect(label).to.eq("Non-Conforming");
});
});

it("show custom link option", () => {
cy.window()
.its("frappe")
.then((frappe) => {
frappe.ui.form.ControlLink.link_options = (link) => {
return [
{
html:
"<span class='text-primary custom-link-option'>" +
"<i class='fa fa-search' style='margin-right: 5px;'></i> " +
"Custom Link Option" +
"</span>",
label: "Custom Link Option",
value: "custom__link_option",
action: () => {},
},
];
};

get_dialog_with_link().as("dialog");
cy.get(".frappe-control[data-fieldname=link] input").focus().as("input");
cy.get("@input").type("custom", { delay: 100 });
cy.get(".custom-link-option").should("be.visible");
});
});
});

+ 10
- 1
frappe/public/js/frappe/form/controls/link.js Переглянути файл

@@ -288,8 +288,17 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
action: me.new_doc,
});
}
// advanced search

//custom link actions
let custom__link_options =
frappe.ui.form.ControlLink.link_options &&
frappe.ui.form.ControlLink.link_options(me);

if (custom__link_options) {
r.results = r.results.concat(custom__link_options);
}

// advanced search
if (locals && locals["DocType"]) {
// not applicable in web forms
r.results.push({


Завантаження…
Відмінити
Зберегти