chore: Fix formatting issues

This commit is contained in:
Suraj Shetty 2021-02-01 19:40:44 +05:30
parent 13d48a0c20
commit f67bf7ae98
2 changed files with 43 additions and 44 deletions

View File

@ -1,6 +1,7 @@
import onScan from 'onscan.js'; import onScan from 'onscan.js';
erpnext.PointOfSale.ItemSelector = class { erpnext.PointOfSale.ItemSelector = class {
// eslint-disable-next-line no-unused-vars
constructor({ frm, wrapper, events, pos_profile, settings }) { constructor({ frm, wrapper, events, pos_profile, settings }) {
this.wrapper = wrapper; this.wrapper = wrapper;
this.events = events; this.events = events;
@ -39,7 +40,7 @@ erpnext.PointOfSale.ItemSelector = class {
if (!this.item_group) { if (!this.item_group) {
const res = await frappe.db.get_value("Item Group", {lft: 1, is_group: 1}, "name"); const res = await frappe.db.get_value("Item Group", {lft: 1, is_group: 1}, "name");
this.parent_item_group = res.message.name; this.parent_item_group = res.message.name;
}; }
if (!this.price_list) { if (!this.price_list) {
const res = await frappe.db.get_value("POS Profile", this.pos_profile, "selling_price_list"); const res = await frappe.db.get_value("POS Profile", this.pos_profile, "selling_price_list");
this.price_list = res.message.selling_price_list; this.price_list = res.message.selling_price_list;
@ -71,11 +72,12 @@ erpnext.PointOfSale.ItemSelector = class {
items.forEach(item => { items.forEach(item => {
const item_html = this.get_item_html(item); const item_html = this.get_item_html(item);
this.$items_container.append(item_html); this.$items_container.append(item_html);
}) });
} }
get_item_html(item) { get_item_html(item) {
const me = this; const me = this;
// eslint-disable-next-line no-unused-vars
const { item_image, serial_no, batch_no, barcode, actual_qty, stock_uom } = item; const { item_image, serial_no, batch_no, barcode, actual_qty, stock_uom } = item;
const indicator_color = actual_qty > 10 ? "green" : actual_qty <= 0 ? "red" : "orange"; const indicator_color = actual_qty > 10 ? "green" : actual_qty <= 0 ? "red" : "orange";
@ -83,7 +85,7 @@ erpnext.PointOfSale.ItemSelector = class {
if (!me.hide_images && item_image) { if (!me.hide_images && item_image) {
return `<div class="flex items-center justify-center h-32 border-b-grey text-6xl text-grey-100"> return `<div class="flex items-center justify-center h-32 border-b-grey text-6xl text-grey-100">
<img class="h-full" src="${item_image}" alt="${frappe.get_abbr(item.item_name)}" style="object-fit: cover;"> <img class="h-full" src="${item_image}" alt="${frappe.get_abbr(item.item_name)}" style="object-fit: cover;">
</div>` </div>`;
} else { } else {
return `<div class="item-display abbr">${frappe.get_abbr(item.item_name)}</div>`; return `<div class="item-display abbr">${frappe.get_abbr(item.item_name)}</div>`;
} }
@ -105,7 +107,7 @@ erpnext.PointOfSale.ItemSelector = class {
<div class="item-rate">${format_currency(item.price_list_rate, item.currency, 0) || 0}</div> <div class="item-rate">${format_currency(item.price_list_rate, item.currency, 0) || 0}</div>
</div> </div>
</div>` </div>`
) );
} }
make_search_bar() { make_search_bar() {
@ -140,7 +142,7 @@ erpnext.PointOfSale.ItemSelector = class {
filters: { filters: {
pos_profile: doc ? doc.pos_profile : '' pos_profile: doc ? doc.pos_profile : ''
} }
} };
}, },
}, },
parent: this.$component.find('.item-group-field'), parent: this.$component.find('.item-group-field'),
@ -176,7 +178,7 @@ erpnext.PointOfSale.ItemSelector = class {
uom = uom === "undefined" ? undefined : uom; uom = uom === "undefined" ? undefined : uom;
me.events.item_selected({ field: 'qty', value: "+1", item: { item_code, batch_no, serial_no, uom }}); me.events.item_selected({ field: 'qty', value: "+1", item: { item_code, batch_no, serial_no, uom }});
}) });
this.search_field.$input.on('input', (e) => { this.search_field.$input.on('input', (e) => {
clearTimeout(this.last_search); clearTimeout(this.last_search);
@ -247,6 +249,7 @@ erpnext.PointOfSale.ItemSelector = class {
this.get_items({ search_value: search_term }) this.get_items({ search_value: search_term })
.then(({ message }) => { .then(({ message }) => {
// eslint-disable-next-line no-unused-vars
const { items, serial_no, batch_no, barcode } = message; const { items, serial_no, batch_no, barcode } = message;
if (search_term && !barcode) { if (search_term && !barcode) {
this.search_index[search_term] = items; this.search_index[search_term] = items;
@ -263,23 +266,23 @@ erpnext.PointOfSale.ItemSelector = class {
resize_selector(minimize) { resize_selector(minimize) {
minimize ? minimize ?
this.$component.find('.filter-section').css('grid-template-columns', 'repeat(1, minmax(0, 1fr))') : this.$component.find('.filter-section').css('grid-template-columns', 'repeat(1, minmax(0, 1fr))') :
this.$component.find('.filter-section').css('grid-template-columns', 'repeat(12, minmax(0, 1fr))'); this.$component.find('.filter-section').css('grid-template-columns', 'repeat(12, minmax(0, 1fr))');
minimize ? minimize ?
this.$component.find('.search-field').css('margin', 'var(--margin-sm) 0px') : this.$component.find('.search-field').css('margin', 'var(--margin-sm) 0px') :
this.$component.find('.search-field').css('margin', '0px var(--margin-sm)'); this.$component.find('.search-field').css('margin', '0px var(--margin-sm)');
minimize ? minimize ?
this.$component.css('grid-column', 'span 2 / span 2') : this.$component.css('grid-column', 'span 2 / span 2') :
this.$component.css('grid-column', 'span 6 / span 6') this.$component.css('grid-column', 'span 6 / span 6');
minimize ? minimize ?
this.$items_container.css('grid-template-columns', 'repeat(1, minmax(0, 1fr))') : this.$items_container.css('grid-template-columns', 'repeat(1, minmax(0, 1fr))') :
this.$items_container.css('grid-template-columns', 'repeat(4, minmax(0, 1fr))') this.$items_container.css('grid-template-columns', 'repeat(4, minmax(0, 1fr))');
} }
toggle_component(show) { toggle_component(show) {
show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none'); show ? this.$component.css('display', 'flex') : this.$component.css('display', 'none');
} }
} };

View File

@ -48,7 +48,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
const email_dialog = new frappe.ui.Dialog({ const email_dialog = new frappe.ui.Dialog({
title: 'Email Receipt', title: 'Email Receipt',
fields: [ fields: [
{fieldname:'email_id', fieldtype:'Data', options: 'Email', label:'Email ID'}, {fieldname: 'email_id', fieldtype: 'Data', options: 'Email', label: 'Email ID'},
// {fieldname:'remarks', fieldtype:'Text', label:'Remarks (if any)'} // {fieldname:'remarks', fieldtype:'Text', label:'Remarks (if any)'}
], ],
primary_action: () => { primary_action: () => {
@ -61,7 +61,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
const print_dialog = new frappe.ui.Dialog({ const print_dialog = new frappe.ui.Dialog({
title: 'Print Receipt', title: 'Print Receipt',
fields: [ fields: [
{fieldname:'print', fieldtype:'Data', label:'Print Preview'} {fieldname: 'print', fieldtype: 'Data', label: 'Print Preview'}
], ],
primary_action: () => { primary_action: () => {
const frm = this.events.get_frm(); const frm = this.events.get_frm();
@ -132,18 +132,17 @@ erpnext.PointOfSale.PastOrderSummary = class {
get_taxes_html(doc) { get_taxes_html(doc) {
if (!doc.taxes.length) return ''; if (!doc.taxes.length) return '';
return ` let taxes_html = doc.taxes.map(t => {
<div class="taxes-wrapper"> const description = /[0-9]+/.test(t.description) ? t.description : `${t.description} @ ${t.rate}%`;
${ return `
doc.taxes.map((t, i) => { <div class="tax-row">
const description = /[0-9]+/.test(t.description) ? t.description : `${t.description} @ ${t.rate}%`; <div class="tax-label">${description}</div>
return `<div class="tax-row"> <div class="tax-value">${format_currency(t.tax_amount_after_discount_amount, doc.currency)}</div>
<div class="tax-label">${description}</div> </div>
<div class="tax-value">${format_currency(t.tax_amount_after_discount_amount, doc.currency)}</div> `;
</div>` }).join('');
}).join('')
} return `<div class="taxes-wrapper">${taxes_html}</div>`;
</div>`;
} }
get_grand_total_html(doc) { get_grand_total_html(doc) {
@ -178,9 +177,6 @@ erpnext.PointOfSale.PastOrderSummary = class {
this.$summary_container.on('click', '.delete-btn', () => { this.$summary_container.on('click', '.delete-btn', () => {
this.events.delete_order(this.doc.name); this.events.delete_order(this.doc.name);
this.show_summary_placeholder(); this.show_summary_placeholder();
// this.toggle_component(false);
// this.$component.find('.no-summary-placeholder').removeClass('d-none');
// this.$summary_wrapper.addClass('d-none');
}); });
this.$summary_container.on('click', '.new-btn', () => { this.$summary_container.on('click', '.new-btn', () => {
@ -237,7 +233,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
const print_format = frm.pos_print_format; const print_format = frm.pos_print_format;
frappe.call({ frappe.call({
method:"frappe.core.doctype.communication.email.make", method: "frappe.core.doctype.communication.email.make",
args: { args: {
recipients: recipients, recipients: recipients,
subject: __(frm.meta.name) + ': ' + doc.name, subject: __(frm.meta.name) + ': ' + doc.name,
@ -246,12 +242,12 @@ erpnext.PointOfSale.PastOrderSummary = class {
send_email: 1, send_email: 1,
print_format, print_format,
sender_full_name: frappe.user.full_name(), sender_full_name: frappe.user.full_name(),
_lang : doc.language _lang: doc.language
}, },
callback: r => { callback: r => {
if(!r.exc) { if (!r.exc) {
frappe.utils.play_sound("email"); frappe.utils.play_sound("email");
if(r.message["emails_not_sent_to"]) { if (r.message["emails_not_sent_to"]) {
frappe.msgprint(__( frappe.msgprint(__(
"Email not sent to {0} (unsubscribed / disabled)", "Email not sent to {0} (unsubscribed / disabled)",
[ frappe.utils.escape_html(r.message["emails_not_sent_to"]) ] [ frappe.utils.escape_html(r.message["emails_not_sent_to"]) ]
@ -309,9 +305,9 @@ erpnext.PointOfSale.PastOrderSummary = class {
load_summary_of(doc, after_submission=false) { load_summary_of(doc, after_submission=false) {
after_submission ? after_submission ?
this.$component.css('grid-column', 'span 10 / span 10') : this.$component.css('grid-column', 'span 10 / span 10') :
this.$component.css('grid-column', 'span 6 / span 6') this.$component.css('grid-column', 'span 6 / span 6');
this.toggle_summary_placeholder(false) this.toggle_summary_placeholder(false);
this.doc = doc; this.doc = doc;
@ -338,7 +334,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
attach_items_info(doc) { attach_items_info(doc) {
this.$items_container.html(''); this.$items_container.html('');
doc.items.forEach((item, i) => { doc.items.forEach(item => {
const item_dom = this.get_item_html(doc, item); const item_dom = this.get_item_html(doc, item);
this.$items_container.append(item_dom); this.$items_container.append(item_dom);
this.set_dynamic_rate_header_width(); this.set_dynamic_rate_header_width();