Merge branch 'rebrand-ui' of https://github.com/frappe/frappe into rebrand-ui
This commit is contained in:
commit
76f67fbb3a
4 changed files with 29 additions and 75 deletions
|
|
@ -204,7 +204,6 @@
|
|||
"public/js/frappe/views/translation_manager.js",
|
||||
"public/js/frappe/views/workspace/workspace.js",
|
||||
|
||||
"public/js/frappe/widgets/utils.js",
|
||||
"public/js/frappe/widgets/widget_group.js",
|
||||
|
||||
"public/js/frappe/ui/sort_selector.html",
|
||||
|
|
|
|||
|
|
@ -43,12 +43,16 @@ frappe.ui.FilterGroup = class {
|
|||
set_popover_events() {
|
||||
$(document.body).on('click', (e) => {
|
||||
if (this.wrapper && this.wrapper.is(':visible')) {
|
||||
const in_datepicker = $(e.target).is('.datepicker--cell')
|
||||
|| $(e.target).is('.datepicker--nav-title')
|
||||
|| $(e.target).parents('.datepicker--nav-action').length !== 0;
|
||||
|
||||
if (
|
||||
$(e.target).parents('.filter-popover').length === 0
|
||||
&& $(e.target).parents('.filter-box').length === 0
|
||||
&& this.filter_button.find($(e.target)).length === 0
|
||||
&& !$(e.target).is(this.filter_button)
|
||||
&& !$(e.target).is('.datepicker--cell')
|
||||
&& !in_datepicker
|
||||
) {
|
||||
this.wrapper && this.filter_button.popover('hide');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1193,5 +1193,29 @@ Object.assign(frappe.utils, {
|
|||
// item.shown = true;
|
||||
// }
|
||||
return `/app/${route}`;
|
||||
},
|
||||
|
||||
build_summary_item(summary) {
|
||||
if (summary.type == "separator") {
|
||||
return $(`<div class="summary-separator">
|
||||
<div class="summary-value ${summary.color ? summary.color.toLowerCase() : 'text-muted'}">${summary.value}</div>
|
||||
</div>`);
|
||||
}
|
||||
let df = { fieldtype: summary.datatype };
|
||||
let doc = null;
|
||||
|
||||
if (summary.datatype == "Currency") {
|
||||
df.options = "currency";
|
||||
doc = { currency: summary.currency };
|
||||
}
|
||||
|
||||
let value = frappe.format(summary.value, df, { only_value: true }, doc);
|
||||
let color = summary.indicator ? summary.indicator.toLowerCase()
|
||||
: summary.color ? summary.color.toLowerCase() : '';
|
||||
|
||||
return $(`<div class="summary-item">
|
||||
<span class="summary-label">${summary.label}</span>
|
||||
<div class="summary-value ${color}">${value}</div>
|
||||
</div>`);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
frappe.provide('frappe.utils');
|
||||
|
||||
Object.assign(frappe.utils, {
|
||||
build_summary_item(summary) {
|
||||
if (summary.type == "separator") {
|
||||
return $(`<div class="summary-separator">
|
||||
<div class="summary-value ${summary.color ? summary.color.toLowerCase() : 'text-muted'}">${summary.value}</div>
|
||||
</div>`);
|
||||
}
|
||||
let df = { fieldtype: summary.datatype };
|
||||
let doc = null;
|
||||
|
||||
if (summary.datatype == "Currency") {
|
||||
df.options = "currency";
|
||||
doc = { currency: summary.currency };
|
||||
}
|
||||
|
||||
let value = frappe.format(summary.value, df, { only_value: true }, doc);
|
||||
let color = summary.indicator ? summary.indicator.toLowerCase()
|
||||
: summary.color ? summary.color.toLowerCase() : '';
|
||||
|
||||
return $(`<div class="summary-item">
|
||||
<span class="summary-label">${summary.label}</span>
|
||||
<div class="summary-value ${color}">${value}</div>
|
||||
</div>`);
|
||||
},
|
||||
|
||||
shorten_number(number, country) {
|
||||
country = (country == 'India') ? country : '';
|
||||
const number_system = get_number_system(country);
|
||||
let x = Math.abs(Math.round(number));
|
||||
for (const map of number_system) {
|
||||
const condition = map.condition ? map.condition(x) : x >= map.divisor;
|
||||
if (condition) {
|
||||
return (number / map.divisor).toFixed(2) + ' ' + map.symbol;
|
||||
}
|
||||
}
|
||||
return number.toFixed(2);
|
||||
},
|
||||
|
||||
get_number_system(country) {
|
||||
let number_system_map = {
|
||||
'India':
|
||||
[{
|
||||
divisor: 1.0e+7,
|
||||
symbol: 'Cr'
|
||||
},
|
||||
{
|
||||
divisor: 1.0e+5,
|
||||
symbol: 'Lakh'
|
||||
}],
|
||||
'':
|
||||
[{
|
||||
divisor: 1.0e+12,
|
||||
symbol: 'T'
|
||||
},
|
||||
{
|
||||
divisor: 1.0e+9,
|
||||
symbol: 'B'
|
||||
},
|
||||
{
|
||||
divisor: 1.0e+6,
|
||||
symbol: 'M'
|
||||
},
|
||||
{
|
||||
divisor: 1.0e+3,
|
||||
symbol: 'K',
|
||||
condition: (num) => num.toFixed().length > 5
|
||||
}]
|
||||
};
|
||||
return number_system_map[country];
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue