From 0b4e5a36a71fe563290f2dd8a11132f55441d237 Mon Sep 17 00:00:00 2001 From: prssanna Date: Mon, 15 Feb 2021 14:37:08 +0530 Subject: [PATCH 1/2] fix: rating field fixes - fix rating formatter - fix setting of input --- frappe/public/js/frappe/form/controls/rating.js | 2 +- frappe/public/js/frappe/form/formatters.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/rating.js b/frappe/public/js/frappe/form/controls/rating.js index 351c4f7122..8117bf24bf 100644 --- a/frappe/public/js/frappe/form/controls/rating.js +++ b/frappe/public/js/frappe/form/controls/rating.js @@ -52,7 +52,7 @@ frappe.ui.form.ControlRating = frappe.ui.form.ControlInt.extend({ return cint(this.value, null); }, set_formatted_input(value) { - let el = $(this.input_area).find('i'); + let el = $(this.input_area).find('svg'); el.children('svg').prevObject.each( function(e) { if (e < value) { $(this).addClass('star-click'); diff --git a/frappe/public/js/frappe/form/formatters.js b/frappe/public/js/frappe/form/formatters.js index 30ed7f15e4..6beb369922 100644 --- a/frappe/public/js/frappe/form/formatters.js +++ b/frappe/public/js/frappe/form/formatters.js @@ -61,12 +61,14 @@ frappe.form.formatters = { return frappe.form.formatters._right(flt(value, precision) + "%", options); }, Rating: function(value) { - return ` - ${Array.from(new Array(5)).map((_, i) => - `` - ).join('')} - `; - }, + return `
+ ${[1, 2, 3, 4, 5].map(i => + ` + + ` + ).join('')} +
`; + }, Currency: function (value, docfield, options, doc) { var currency = frappe.meta.get_field_currency(docfield, doc); var precision = docfield.precision || cint(frappe.boot.sysdefaults.currency_precision) || 2; From e0ec834c58899f600cbaf5875533a54c4dd38487 Mon Sep 17 00:00:00 2001 From: prssanna Date: Mon, 15 Feb 2021 14:52:03 +0530 Subject: [PATCH 2/2] style: fix formatting --- frappe/public/js/frappe/form/formatters.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frappe/public/js/frappe/form/formatters.js b/frappe/public/js/frappe/form/formatters.js index 6beb369922..5386f97528 100644 --- a/frappe/public/js/frappe/form/formatters.js +++ b/frappe/public/js/frappe/form/formatters.js @@ -61,14 +61,15 @@ frappe.form.formatters = { return frappe.form.formatters._right(flt(value, precision) + "%", options); }, Rating: function(value) { + const rating_html = `${[1, 2, 3, 4, 5].map(i => + ` + + ` + ).join('')}`; return `
- ${[1, 2, 3, 4, 5].map(i => - ` - - ` - ).join('')} + ${rating_html}
`; - }, + }, Currency: function (value, docfield, options, doc) { var currency = frappe.meta.get_field_currency(docfield, doc); var precision = docfield.precision || cint(frappe.boot.sysdefaults.currency_precision) || 2;