mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Prettify negative numbers in reviewable score explanation (#23642)
This is an aesthetic change. Currently, if one of the scores involved in the reviewable score explanation is negative, we display it as: + -value. This changes that. I also made an attempt at converting the component into GJS format. This is done as a separate commit.
This commit is contained in:
parent
efce57e23d
commit
c42257b47d
@ -14,26 +14,19 @@
|
|||||||
{{#each this.reviewableExplanation.scores as |s|}}
|
{{#each this.reviewableExplanation.scores as |s|}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<ScoreValue @value="1.0" @tagName="" />
|
<ScoreValue @value="1.0" />
|
||||||
<ScoreValue
|
<ScoreValue @value={{s.type_bonus}} @label="type_bonus" />
|
||||||
@value={{s.type_bonus}}
|
|
||||||
@label="type_bonus"
|
|
||||||
@tagName=""
|
|
||||||
/>
|
|
||||||
<ScoreValue
|
<ScoreValue
|
||||||
@value={{s.take_action_bonus}}
|
@value={{s.take_action_bonus}}
|
||||||
@label="take_action_bonus"
|
@label="take_action_bonus"
|
||||||
@tagName=""
|
|
||||||
/>
|
/>
|
||||||
<ScoreValue
|
<ScoreValue
|
||||||
@value={{s.trust_level_bonus}}
|
@value={{s.trust_level_bonus}}
|
||||||
@label="trust_level_bonus"
|
@label="trust_level_bonus"
|
||||||
@tagName=""
|
|
||||||
/>
|
/>
|
||||||
<ScoreValue
|
<ScoreValue
|
||||||
@value={{s.user_accuracy_bonus}}
|
@value={{s.user_accuracy_bonus}}
|
||||||
@label="user_accuracy_bonus"
|
@label="user_accuracy_bonus"
|
||||||
@tagName=""
|
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td class="sum">{{float s.score}}</td>
|
<td class="sum">{{float s.score}}</td>
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
import Component from "@glimmer/component";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
export default class ScoreValue extends Component {
|
||||||
|
<template>
|
||||||
|
{{#if @value}}
|
||||||
|
<span class="op">{{if this.isNegative "-" "+"}}</span>
|
||||||
|
<span class="score-value">
|
||||||
|
<span class="score-number">{{this.numericValue}}</span>
|
||||||
|
{{#if @label}}
|
||||||
|
<span title={{this.explanationTitle}} class="score-value-type">
|
||||||
|
{{this.explanationContent}}
|
||||||
|
</span>
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
{{/if}}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
get numericValue() {
|
||||||
|
return parseFloat(Math.abs(this.args.value)).toFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
get isNegative() {
|
||||||
|
return this.args.value < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
get explanationTitle() {
|
||||||
|
return I18n.t(`review.explain.${this.args.label}.title`);
|
||||||
|
}
|
||||||
|
|
||||||
|
get explanationContent() {
|
||||||
|
return I18n.t(`review.explain.${this.args.label}.name`);
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +0,0 @@
|
|||||||
{{#if this.value}}
|
|
||||||
<span class="score-value">
|
|
||||||
<span class="score-number">{{float this.value}}</span>
|
|
||||||
{{#if this.label}}
|
|
||||||
<span
|
|
||||||
title={{i18n (concat "review.explain." this.label ".title")}}
|
|
||||||
class="score-value-type"
|
|
||||||
>
|
|
||||||
{{i18n (concat "review.explain." this.label ".name")}}
|
|
||||||
</span>
|
|
||||||
{{/if}}
|
|
||||||
</span>
|
|
||||||
<span class="op">+</span>
|
|
||||||
{{/if}}
|
|
@ -1,3 +0,0 @@
|
|||||||
import Component from "@ember/component";
|
|
||||||
|
|
||||||
export default Component.extend({});
|
|
@ -31,7 +31,7 @@
|
|||||||
color: var(--primary-medium);
|
color: var(--primary-medium);
|
||||||
}
|
}
|
||||||
|
|
||||||
.op:last-of-type {
|
.op:first-of-type {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user