mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
POS - Translate some text & numpad (#14765)
* make label & placeholder translatable * numpad translatable * Update point_of_sale.js remove debugger
This commit is contained in:
committed by
Nabin Hait
parent
e3daaa63f0
commit
8662a4f677
@@ -408,7 +408,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
this.search_item = frappe.ui.form.make_control({
|
this.search_item = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Item",
|
"label": __("Item"),
|
||||||
"fieldname": "pos_item",
|
"fieldname": "pos_item",
|
||||||
"placeholder": __("Search Item")
|
"placeholder": __("Search Item")
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
this.update_item_in_cart(item_code, field, value, batch_no);
|
this.update_item_in_cart(item_code, field, value, batch_no);
|
||||||
},
|
},
|
||||||
on_numpad: (value) => {
|
on_numpad: (value) => {
|
||||||
if (value == 'Pay') {
|
if (value == __('Pay')) {
|
||||||
if (!this.payment) {
|
if (!this.payment) {
|
||||||
this.make_payment_modal();
|
this.make_payment_modal();
|
||||||
} else {
|
} else {
|
||||||
@@ -548,6 +548,8 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [Qty,Disc,Rate,Del,Pay] = [__("Qty"), __('Disc'), __('Rate'), __('Del'), __('Pay')];
|
||||||
|
|
||||||
class POSCart {
|
class POSCart {
|
||||||
constructor({frm, wrapper, events}) {
|
constructor({frm, wrapper, events}) {
|
||||||
this.frm = frm;
|
this.frm = frm;
|
||||||
@@ -579,7 +581,7 @@ class POSCart {
|
|||||||
</div>
|
</div>
|
||||||
<div class="cart-items">
|
<div class="cart-items">
|
||||||
<div class="empty-state">
|
<div class="empty-state">
|
||||||
<span>No Items added to cart</span>
|
<span>${__('No Items added to cart')}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="taxes-and-totals">
|
<div class="taxes-and-totals">
|
||||||
@@ -775,42 +777,45 @@ class POSCart {
|
|||||||
disable_numpad_control() {
|
disable_numpad_control() {
|
||||||
let disabled_btns = [];
|
let disabled_btns = [];
|
||||||
if(!this.frm.allow_edit_rate) {
|
if(!this.frm.allow_edit_rate) {
|
||||||
disabled_btns.push('Rate');
|
disabled_btns.push(__('Rate'));
|
||||||
}
|
}
|
||||||
if(!this.frm.allow_edit_discount) {
|
if(!this.frm.allow_edit_discount) {
|
||||||
disabled_btns.push('Disc');
|
disabled_btns.push(__('Disc'));
|
||||||
}
|
}
|
||||||
return disabled_btns;
|
return disabled_btns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
make_numpad() {
|
make_numpad() {
|
||||||
|
|
||||||
|
var pay_class = {}
|
||||||
|
pay_class[__('Pay')]='brand-primary'
|
||||||
this.numpad = new NumberPad({
|
this.numpad = new NumberPad({
|
||||||
button_array: [
|
button_array: [
|
||||||
[1, 2, 3, 'Qty'],
|
[1, 2, 3, Qty],
|
||||||
[4, 5, 6, 'Disc'],
|
[4, 5, 6, Disc],
|
||||||
[7, 8, 9, 'Rate'],
|
[7, 8, 9, Rate],
|
||||||
['Del', 0, '.', 'Pay']
|
[Del, 0, '.', Pay]
|
||||||
],
|
],
|
||||||
add_class: {
|
add_class: pay_class,
|
||||||
'Pay': 'brand-primary'
|
disable_highlight: [Qty, Disc, Rate, Pay],
|
||||||
},
|
reset_btns: [Qty, Disc, Rate, Pay],
|
||||||
disable_highlight: ['Qty', 'Disc', 'Rate', 'Pay'],
|
del_btn: Del,
|
||||||
reset_btns: ['Qty', 'Disc', 'Rate', 'Pay'],
|
|
||||||
del_btn: 'Del',
|
|
||||||
disable_btns: this.disable_numpad_control(),
|
disable_btns: this.disable_numpad_control(),
|
||||||
wrapper: this.wrapper.find('.number-pad-container'),
|
wrapper: this.wrapper.find('.number-pad-container'),
|
||||||
onclick: (btn_value) => {
|
onclick: (btn_value) => {
|
||||||
// on click
|
// on click
|
||||||
if (!this.selected_item && btn_value !== 'Pay') {
|
|
||||||
|
if (!this.selected_item && btn_value !== Pay) {
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
indicator: 'red',
|
indicator: 'red',
|
||||||
message: __('Please select an item in the cart')
|
message: __('Please select an item in the cart')
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (['Qty', 'Disc', 'Rate'].includes(btn_value)) {
|
if ([Qty, Disc, Rate].includes(btn_value)) {
|
||||||
this.set_input_active(btn_value);
|
this.set_input_active(btn_value);
|
||||||
} else if (btn_value !== 'Pay') {
|
} else if (btn_value !== Pay) {
|
||||||
if (!this.selected_item.active_field) {
|
if (!this.selected_item.active_field) {
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
indicator: 'red',
|
indicator: 'red',
|
||||||
@@ -844,13 +849,13 @@ class POSCart {
|
|||||||
this.selected_item.removeClass('qty disc rate');
|
this.selected_item.removeClass('qty disc rate');
|
||||||
|
|
||||||
this.numpad.set_active(btn_value);
|
this.numpad.set_active(btn_value);
|
||||||
if (btn_value === 'Qty') {
|
if (btn_value === Qty) {
|
||||||
this.selected_item.addClass('qty');
|
this.selected_item.addClass('qty');
|
||||||
this.selected_item.active_field = 'qty';
|
this.selected_item.active_field = 'qty';
|
||||||
} else if (btn_value == 'Disc') {
|
} else if (btn_value == Disc) {
|
||||||
this.selected_item.addClass('disc');
|
this.selected_item.addClass('disc');
|
||||||
this.selected_item.active_field = 'discount_percentage';
|
this.selected_item.active_field = 'discount_percentage';
|
||||||
} else if (btn_value == 'Rate') {
|
} else if (btn_value == Rate) {
|
||||||
this.selected_item.addClass('rate');
|
this.selected_item.addClass('rate');
|
||||||
this.selected_item.active_field = 'rate';
|
this.selected_item.active_field = 'rate';
|
||||||
}
|
}
|
||||||
@@ -982,16 +987,6 @@ class POSCart {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// this.$cart_items.on('focus', '.quantity input', function(e) {
|
|
||||||
// const $input = $(this);
|
|
||||||
// const $item = $input.closest('.list-item[data-item-code]');
|
|
||||||
// me.set_selected_item($item);
|
|
||||||
// me.set_input_active('Qty');
|
|
||||||
// e.preventDefault();
|
|
||||||
// e.stopPropagation();
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
|
|
||||||
this.$cart_items.on('change', '.quantity input', function() {
|
this.$cart_items.on('change', '.quantity input', function() {
|
||||||
const $input = $(this);
|
const $input = $(this);
|
||||||
const $item = $input.closest('.list-item[data-item-code]');
|
const $item = $input.closest('.list-item[data-item-code]');
|
||||||
@@ -1004,16 +999,6 @@ class POSCart {
|
|||||||
me.set_selected_item($(this));
|
me.set_selected_item($(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
// disable current item
|
|
||||||
// $('body').on('click', function(e) {
|
|
||||||
// console.log(e);
|
|
||||||
// if($(e.target).is('.list-item')) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// me.$cart_items.find('.list-item').removeClass('current-item qty disc rate');
|
|
||||||
// me.selected_item = null;
|
|
||||||
// });
|
|
||||||
|
|
||||||
this.wrapper.find('.additional_discount_percentage').on('change', (e) => {
|
this.wrapper.find('.additional_discount_percentage').on('change', (e) => {
|
||||||
const discount_percentage = flt(e.target.value,
|
const discount_percentage = flt(e.target.value,
|
||||||
precision("additional_discount_percentage"));
|
precision("additional_discount_percentage"));
|
||||||
@@ -1122,8 +1107,8 @@ class POSItems {
|
|||||||
this.search_field = frappe.ui.form.make_control({
|
this.search_field = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
fieldtype: 'Data',
|
fieldtype: 'Data',
|
||||||
label: 'Search Item (Ctrl + i)',
|
label: __('Search Item (Ctrl + i)'),
|
||||||
placeholder: 'Search by item code, serial number, batch no or barcode'
|
placeholder: __('Search by item code, serial number, batch no or barcode')
|
||||||
},
|
},
|
||||||
parent: this.wrapper.find('.search-field'),
|
parent: this.wrapper.find('.search-field'),
|
||||||
render_input: true,
|
render_input: true,
|
||||||
@@ -1486,7 +1471,7 @@ class Payment {
|
|||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[4, 5, 6],
|
[4, 5, 6],
|
||||||
[7, 8, 9],
|
[7, 8, 9],
|
||||||
['Del', 0, '.'],
|
[__('Del'), 0, '.'],
|
||||||
],
|
],
|
||||||
onclick: () => {
|
onclick: () => {
|
||||||
if(this.fieldname) {
|
if(this.fieldname) {
|
||||||
|
|||||||
Reference in New Issue
Block a user