Merge pull request #27736 from JefteSG/develop
feat: implement Clear Button in Link Field
This commit is contained in:
commit
2b1150ff44
1 changed files with 8 additions and 2 deletions
|
|
@ -5,7 +5,6 @@
|
|||
// custom queries
|
||||
// add_fetches
|
||||
import Awesomplete from "awesomplete";
|
||||
|
||||
frappe.ui.form.recent_link_validations = {};
|
||||
|
||||
frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlData {
|
||||
|
|
@ -15,6 +14,9 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
|
|||
$(`<div class="link-field ui-front" style="position: relative;">
|
||||
<input type="text" class="input-with-feedback form-control">
|
||||
<span class="link-btn">
|
||||
<a class="btn-clear no-decoration">
|
||||
${frappe.utils.icon("close-alt", "xs")}
|
||||
</a>
|
||||
<a class="btn-open no-decoration" title="${__("Open Link")}">
|
||||
${frappe.utils.icon("arrow-right", "xs")}
|
||||
</a>
|
||||
|
|
@ -23,6 +25,7 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
|
|||
this.$input_area = $(this.input_area);
|
||||
this.$input = this.$input_area.find("input");
|
||||
this.$link = this.$input_area.find(".link-btn");
|
||||
this.$link_clear = this.$input_area.find(".btn-clear");
|
||||
this.$link_open = this.$link.find(".btn-open");
|
||||
this.set_input_attributes();
|
||||
this.$input.on("focus", function () {
|
||||
|
|
@ -32,6 +35,10 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
|
|||
let name = me.get_input_value();
|
||||
me.$link.toggle(true);
|
||||
me.$link_open.attr("href", frappe.utils.get_form_link(doctype, name));
|
||||
me.$link_clear.on("click", function () {
|
||||
me.$input.val("").trigger("input");
|
||||
me.$link.toggle(false);
|
||||
});
|
||||
}
|
||||
|
||||
if (!me.$input.val()) {
|
||||
|
|
@ -327,7 +334,6 @@ frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlDat
|
|||
me.$input.cache[doctype][term] = r.message;
|
||||
me.awesomplete.list = me.$input.cache[doctype][term];
|
||||
me.toggle_href(doctype);
|
||||
|
||||
r.message.forEach((item) => {
|
||||
frappe.utils.add_link_title(doctype, item.value, item.label);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue