fix: Rating field value is faulty in list view (#17672)

This commit is contained in:
Shariq Ansari 2022-07-29 20:52:45 +05:30 committed by GitHub
parent 88ad1c9458
commit 1b9aef4034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View file

@ -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) {

View file

@ -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 += `<svg class="icon icon-md" data-rating=${i} viewBox="0 0 24 24" fill="none">
<path class="right-half ${i <= (value || 0) ? "star-click": "" }" d="M11.9987 3.00011C12.177 3.00011 12.3554 3.09303 12.4471 3.27888L14.8213 8.09112C14.8941 8.23872 15.0349 8.34102 15.1978 8.3647L20.5069 9.13641C20.917 9.19602 21.0807 9.69992 20.7841 9.9892L16.9421 13.7354C16.8243 13.8503 16.7706 14.0157 16.7984 14.1779L17.7053 19.4674C17.7753 19.8759 17.3466 20.1874 16.9798 19.9945L12.2314 17.4973C12.1586 17.459 12.0786 17.4398 11.9987 17.4398V3.00011Z" fill="var(--star-fill)" stroke="var(--star-fill)"/>