mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 14:09:19 +00:00
Merge pull request #30809 from frappe/mergify/bp/version-13-hotfix/pr-30808
fix(pos): search field doesn't reset on checkout (backport #30808)
This commit is contained in:
@@ -343,9 +343,9 @@ erpnext.PointOfSale.Controller = class {
|
|||||||
toggle_other_sections: (show) => {
|
toggle_other_sections: (show) => {
|
||||||
if (show) {
|
if (show) {
|
||||||
this.item_details.$component.is(':visible') ? this.item_details.$component.css('display', 'none') : '';
|
this.item_details.$component.is(':visible') ? this.item_details.$component.css('display', 'none') : '';
|
||||||
this.item_selector.$component.css('display', 'none');
|
this.item_selector.toggle_component(false);
|
||||||
} else {
|
} else {
|
||||||
this.item_selector.$component.css('display', 'flex');
|
this.item_selector.toggle_component(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -130,10 +130,10 @@ erpnext.PointOfSale.ItemCart = class {
|
|||||||
},
|
},
|
||||||
cols: 5,
|
cols: 5,
|
||||||
keys: [
|
keys: [
|
||||||
[ 1, 2, 3, __('Quantity') ],
|
[ 1, 2, 3, 'Quantity' ],
|
||||||
[ 4, 5, 6, __('Discount') ],
|
[ 4, 5, 6, 'Discount' ],
|
||||||
[ 7, 8, 9, __('Rate') ],
|
[ 7, 8, 9, 'Rate' ],
|
||||||
[ '.', 0, __('Delete'), __('Remove') ]
|
[ '.', 0, 'Delete', 'Remove' ]
|
||||||
],
|
],
|
||||||
css_classes: [
|
css_classes: [
|
||||||
[ '', '', '', 'col-span-2' ],
|
[ '', '', '', 'col-span-2' ],
|
||||||
|
|||||||
@@ -179,6 +179,25 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
});
|
});
|
||||||
this.search_field.toggle_label(false);
|
this.search_field.toggle_label(false);
|
||||||
this.item_group_field.toggle_label(false);
|
this.item_group_field.toggle_label(false);
|
||||||
|
|
||||||
|
this.attach_clear_btn();
|
||||||
|
}
|
||||||
|
|
||||||
|
attach_clear_btn() {
|
||||||
|
this.search_field.$wrapper.find('.control-input').append(
|
||||||
|
`<span class="link-btn" style="top: 2px;">
|
||||||
|
<a class="btn-open no-decoration" title="${__("Clear")}">
|
||||||
|
${frappe.utils.icon('close', 'sm')}
|
||||||
|
</a>
|
||||||
|
</span>`
|
||||||
|
);
|
||||||
|
|
||||||
|
this.$clear_search_btn = this.search_field.$wrapper.find('.link-btn');
|
||||||
|
|
||||||
|
this.$clear_search_btn.on('click', 'a', () => {
|
||||||
|
this.set_search_value('');
|
||||||
|
this.search_field.set_focus();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
set_search_value(value) {
|
set_search_value(value) {
|
||||||
@@ -252,6 +271,16 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
const search_term = e.target.value;
|
const search_term = e.target.value;
|
||||||
this.filter_items({ search_term });
|
this.filter_items({ search_term });
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
this.$clear_search_btn.toggle(
|
||||||
|
Boolean(this.search_field.$input.val())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.search_field.$input.on('focus', () => {
|
||||||
|
this.$clear_search_btn.toggle(
|
||||||
|
Boolean(this.search_field.$input.val())
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +313,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
if (this.items.length == 1) {
|
if (this.items.length == 1) {
|
||||||
this.$items_container.find(".item-wrapper").click();
|
this.$items_container.find(".item-wrapper").click();
|
||||||
frappe.utils.play_sound("submit");
|
frappe.utils.play_sound("submit");
|
||||||
$(this.search_field.$input[0]).val("").trigger("input");
|
this.set_search_value('');
|
||||||
} else if (this.items.length == 0 && this.barcode_scanned) {
|
} else if (this.items.length == 0 && this.barcode_scanned) {
|
||||||
// only show alert of barcode is scanned and enter is pressed
|
// only show alert of barcode is scanned and enter is pressed
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
@@ -293,7 +322,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
});
|
});
|
||||||
frappe.utils.play_sound("error");
|
frappe.utils.play_sound("error");
|
||||||
this.barcode_scanned = false;
|
this.barcode_scanned = false;
|
||||||
$(this.search_field.$input[0]).val("").trigger("input");
|
this.set_search_value('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -350,6 +379,7 @@ erpnext.PointOfSale.ItemSelector = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggle_component(show) {
|
toggle_component(show) {
|
||||||
show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none');
|
this.set_search_value('');
|
||||||
|
this.$component.css('display', show ? 'flex': 'none');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ erpnext.PointOfSale.NumberPad = class {
|
|||||||
const fieldname = fieldnames && fieldnames[number] ?
|
const fieldname = fieldnames && fieldnames[number] ?
|
||||||
fieldnames[number] : typeof number === 'string' ? frappe.scrub(number) : number;
|
fieldnames[number] : typeof number === 'string' ? frappe.scrub(number) : number;
|
||||||
|
|
||||||
return a2 + `<div class="numpad-btn ${class_to_append}" data-button-value="${fieldname}">${number}</div>`;
|
return a2 + `<div class="numpad-btn ${class_to_append}" data-button-value="${fieldname}">${__(number)}</div>`;
|
||||||
}, '');
|
}, '');
|
||||||
}, '');
|
}, '');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user