Merge pull request #12398 from prssanna/rating-fix

This commit is contained in:
Prssanna Desai 2021-02-15 17:55:46 +05:30 committed by GitHub
commit 4efe2291c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -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');

View file

@ -61,11 +61,14 @@ frappe.form.formatters = {
return frappe.form.formatters._right(flt(value, precision) + "%", options);
},
Rating: function(value) {
return `<span class="rating">
${Array.from(new Array(5)).map((_, i) =>
`<i class="fa fa-fw fa-star ${i < (value || 0) ? "star-click": "" } star-icon" data-idx="${(i+1)}"></i>`
).join('')}
</span>`;
const rating_html = `${[1, 2, 3, 4, 5].map(i =>
`<svg class="icon icon-md ${i <= (value || 0) ? "star-click": "" }" data-idx="${i}">
<use href="#icon-star"></use>
</svg>`
).join('')}`;
return `<div class="rating">
${rating_html}
</div>`;
},
Currency: function (value, docfield, options, doc) {
var currency = frappe.meta.get_field_currency(docfield, doc);