fix: code formatting

This commit is contained in:
prssanna 2020-04-26 12:37:40 +05:30
parent de8f7faa47
commit ec7fc7f345
6 changed files with 45 additions and 37 deletions

View file

@ -14,7 +14,7 @@ frappe.ui.form.on('Number Card', {
filters: {
'issingle': false
}
}
};
});
frm.set_value('filters_json', '[]');
frm.set_value('aggregate_function_based_on', '');

View file

@ -57,9 +57,10 @@ frappe.dashboard_utils = {
},
get_dashboard_settings() {
return frappe.db.get_list('Dashboard Settings',
{
filters: {name: frappe.session.user},
return frappe.db.get_list('Dashboard Settings', {
filters: {
name: frappe.session.user
},
fields: ['*']
}).then(settings => {
if (!settings.length) {
@ -75,7 +76,9 @@ frappe.dashboard_utils = {
create_dashboard_settings() {
return frappe.xcall(
'frappe.desk.doctype.dashboard_settings.dashboard_settings.create_dashboard_settings',
{user: frappe.session.user}
{
user: frappe.session.user
}
).then(settings => {
return settings;
});

View file

@ -96,7 +96,6 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
});
this.render_dashboard_charts();
});
this.render_number_cards();
if (!this.charts.length && !this.number_cards.length) {
@ -173,7 +172,6 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
</div>`;
this.$dashboard_wrapper.append(empty_state_html);
this.$empty_state = this.$dashboard_wrapper.find('.empty-dashboard');
}
@ -182,7 +180,6 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
return;
}
if (this.$empty_state) {
this.$empty_state.remove();
}
@ -228,7 +225,8 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
this.dashboard_settings = null;
frappe.model.user_settings.save(
this.doctype, 'dashboard_settings', this.dashboard_settings
).then(()=> this.make_dashboard());
).then(() => this.make_dashboard());
this.toggle_customize(false);
}
@ -435,16 +433,17 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView {
group_by_fields.push({label: df.label, value: df.fieldname});
}
});
return {
date_fields: date_fields,
value_fields: value_fields,
group_by_fields: group_by_fields,
aggregate_function_fields: aggregate_function_fields
}
};
}
remove_duplicates(items) {
return items.filter((item, index) => items.indexOf(item) === index);
}
}
};

View file

@ -113,7 +113,8 @@ export default class Widget {
let remove_widget = () => {
this.widget.remove();
this.options.on_delete && this.options.on_delete(this.name);
}
};
if (animate) {
this.widget.addClass("zoomOutDelete");
// wait for animation

View file

@ -19,7 +19,7 @@ export default class NumberCardWidget extends Widget {
this.set_body();
}
set_body() {
set_body() {
this.widget.addClass("number-widget-box");
this.make_card();
}
@ -29,7 +29,7 @@ export default class NumberCardWidget extends Widget {
}
make_card() {
frappe.model.with_doc("Number Card", this.name).then(card => {
frappe.model.with_doc('Number Card', this.name).then(card => {
if (!card) {
if (this.document_type) {
this.create_number_card();
@ -52,7 +52,9 @@ export default class NumberCardWidget extends Widget {
this.set_doc_args();
frappe.xcall(
'frappe.desk.doctype.number_card.number_card.create_number_card',
{'args': this.card_doc}
{
'args': this.card_doc
}
).then(doc => {
this.name = doc.name;
this.widget.attr('data-widget-name', this.name);
@ -96,7 +98,9 @@ export default class NumberCardWidget extends Widget {
}
get_number() {
return frappe.xcall('frappe.desk.doctype.number_card.number_card.get_result', {doc: this.card_doc}).then(res => {
return frappe.xcall('frappe.desk.doctype.number_card.number_card.get_result', {
doc: this.card_doc
}).then(res => {
this.number = res;
if (this.card_doc.function !== 'Count') {
return frappe.model.with_doctype(this.card_doc.document_type, () => {
@ -148,43 +152,43 @@ export default class NumberCardWidget extends Widget {
$(this.body).find('.widget-content').append(`<div class="card-stats ${color_class}">
${caret_html}
<span class="percentage-stat">${Math.abs(this.percentage_stat)} %</span>
</div>`)
</div>`);
});
}
get_percentage_stats() {
return frappe.xcall('frappe.desk.doctype.number_card.number_card.get_percentage_difference',
{
doc: this.card_doc,
result: this.number
}).then(res => {
if (res !== undefined) {
this.percentage_stat = +res.toFixed(2);
}
return frappe.xcall('frappe.desk.doctype.number_card.number_card.get_percentage_difference', {
doc: this.card_doc,
result: this.number
}).then(res => {
if (res !== undefined) {
this.percentage_stat = +res.toFixed(2);
}
});
}
prepare_actions() {
let actions = [
{
label: __("Refresh"),
action: "action-refresh",
label: __('Refresh'),
action: 'action-refresh',
handler: () => {
this.render_card();
}
},
{
label: __("Edit"),
action: "action-edit",
label: __('Edit'),
action: 'action-edit',
handler: () => {
frappe.set_route(
"Form",
"Number Card",
'Form',
'Number Card',
this.name
);
}
},
];
this.set_card_actions(actions);
}
@ -196,11 +200,11 @@ export default class NumberCardWidget extends Widget {
<ul class="dropdown-menu" style="max-height: 300px; overflow-y: auto;">
${actions.map(
action =>
`<li><a data-action="${action.action}">${
action.label
}</a></li>`
`<li>
<a data-action="${action.action}">${action.label}</a>
</li>`
)
.join("")}
.join('')}
</ul>
</div>
`);
@ -209,6 +213,7 @@ export default class NumberCardWidget extends Widget {
const action = o.dataset.action;
$(o).click(actions.find(a => a.action === action));
});
this.action_area.html(this.card_actions);
}
}

View file

@ -124,9 +124,9 @@ function go_to_list_with_filters(doctype, filters) {
}
function shorten_number(number) {
let x = Math.abs(Math.round(number))
let x = Math.abs(Math.round(number));
switch(true) {
switch (true) {
case x >= 1.0e+12:
return Math.round(number/1.0e+12) + " T";
case x >= 1.0e+9: