Merge pull request #8497 from thefalconx33/internal-issues
fix: Incorrect currency value while pasting from excel to grid and other UX issues
This commit is contained in:
commit
775503cfd8
3 changed files with 30 additions and 1 deletions
|
|
@ -1,4 +1,15 @@
|
|||
frappe.ui.form.ControlCurrency = frappe.ui.form.ControlFloat.extend({
|
||||
eval_expression: function(value) {
|
||||
if (typeof value === 'string'
|
||||
&& value.match(/^[0-9+-/* ]+$/)
|
||||
// paresFloat('1,44,000') returns 1.0
|
||||
// 1,44,000 are being passed when we paste rows from excel sheet to a table
|
||||
&& value.includes(',')) {
|
||||
return value.replace(",", "");
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
format_for_input: function(value) {
|
||||
var formatted_value = format_number(parseFloat(value), this.get_number_format(), this.get_precision());
|
||||
return isNaN(parseFloat(value)) ? "" : formatted_value;
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({
|
|||
if(!me.$input.is(":focus")) {
|
||||
return;
|
||||
}
|
||||
r.results = me.merge_duplicates(r.results);
|
||||
|
||||
// show filter description in awesomplete
|
||||
if (args.filters) {
|
||||
|
|
@ -276,6 +277,23 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({
|
|||
});
|
||||
},
|
||||
|
||||
merge_duplicates(results) {
|
||||
// in case of result like this
|
||||
// [{value: 'Manufacturer 1', 'description': 'mobile part 1'},
|
||||
// {value: 'Manufacturer 1', 'description': 'mobile part 2'}]
|
||||
// suggestion list has two items with same value (docname) & description
|
||||
return results.reduce((newArr, currElem) => {
|
||||
if (newArr.length === 0) return [currElem];
|
||||
let element_with_same_value = newArr.find(e => e.value === currElem.value);
|
||||
if (element_with_same_value) {
|
||||
element_with_same_value.description += `, ${currElem.description}`;
|
||||
return [...newArr];
|
||||
}
|
||||
return [...newArr, currElem];
|
||||
}, []);
|
||||
// returns [{value: 'Manufacturer 1', 'description': 'mobile part 1, mobile part 2'}]
|
||||
},
|
||||
|
||||
get_filter_description(filters) {
|
||||
let doctype = this.get_options();
|
||||
let filter_array = [];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<h1 class="flex" style="margin: auto;">
|
||||
<div class="title-image hide hidden-md hidden-lg">
|
||||
</div>
|
||||
<div class="flex fill-width title-area">
|
||||
<div class="flex fill-width title-area" style="max-width: 100%">
|
||||
<div class="ellipsis title-text"></div>
|
||||
<span class="indicator whitespace-nowrap hide"></span>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue