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,13 +1,14 @@
import onScan from 'onscan.js';
erpnext.PointOfSale.ItemSelector = class {
// eslint-disable-next-line no-unused-vars
constructor({ frm, wrapper, events, pos_profile, settings }) {
this.wrapper = wrapper;
this.events = events;
this.pos_profile = pos_profile;
this.hide_images = settings.hide_images;
this.auto_add_item = settings.auto_add_item_to_cart;
this.inti_component();
}
@ -39,7 +40,7 @@ erpnext.PointOfSale.ItemSelector = class {
if (!this.item_group) {
const res = await frappe.db.get_value("Item Group", {lft: 1, is_group: 1}, "name");
this.parent_item_group = res.message.name;
};
}
if (!this.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;
@ -71,11 +72,12 @@ erpnext.PointOfSale.ItemSelector = class {
items.forEach(item => {
const item_html = this.get_item_html(item);
this.$items_container.append(item_html);
})
});
}
get_item_html(item) {
const me = this;
// eslint-disable-next-line no-unused-vars
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";
@ -83,7 +85,7 @@ erpnext.PointOfSale.ItemSelector = class {
if (!me.hide_images && item_image) {
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;">
</div>`
</div>`;
} else {
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>
</div>`
)
);
}
make_search_bar() {
@ -140,7 +142,7 @@ erpnext.PointOfSale.ItemSelector = class {
filters: {
pos_profile: doc ? doc.pos_profile : ''
}
}
};
},
},
parent: this.$component.find('.item-group-field'),
@ -176,7 +178,7 @@ erpnext.PointOfSale.ItemSelector = class {
uom = uom === "undefined" ? undefined : uom;
me.events.item_selected({ field: 'qty', value: "+1", item: { item_code, batch_no, serial_no, uom }});
})
});
this.search_field.$input.on('input', (e) => {
clearTimeout(this.last_search);
@ -247,6 +249,7 @@ erpnext.PointOfSale.ItemSelector = class {
this.get_items({ search_value: search_term })
.then(({ message }) => {
// eslint-disable-next-line no-unused-vars
const { items, serial_no, batch_no, barcode } = message;
if (search_term && !barcode) {
this.search_index[search_term] = items;
@ -260,26 +263,26 @@ erpnext.PointOfSale.ItemSelector = class {
add_filtered_item_to_cart() {
this.$items_container.find(".item-wrapper").click();
}
resize_selector(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(12, 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))');
minimize ?
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', 'var(--margin-sm) 0px') :
this.$component.find('.search-field').css('margin', '0px var(--margin-sm)');
minimize ?
this.$component.css('grid-column', 'span 2 / span 2') :
this.$component.css('grid-column', 'span 6 / span 6')
this.$component.css('grid-column', 'span 2 / span 2') :
this.$component.css('grid-column', 'span 6 / span 6');
minimize ?
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(1, minmax(0, 1fr))') :
this.$items_container.css('grid-template-columns', 'repeat(4, minmax(0, 1fr))');
}
toggle_component(show) {
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({
title: 'Email Receipt',
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)'}
],
primary_action: () => {
@ -61,7 +61,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
const print_dialog = new frappe.ui.Dialog({
title: 'Print Receipt',
fields: [
{fieldname:'print', fieldtype:'Data', label:'Print Preview'}
{fieldname: 'print', fieldtype: 'Data', label: 'Print Preview'}
],
primary_action: () => {
const frm = this.events.get_frm();
@ -132,18 +132,17 @@ erpnext.PointOfSale.PastOrderSummary = class {
get_taxes_html(doc) {
if (!doc.taxes.length) return '';
return `
<div class="taxes-wrapper">
${
doc.taxes.map((t, i) => {
const description = /[0-9]+/.test(t.description) ? t.description : `${t.description} @ ${t.rate}%`;
return `<div class="tax-row">
<div class="tax-label">${description}</div>
<div class="tax-value">${format_currency(t.tax_amount_after_discount_amount, doc.currency)}</div>
</div>`
}).join('')
}
</div>`;
let taxes_html = doc.taxes.map(t => {
const description = /[0-9]+/.test(t.description) ? t.description : `${t.description} @ ${t.rate}%`;
return `
<div class="tax-row">
<div class="tax-label">${description}</div>
<div class="tax-value">${format_currency(t.tax_amount_after_discount_amount, doc.currency)}</div>
</div>
`;
}).join('');
return `<div class="taxes-wrapper">${taxes_html}</div>`;
}
get_grand_total_html(doc) {
@ -178,9 +177,6 @@ erpnext.PointOfSale.PastOrderSummary = class {
this.$summary_container.on('click', '.delete-btn', () => {
this.events.delete_order(this.doc.name);
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', () => {
@ -237,7 +233,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
const print_format = frm.pos_print_format;
frappe.call({
method:"frappe.core.doctype.communication.email.make",
method: "frappe.core.doctype.communication.email.make",
args: {
recipients: recipients,
subject: __(frm.meta.name) + ': ' + doc.name,
@ -246,14 +242,14 @@ erpnext.PointOfSale.PastOrderSummary = class {
send_email: 1,
print_format,
sender_full_name: frappe.user.full_name(),
_lang : doc.language
_lang: doc.language
},
callback: r => {
if(!r.exc) {
if (!r.exc) {
frappe.utils.play_sound("email");
if(r.message["emails_not_sent_to"]) {
if (r.message["emails_not_sent_to"]) {
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"]) ]
));
} else {
@ -309,10 +305,10 @@ erpnext.PointOfSale.PastOrderSummary = class {
load_summary_of(doc, after_submission=false) {
after_submission ?
this.$component.css('grid-column', 'span 10 / span 10') :
this.$component.css('grid-column', 'span 6 / span 6')
this.toggle_summary_placeholder(false)
this.$component.css('grid-column', 'span 6 / span 6');
this.toggle_summary_placeholder(false);
this.doc = doc;
this.attach_document_info(doc);
@ -338,7 +334,7 @@ erpnext.PointOfSale.PastOrderSummary = class {
attach_items_info(doc) {
this.$items_container.html('');
doc.items.forEach((item, i) => {
doc.items.forEach(item => {
const item_dom = this.get_item_html(doc, item);
this.$items_container.append(item_dom);
this.set_dynamic_rate_header_width();