From 1b9aef40348eb0cd329f1fa80f9f66d80698c111 Mon Sep 17 00:00:00 2001 From: Shariq Ansari <30859809+shariquerik@users.noreply.github.com> Date: Fri, 29 Jul 2022 20:52:45 +0530 Subject: [PATCH] fix: Rating field value is faulty in list view (#17672) --- frappe/public/js/frappe/form/controls/rating.js | 1 + frappe/public/js/frappe/form/formatters.js | 1 + 2 files changed, 2 insertions(+) diff --git a/frappe/public/js/frappe/form/controls/rating.js b/frappe/public/js/frappe/form/controls/rating.js index 981168457a..2bdfcb7d45 100644 --- a/frappe/public/js/frappe/form/controls/rating.js +++ b/frappe/public/js/frappe/form/controls/rating.js @@ -72,6 +72,7 @@ frappe.ui.form.ControlRating = class ControlRating extends frappe.ui.form.Contro set_formatted_input(value) { let out_of_ratings = this.df.options || 5; value = value * out_of_ratings; + value = Math.round(value * 2) / 2; // roundoff number to nearest 0.5 let el = $(this.input_area).find('svg'); el.children('svg').prevObject.each( function(e) { if (e < value) { diff --git a/frappe/public/js/frappe/form/formatters.js b/frappe/public/js/frappe/form/formatters.js index 5a15b4fd45..22225f5501 100644 --- a/frappe/public/js/frappe/form/formatters.js +++ b/frappe/public/js/frappe/form/formatters.js @@ -88,6 +88,7 @@ frappe.form.formatters = { let rating_html = ''; let number_of_stars = docfield.options || 5; value = value * number_of_stars; + value = Math.round(value * 2) / 2; // roundoff number to nearest 0.5 Array.from({length: cint(number_of_stars)}, (_, i) => i + 1).forEach(i => { rating_html += `