Merge branch 'rebrand-ui' of https://github.com/frappe/erpnext into rebrand-ui

This commit is contained in:
prssanna 2021-02-01 19:50:46 +05:30
commit ba54c4f1b3
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;
@ -272,14 +275,14 @@ erpnext.PointOfSale.ItemSelector = class {
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

@ -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">
${
doc.taxes.map((t, i) => {
const description = /[0-9]+/.test(t.description) ? t.description : `${t.description} @ ${t.rate}%`; const description = /[0-9]+/.test(t.description) ? t.description : `${t.description} @ ${t.rate}%`;
return `<div class="tax-row"> return `
<div class="tax-row">
<div class="tax-label">${description}</div> <div class="tax-label">${description}</div>
<div class="tax-value">${format_currency(t.tax_amount_after_discount_amount, doc.currency)}</div> <div class="tax-value">${format_currency(t.tax_amount_after_discount_amount, doc.currency)}</div>
</div>` </div>
}).join('') `;
} }).join('');
</div>`;
return `<div class="taxes-wrapper">${taxes_html}</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', () => {
@ -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();