Merge pull request #9477 from KDSBrowne/issue-9302
Localize default poll options before calculating annotation required space
This commit is contained in:
commit
21375864fe
@ -1,7 +1,8 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import PollService from '/imports/ui/components/poll/service';
|
import PollService from '/imports/ui/components/poll/service';
|
||||||
import { injectIntl } from 'react-intl';
|
import { injectIntl, intlShape } from 'react-intl';
|
||||||
|
import styles from './styles';
|
||||||
|
|
||||||
class PollDrawComponent extends Component {
|
class PollDrawComponent extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -96,6 +97,28 @@ class PollDrawComponent extends Component {
|
|||||||
for (let i = 0; i < arrayLength; i += 1) {
|
for (let i = 0; i < arrayLength; i += 1) {
|
||||||
const _tempArray = [];
|
const _tempArray = [];
|
||||||
const _result = result[i];
|
const _result = result[i];
|
||||||
|
let isDefaultPoll;
|
||||||
|
switch (_result.key.toLowerCase()) {
|
||||||
|
case 'true':
|
||||||
|
case 'false':
|
||||||
|
case 'yes':
|
||||||
|
case 'no':
|
||||||
|
case 'a':
|
||||||
|
case 'b':
|
||||||
|
case 'c':
|
||||||
|
case 'd':
|
||||||
|
case 'e':
|
||||||
|
isDefaultPoll = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
isDefaultPoll = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDefaultPoll) {
|
||||||
|
_result.key = intl.formatMessage({ id: `app.poll.answer.${_result.key.toLowerCase()}` });
|
||||||
|
}
|
||||||
|
|
||||||
_tempArray.push(_result.key, `${_result.numVotes}`);
|
_tempArray.push(_result.key, `${_result.numVotes}`);
|
||||||
if (votesTotal === 0) {
|
if (votesTotal === 0) {
|
||||||
_tempArray.push('0%');
|
_tempArray.push('0%');
|
||||||
@ -431,6 +454,7 @@ class PollDrawComponent extends Component {
|
|||||||
y={line.keyColumn.yLeft}
|
y={line.keyColumn.yLeft}
|
||||||
dy={maxLineHeight / 2}
|
dy={maxLineHeight / 2}
|
||||||
key={`${line.key}_key`}
|
key={`${line.key}_key`}
|
||||||
|
className={styles.outline}
|
||||||
>
|
>
|
||||||
{line.keyColumn.keyString}
|
{line.keyColumn.keyString}
|
||||||
</tspan>
|
</tspan>
|
||||||
@ -462,6 +486,7 @@ class PollDrawComponent extends Component {
|
|||||||
y={line.percentColumn.yRight}
|
y={line.percentColumn.yRight}
|
||||||
dy={maxLineHeight / 2}
|
dy={maxLineHeight / 2}
|
||||||
key={`${line.key}_percent`}
|
key={`${line.key}_percent`}
|
||||||
|
className={styles.outline}
|
||||||
>
|
>
|
||||||
{line.percentColumn.percentString}
|
{line.percentColumn.percentString}
|
||||||
</tspan>
|
</tspan>
|
||||||
@ -482,6 +507,7 @@ class PollDrawComponent extends Component {
|
|||||||
dy={maxLineHeight / 2}
|
dy={maxLineHeight / 2}
|
||||||
key={`${line.key}_numVotes`}
|
key={`${line.key}_numVotes`}
|
||||||
fill={line.barColumn.color}
|
fill={line.barColumn.color}
|
||||||
|
className={styles.outline}
|
||||||
>
|
>
|
||||||
{line.barColumn.numVotes}
|
{line.barColumn.numVotes}
|
||||||
</tspan>
|
</tspan>
|
||||||
@ -578,6 +604,7 @@ class PollDrawComponent extends Component {
|
|||||||
export default injectIntl(PollDrawComponent);
|
export default injectIntl(PollDrawComponent);
|
||||||
|
|
||||||
PollDrawComponent.propTypes = {
|
PollDrawComponent.propTypes = {
|
||||||
|
intl: intlShape.isRequired,
|
||||||
// Defines an annotation object, which contains all the basic info we need to draw a line
|
// Defines an annotation object, which contains all the basic info we need to draw a line
|
||||||
annotation: PropTypes.shape({
|
annotation: PropTypes.shape({
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
@import "/imports/ui/stylesheets/variables/_all";
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--poll-annotation-gray: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outline {
|
||||||
|
stroke: var(--poll-annotation-gray);
|
||||||
|
stroke-width: .5;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user