diff --git a/packages/app/i18n/en.pot b/packages/app/i18n/en.pot index be19fc8416..dc0e9b3834 100644 --- a/packages/app/i18n/en.pot +++ b/packages/app/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2020-02-05T10:48:05.798Z\n" -"PO-Revision-Date: 2020-02-05T10:48:05.798Z\n" +"POT-Creation-Date: 2020-02-07T15:29:25.817Z\n" +"PO-Revision-Date: 2020-02-07T15:29:25.817Z\n" msgid "Rename successful" msgstr "" @@ -34,6 +34,9 @@ msgstr "" msgid "Update" msgstr "" +msgid "Add to {{axisName}}" +msgstr "" + msgid "" "'{{visualizationType}}' is intended to show a single data item. Only the " "first item will be used and saved." @@ -44,6 +47,15 @@ msgid "" "items. Only the first {{maxNumber}} items will be used and saved." msgstr "" +msgid "Main dimensions" +msgstr "" + +msgid "Other dimensions" +msgstr "" + +msgid "Your dimensions" +msgstr "" + msgid "Filter dimensions" msgstr "" @@ -119,12 +131,6 @@ msgstr "" msgid "{{dimensionName}} is locked to {{axisName}} for {{visTypeName}}" msgstr "" -msgid "Columns" -msgstr "" - -msgid "Rows" -msgstr "" - msgid "None selected" msgstr "" @@ -143,6 +149,23 @@ msgstr "" msgid "Viewing interpretation from {{interpretationDate}}" msgstr "" +msgid "Getting started" +msgstr "" + +msgid "" +"All dimensions that you can use to build visualizations are shown in the " +"left sidebar" +msgstr "" + +msgid "Add dimensions to the layout above" +msgstr "" + +msgid "Double click a dimension to add or remove items" +msgstr "" + +msgid "Your most viewed charts and tables" +msgstr "" + msgid "Aggregation type" msgstr "" @@ -459,31 +482,25 @@ msgid "" "you may not have access to it." msgstr "" -msgid "Series is empty" -msgstr "" - -msgid "Add at least one item to Series." +msgid "{{axisName}} is empty" msgstr "" -msgid "Category is empty" -msgstr "" - -msgid "Add at least one item to Category." +msgid "Add at least one item to {{axisName}}." msgstr "" msgid "No period set" msgstr "" -msgid "{{visType}} must have at least one period set in {{axes}}." +msgid "{{visualizationType}} must have at least one period set in {{axes}}." msgstr "" msgid "No data set" msgstr "" -msgid "{{visType}} must have at least one data item in {{axes}}." +msgid "{{visualizationType}} must have at least one data item in {{axes}}." msgstr "" -msgid "There is a problem with this {{visType}} visualization." +msgid "There is a problem with this {{visualizationType}} visualization." msgstr "" msgid "There was a problem getting the data from the server." @@ -504,24 +521,6 @@ msgstr "" msgid "or" msgstr "" -msgid "Add to series" -msgstr "" - -msgid "Add to category" -msgstr "" - -msgid "Add to filter" -msgstr "" - -msgid "series" -msgstr "" - -msgid "category" -msgstr "" - -msgid "filter" -msgstr "" - msgid "Today" msgstr "" diff --git a/packages/app/package.json b/packages/app/package.json index eceee34e95..cf96a3e37e 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -12,7 +12,7 @@ "redux-mock-store": "^1.5.3" }, "dependencies": { - "@dhis2/analytics": "^3.1.2", + "@dhis2/analytics": "^3.1.3", "@dhis2/d2-ui-core": "^6.5.3", "@dhis2/d2-ui-file-menu": "^6.5.3", "@dhis2/d2-ui-interpretations": "^6.5.3", diff --git a/packages/app/src/components/DimensionsPanel/Dialogs/AddToLayoutButton/AddToLayoutButton.js b/packages/app/src/components/DimensionsPanel/Dialogs/AddToLayoutButton/AddToLayoutButton.js index 9718b5f1ee..1568f00796 100644 --- a/packages/app/src/components/DimensionsPanel/Dialogs/AddToLayoutButton/AddToLayoutButton.js +++ b/packages/app/src/components/DimensionsPanel/Dialogs/AddToLayoutButton/AddToLayoutButton.js @@ -4,14 +4,18 @@ import { connect } from 'react-redux' import Button from '@material-ui/core/Button' import MenuItem from '@material-ui/core/Button' import { withStyles } from '@material-ui/core/styles' -import { getAvailableAxes } from '@dhis2/analytics' +import { + getAvailableAxes, + getAxisNameByLayoutType, + getLayoutTypeByVisType, +} from '@dhis2/analytics' import Menu from './Menu' import { sGetUiActiveModalDialog, sGetUiType } from '../../../../reducers/ui' import { acAddUiLayoutDimensions } from '../../../../actions/ui' -import { ADD_TO_LAYOUT_OPTIONS } from '../../../../modules/layout' import styles from './styles/AddToLayoutButton.style' +import i18n from '@dhis2/d2-i18n' export class AddToLayoutButton extends Component { constructor(props) { @@ -36,31 +40,27 @@ export class AddToLayoutButton extends Component { this.props.onClick() } - getAxisMeta = axisIdArray => - axisIdArray.map(axisId => - ADD_TO_LAYOUT_OPTIONS.find( - axisMetaObj => axisMetaObj.axisId === axisId - ) - ) - renderMenuItems = () => - this.getAxisMeta(getAvailableAxes(this.props.visType)) + getAvailableAxes(this.props.visType) .slice(1) - .map(axisMetaObj => ( + .map(axis => ( this.onUpdate(axisMetaObj.axisId)} + key={axis} + onClick={() => this.onUpdate(axis)} > - {axisMetaObj.name} + {i18n.t(`Add to {{axisName}}`, { + axisName: getAxisNameByLayoutType( + axis, + getLayoutTypeByVisType(this.props.visType) + ), + })} )) render() { - const availableAxisMeta = this.getAxisMeta( - getAvailableAxes(this.props.visType) - ) + const availableAxes = getAvailableAxes(this.props.visType) return (
(this.buttonRef = addToRef)}> @@ -70,11 +70,16 @@ export class AddToLayoutButton extends Component { color="primary" disableRipple disableFocusRipple - onClick={() => this.onUpdate(availableAxisMeta[0].axisId)} + onClick={() => this.onUpdate(availableAxes[0])} > - {availableAxisMeta[0].name} + {i18n.t(`Add to {{axisName}}`, { + axisName: getAxisNameByLayoutType( + availableAxes[0], + getLayoutTypeByVisType(this.props.visType) + ), + })} - {availableAxisMeta.length > 1 ? ( + {availableAxes.length > 1 ? ( { let props @@ -55,7 +55,7 @@ describe('The DropDownButton component ', () => { it('renders a Menu with children if prop anchorel is equal to a truthy value', () => { props.anchorEl = { getBoundingClientRect: () => ({ bottom: 100 }) } - props.menuItems = ADD_TO_LAYOUT_OPTIONS.map((option, i) => ( + props.menuItems = getAvailableAxes(VIS_TYPE_COLUMN).map((option, i) => ( )) diff --git a/packages/app/src/components/DimensionsPanel/Dialogs/__tests__/DialogManager.spec.js b/packages/app/src/components/DimensionsPanel/Dialogs/__tests__/DialogManager.spec.js index 88792c487c..7861bc3118 100644 --- a/packages/app/src/components/DimensionsPanel/Dialogs/__tests__/DialogManager.spec.js +++ b/packages/app/src/components/DimensionsPanel/Dialogs/__tests__/DialogManager.spec.js @@ -35,7 +35,6 @@ jest.mock('@dhis2/analytics', () => { DIMENSION_ID_ORGUNIT: ouId, getAxisMaxNumberOfItems: () => {}, filterOutPredefinedDimensions: () => [], - getAxisName: () => {}, getPredefinedDimensions: () => {}, getPredefinedDimensionProp: () => {}, } diff --git a/packages/app/src/components/DimensionsPanel/DndDimensionList.js b/packages/app/src/components/DimensionsPanel/DndDimensionList.js index 9a266fd75a..be5f48cb66 100644 --- a/packages/app/src/components/DimensionsPanel/DndDimensionList.js +++ b/packages/app/src/components/DimensionsPanel/DndDimensionList.js @@ -10,6 +10,7 @@ import { getDynamicDimensions, getPredefinedDimensions, } from '@dhis2/analytics' +import i18n from '@dhis2/d2-i18n' import DndDimensionItem from './DndDimensionItem' import * as fromReducers from '../../reducers' @@ -88,7 +89,7 @@ export class DndDimensionList extends Component {

- Main dimensions + {i18n.t('Main dimensions')}

    {fixedDimensions} @@ -96,7 +97,7 @@ export class DndDimensionList extends Component {

- Other dimensions + {i18n.t('Other dimensions')}

    {dynamicDimensions} @@ -104,7 +105,7 @@ export class DndDimensionList extends Component {

- Your dimensions + {i18n.t('Your dimensions')}

    {nonPredefinedDimensions} diff --git a/packages/app/src/components/Layout/Chip.js b/packages/app/src/components/Layout/Chip.js index 51f0c920b4..088a88f60f 100644 --- a/packages/app/src/components/Layout/Chip.js +++ b/packages/app/src/components/Layout/Chip.js @@ -9,7 +9,8 @@ import { getAxisMaxNumberOfItems, hasAxisTooManyItems, getDisplayNameByVisType, - getAxisName, + getAxisNameByLayoutType, + getLayoutTypeByVisType, DIMENSION_ID_ASSIGNED_CATEGORIES, isDimensionLocked, DIMENSION_PROP_NO_ITEMS, @@ -154,7 +155,10 @@ class Chip extends React.Component { `{{dimensionName}} is locked to {{axisName}} for {{visTypeName}}`, { dimensionName: this.props.dimensionName, - axisName: getAxisName(this.props.axisId), + axisName: getAxisNameByLayoutType( + this.props.axisId, + getLayoutTypeByVisType(this.props.type) + ), visTypeName: getDisplayNameByVisType(this.props.type), } ) diff --git a/packages/app/src/components/Layout/DefaultLayout/DefaultAxis.js b/packages/app/src/components/Layout/DefaultLayout/DefaultAxis.js index ec86646ddb..f9bfaa5d11 100644 --- a/packages/app/src/components/Layout/DefaultLayout/DefaultAxis.js +++ b/packages/app/src/components/Layout/DefaultLayout/DefaultAxis.js @@ -2,7 +2,11 @@ import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { Droppable, Draggable } from 'react-beautiful-dnd' -import { getAxisName, isDimensionLocked } from '@dhis2/analytics' +import { + getAxisNameByLayoutType, + getLayoutTypeByVisType, + isDimensionLocked, +} from '@dhis2/analytics' import { withStyles } from '@material-ui/core' import Chip from '../Chip' @@ -25,7 +29,11 @@ class Axis extends React.Component { onDragOver={this.onDragOver} >
    - {this.props.label || getAxisName(axisId)} + {this.props.label || + getAxisNameByLayoutType( + axisId, + getLayoutTypeByVisType(type) + )}
    {provided => ( diff --git a/packages/app/src/components/Layout/PivotTableLayout/PivotTableLayout.js b/packages/app/src/components/Layout/PivotTableLayout/PivotTableLayout.js index 05eb3aad97..5e0aa019e2 100644 --- a/packages/app/src/components/Layout/PivotTableLayout/PivotTableLayout.js +++ b/packages/app/src/components/Layout/PivotTableLayout/PivotTableLayout.js @@ -1,5 +1,4 @@ import React from 'react' -import i18n from '@dhis2/d2-i18n' import { AXIS_ID_COLUMNS, AXIS_ID_ROWS, @@ -22,7 +21,6 @@ const Layout = () => ( > ( /> ( style={{ ...defaultAxisStyles.axisContainer, ...props.style }} >
    - {getAxisName(props.axisId)} + {getAxisNameByLayoutType(props.axisId, LAYOUT_TYPE_YEAR_OVER_YEAR)}
    ( }} > ( /> { ) : (
    -

    Getting started

    +

    {i18n.t('Getting started')}

    • - All dimensions that you can use to build - visualizations are shown in the left sidebar + {i18n.t( + 'All dimensions that you can use to build visualizations are shown in the left sidebar' + )}
    • - Add dimensions to the layout above + {i18n.t('Add dimensions to the layout above')}
    • - Double click a dimension to add or remove items + {i18n.t( + 'Double click a dimension to add or remove items' + )}
    {mostViewedVisualizations.length > 0 && (

    - Most viewed charts and tables + {i18n.t('Your most viewed charts and tables')}

    {mostViewedVisualizations.map( (visualization, index) => ( diff --git a/packages/app/src/modules/error.js b/packages/app/src/modules/error.js index 6b6763607b..b8ac0d48bc 100644 --- a/packages/app/src/modules/error.js +++ b/packages/app/src/modules/error.js @@ -2,9 +2,12 @@ import i18n from '@dhis2/d2-i18n' import { getDisplayNameByVisType, getAvailableAxes, - getAxisName, + getAxisNameByLayoutType, + getLayoutTypeByVisType, getAxisPerLockedDimension, DIMENSION_ID_DATA, + AXIS_ID_COLUMNS, + AXIS_ID_ROWS, } from '@dhis2/analytics' import { @@ -37,21 +40,41 @@ export class EmptyResponseError extends VisualizationError { } export class NoSeriesError extends VisualizationError { - constructor() { + constructor(visType) { super( EmptySeries, - i18n.t('Series is empty'), - i18n.t('Add at least one item to Series.') + i18n.t(`{{axisName}} is empty`, { + axisName: getAxisNameByLayoutType( + AXIS_ID_COLUMNS, + getLayoutTypeByVisType(visType) + ), + }), + i18n.t('Add at least one item to {{axisName}}.', { + axisName: getAxisNameByLayoutType( + AXIS_ID_COLUMNS, + getLayoutTypeByVisType(visType) + ), + }) ) } } export class NoCategoryError extends VisualizationError { - constructor() { + constructor(visType) { super( EmptyCategory, - i18n.t('Category is empty'), - i18n.t('Add at least one item to Category.') + i18n.t(`{{axisName}} is empty`, { + axisName: getAxisNameByLayoutType( + AXIS_ID_ROWS, + getLayoutTypeByVisType(visType) + ), + }), + i18n.t('Add at least one item to {{axisName}}.', { + axisName: getAxisNameByLayoutType( + AXIS_ID_ROWS, + getLayoutTypeByVisType(visType) + ), + }) ) } } @@ -62,9 +85,9 @@ export class NoPeriodError extends VisualizationError { PeriodError, i18n.t('No period set'), i18n.t( - '{{visType}} must have at least one period set in {{axes}}.', + '{{visualizationType}} must have at least one period set in {{axes}}.', { - visType: getDisplayNameByVisType(visType), + visualizationType: getDisplayNameByVisType(visType), axes: getAvailableAxesDescription(visType), } ) @@ -79,11 +102,14 @@ export class NoDataError extends VisualizationError { DataError, i18n.t('No data set'), i18n.t( - '{{visType}} must have at least one data item in {{axes}}.', + '{{visualizationType}} must have at least one data item in {{axes}}.', { - visType: getDisplayNameByVisType(visType), + visualizationType: getDisplayNameByVisType(visType), axes: lockedAxis - ? getAxisName(lockedAxis) + ? getAxisNameByLayoutType( + lockedAxis, + getLayoutTypeByVisType(visType) + ) : getAvailableAxesDescription(visType), } ) @@ -96,9 +122,12 @@ export class GenericClientError extends VisualizationError { super( GenericError, i18n.t('Something went wrong'), - i18n.t('There is a problem with this {{visType}} visualization.', { - visType: getDisplayNameByVisType(visType), - }) + i18n.t( + 'There is a problem with this {{visualizationType}} visualization.', + { + visualizationType: getDisplayNameByVisType(visType), + } + ) ) } } @@ -141,7 +170,10 @@ const getAvailableAxesDescription = visType => { const axes = getAvailableAxes(visType) let axesDescription = '' for (let index = 0; index < axes.length; index++) { - axesDescription += getAxisName(axes[index]) + axesDescription += getAxisNameByLayoutType( + axes[index], + getLayoutTypeByVisType(visType) + ) if (index < axes.length - 2) { axesDescription += ', ' } else if (index < axes.length - 1) { diff --git a/packages/app/src/modules/layout.js b/packages/app/src/modules/layout.js index b757b20e26..b40e21b8c0 100644 --- a/packages/app/src/modules/layout.js +++ b/packages/app/src/modules/layout.js @@ -1,4 +1,3 @@ -import i18n from '@dhis2/d2-i18n' import { AXIS_ID_COLUMNS, AXIS_ID_ROWS, @@ -12,19 +11,6 @@ import { // Names for dnd sources export const SOURCE_DIMENSIONS = 'dimensions' -// Keys and displayName for adding dimensions to layout -export const ADD_TO_LAYOUT_OPTIONS = [ - { axisId: AXIS_ID_COLUMNS, name: i18n.t('Add to series') }, - { axisId: AXIS_ID_ROWS, name: i18n.t('Add to category') }, - { axisId: AXIS_ID_FILTERS, name: i18n.t('Add to filter') }, -] - -export const menuLabels = { - columns: i18n.t('series'), - rows: i18n.t('category'), - filters: i18n.t('filter'), -} - // Layout utility functions // Exclude one or many dimensions from layout diff --git a/packages/app/src/modules/layoutValidation.js b/packages/app/src/modules/layoutValidation.js index 5698967cff..a5adba1414 100644 --- a/packages/app/src/modules/layoutValidation.js +++ b/packages/app/src/modules/layoutValidation.js @@ -47,8 +47,8 @@ const validateAxis = (axis, error) => { // Layout validation const validateDefaultLayout = layout => { - validateAxis(layout.columns, new NoSeriesError()) - validateAxis(layout.rows, new NoCategoryError()) + validateAxis(layout.columns, new NoSeriesError(layout.type)) + validateAxis(layout.rows, new NoCategoryError(layout.type)) validateDimension( layoutGetDimension(layout, DIMENSION_ID_PERIOD), // TODO: old validation rule, refactor new NoPeriodError(layout.type) @@ -62,14 +62,14 @@ const validateYearOverYearLayout = layout => { typeof layout[BASE_FIELD_YEARLY_SERIES][0] === 'string' ) ) { - throw new NoSeriesError() + throw new NoSeriesError(layout.type) } - validateAxis(layout.rows, new NoCategoryError()) + validateAxis(layout.rows, new NoCategoryError(layout.type)) } const validatePieLayout = layout => { - validateAxis(layout.columns, new NoSeriesError()) + validateAxis(layout.columns, new NoSeriesError(layout.type)) validateDimension( layoutGetDimension(layout, DIMENSION_ID_PERIOD), new NoPeriodError(layout.type) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index a88f7055d6..2532b3328e 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -6,7 +6,7 @@ "module": "./build/es/lib.js", "license": "BSD-3-Clause", "dependencies": { - "@dhis2/analytics": "^3.1.2", + "@dhis2/analytics": "^3.1.3", "@material-ui/core": "^3.1.2", "d2-analysis": "33.2.11", "lodash-es": "^4.17.11", diff --git a/yarn.lock b/yarn.lock index 7c2bede8aa..7f7a51459a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1442,10 +1442,10 @@ react-beautiful-dnd "^10.1.1" styled-jsx "^3.2.1" -"@dhis2/analytics@^3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-3.1.2.tgz#155795478ce9a2a1043513db764ba483435b3da3" - integrity sha512-phd61NTZ00/R6ktHlsQVg0T+kt0NOvE/aiQDQHWgBaL557B+iG1sEag1IpXymyGuGEkuSvr+oZX3pYPlCEqlkw== +"@dhis2/analytics@^3.1.3": + version "3.1.3" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-3.1.3.tgz#44ea6812ad74620b26e43b8062e7f8e4cfaaabd8" + integrity sha512-8gGKivu6SxShvFbI6Md9NMqBKSjbQx4/9DdvUfqPZQ8w1vcC//kEuzMX+GBHBEvMuKfWJk0jzqYSj7mWXBhvUA== dependencies: "@dhis2/d2-i18n" "^1.0.4" "@dhis2/d2-ui-org-unit-dialog" "^6.3.2"