Skip to content

Commit

Permalink
fix: locked dims not array (#491)
Browse files Browse the repository at this point in the history
* Updated Analytics dep to v2.6.12
* Locked dimensions handled as object instead of array
* General update to match latest Analytics signatures
* Fix for bug DHIS2-7960
  • Loading branch information
martinkrulltott authored Nov 28, 2019
1 parent f94662f commit ae8e741
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 50 deletions.
10 changes: 5 additions & 5 deletions packages/app/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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: 2019-11-21T07:25:38.180Z\n"
"PO-Revision-Date: 2019-11-21T07:25:38.180Z\n"
"POT-Creation-Date: 2019-11-28T10:06:38.807Z\n"
"PO-Revision-Date: 2019-11-28T10:06:38.807Z\n"

msgid "Rename successful"
msgstr ""
Expand Down Expand Up @@ -98,13 +98,13 @@ msgstr ""
msgid "Interpretations"
msgstr ""

msgid "{{dimensionName}} is locked to {{axisName}} for {{visTypeName}}"
msgid "{{total}} of {{axisMaxNumberOfItems}} selected"
msgstr ""

msgid "{{total}} of {{maxNumberOfItemsPerAxis}} selected"
msgid "{{total}} selected"
msgstr ""

msgid "{{total}} selected"
msgid "{{dimensionName}} is locked to {{axisName}} for {{visTypeName}}"
msgstr ""

msgid "Move to"
Expand Down
5 changes: 1 addition & 4 deletions packages/app/i18n/ru.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Translators:
# Viktor Varland <[email protected]>, 2019
# phil_dhis2, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
Expand Down Expand Up @@ -315,9 +315,6 @@ msgstr ""
msgid "Single value"
msgstr ""

msgid "Open as Map"
msgstr ""

msgid "Reporting rate"
msgstr "Показатель отчетности"

Expand Down
23 changes: 22 additions & 1 deletion packages/app/i18n/sv.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Translators:
# Viktor Varland <[email protected]>, 2019
# phil_dhis2, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
Expand Down Expand Up @@ -105,6 +105,27 @@ msgstr ""
msgid "Interpretations"
msgstr "tolkningar"

msgid "{{dimensionName}} is locked to {{axisName}} for {{visTypeName}}"
msgstr ""

msgid "{{total}} of {{maxNumberOfItemsPerAxis}} selected"
msgstr ""

msgid "{{total}} selected"
msgstr ""

msgid "Move to"
msgstr ""

msgid "Remove"
msgstr "Avlägsna"

msgid "None selected"
msgstr ""

msgid "Only '{{name}}' in use"
msgstr ""

msgid "Only '{{number}}' in use"
msgstr ""

Expand Down
5 changes: 4 additions & 1 deletion packages/app/i18n/uk.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Translators:
# Viktor Varland <[email protected]>, 2019
# phil_dhis2, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
Expand Down Expand Up @@ -126,6 +126,9 @@ msgstr ""
msgid "Only '{{name}}' in use"
msgstr ""

msgid "Only '{{number}}' in use"
msgstr ""

msgid "Unsaved chart"
msgstr ""

Expand Down
13 changes: 8 additions & 5 deletions packages/app/i18n/ur.po
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Translators:
# Viktor Varland <[email protected]>, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
Expand Down Expand Up @@ -113,11 +113,14 @@ msgstr ""
msgid "{{total}} selected"
msgstr ""

msgid "Move to"
msgstr "پر منتقل"
msgid "Error validating layout"
msgstr ""

msgid "None selected"
msgstr "کوئی بھی منتخب نہیں"
msgid "Create a new visualization by adding dimensions to the layout"
msgstr ""

msgid "Chart error"
msgstr ""

msgid "Only '{{name}}' in use"
msgstr ""
Expand Down
5 changes: 4 additions & 1 deletion packages/app/i18n/vi.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Translators:
# Viktor Varland <[email protected]>, 2019
# phil_dhis2, 2019
#
#
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
Expand Down Expand Up @@ -117,6 +117,9 @@ msgstr ""
msgid "Move to"
msgstr ""

msgid "Remove"
msgstr "Tháo ra"

msgid "None selected"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"webpack-bundle-analyzer": "^3.0.3"
},
"dependencies": {
"@dhis2/analytics": "^2.6.11",
"@dhis2/analytics": "^2.6.12",
"@dhis2/d2-i18n": "^1.0.6",
"@dhis2/d2-ui-core": "^6.2.1",
"@dhis2/d2-ui-file-menu": "^6.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
DIMENSION_ID_DATA,
DIMENSION_ID_PERIOD,
DIMENSION_ID_ORGUNIT,
getMaxNumberOfItemsPerAxis,
getAxisMaxNumberOfItems,
getDisplayNameByVisType,
filterOutFixedDimensions,
} from '@dhis2/analytics';
Expand Down Expand Up @@ -213,19 +213,19 @@ export class DialogManager extends Component {
const visType = type;
const numberOfItems = selectedItems.length;

const maxNumberOfItemsPerAxis = getMaxNumberOfItemsPerAxis(
const axisMaxNumberOfItems = getAxisMaxNumberOfItems(
visType,
axisId
);

const hasMaxNumberOfItemsRule = !!maxNumberOfItemsPerAxis;
const hasMaxNumberOfItemsRule = !!axisMaxNumberOfItems;

if (
hasMaxNumberOfItemsRule &&
numberOfItems > maxNumberOfItemsPerAxis
numberOfItems > axisMaxNumberOfItems
) {
infoBoxMessage =
maxNumberOfItemsPerAxis === 1
axisMaxNumberOfItems === 1
? i18n.t(
`'{{visualiationType}}' is intended to show a single data item. Only the first item will be used and saved.`,
{
Expand All @@ -240,12 +240,12 @@ export class DialogManager extends Component {
visualiationType: getDisplayNameByVisType(
visType
),
maxNumber: maxNumberOfItemsPerAxis,
maxNumber: axisMaxNumberOfItems,
}
);

selectedItems.forEach((item, index) => {
item.isActive = index < maxNumberOfItemsPerAxis;
item.isActive = index < axisMaxNumberOfItems;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jest.mock('@dhis2/analytics', () => {
[periodId]: {},
[ouId]: {},
},
getMaxNumberOfItemsPerAxis: () => {},
getAxisMaxNumberOfItems: () => {},
filterOutFixedDimensions: () => [],
getAxisName: () => {},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
DimensionsPanel,
DimensionMenu,
getDisallowedDimensions,
getLockedDimensions,
getAllLockedDimensionIds,
} from '@dhis2/analytics';

import DialogManager from './Dialogs/DialogManager';
Expand Down Expand Up @@ -108,7 +108,7 @@ const getDisallowedDimensionsMemo = createSelector(

const getLockedDimensionsMemo = createSelector(
[sGetUiType],
type => getLockedDimensions(type)
type => getAllLockedDimensionIds(type)
);

const mapStateToProps = state => {
Expand Down
29 changes: 14 additions & 15 deletions packages/app/src/components/Layout/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import LockIcon from '@material-ui/icons/Lock';
import i18n from '@dhis2/d2-i18n';
import {
FIXED_DIMENSIONS,
getMaxNumberOfItemsPerAxis,
hasTooManyItemsPerAxis,
getLockedDimensionAxis,
getAxisMaxNumberOfItems,
hasAxisTooManyItems,
getAxisPerLockedDimension,
getDisplayNameByVisType,
getAxisName,
} from '@dhis2/analytics';
Expand Down Expand Up @@ -44,12 +44,11 @@ class Chip extends React.Component {

timeout = null;

isLocked = getLockedDimensionAxis(
this.props.type,
this.props.dimensionId
).includes(this.props.axisId);
isLocked =
getAxisPerLockedDimension(this.props.type, this.props.dimensionId) ===
this.props.axisId;

maxNumberOfItemsPerAxis = getMaxNumberOfItemsPerAxis(
axisMaxNumberOfItems = getAxisMaxNumberOfItems(
this.props.type,
this.props.axisId
);
Expand Down Expand Up @@ -99,11 +98,11 @@ class Chip extends React.Component {
const numberOfItems = this.props.items.length;

const getItemsLabel =
!!this.maxNumberOfItemsPerAxis &&
numberOfItems > this.maxNumberOfItemsPerAxis
? i18n.t(`{{total}} of {{maxNumberOfItemsPerAxis}} selected`, {
!!this.axisMaxNumberOfItems &&
numberOfItems > this.axisMaxNumberOfItems
? i18n.t(`{{total}} of {{axisMaxNumberOfItems}} selected`, {
total: numberOfItems,
maxNumberOfItemsPerAxis: this.maxNumberOfItemsPerAxis,
axisMaxNumberOfItems: this.axisMaxNumberOfItems,
})
: i18n.t('{{total}} selected', {
total: numberOfItems,
Expand Down Expand Up @@ -137,8 +136,8 @@ class Chip extends React.Component {
);

renderTooltip = () => {
const activeItemIds = !!this.maxNumberOfItemsPerAxis
? this.props.items.slice(0, this.maxNumberOfItemsPerAxis)
const activeItemIds = !!this.axisMaxNumberOfItems
? this.props.items.slice(0, this.axisMaxNumberOfItems)
: this.props.items;

const lockedLabel = this.isLocked
Expand Down Expand Up @@ -181,7 +180,7 @@ class Chip extends React.Component {
>
<div style={styles.iconWrapper}>{this.renderChipIcon()}</div>
{this.renderChipLabel()}
{hasTooManyItemsPerAxis(
{hasAxisTooManyItems(
this.props.type,
this.props.axisId,
this.props.items.length
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/components/Layout/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import { styles } from './styles/Tooltip.style';

const labels = {
noneSelected: i18n.t('None selected'),
onlyOneInUse: name => i18n.t("Only '{{name}}' in use", { name }),
onlyOneInUse: name => i18n.t("Only '{{- name}}' in use", { name }),
onlyLimitedNumberInUse: number =>
i18n.t("Only '{{number}}' in use", { number }),
};

export class Tooltip extends React.Component {
renderTooltip = (names, warning) => (
<Popper
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./build/index.js",
"license": "BSD-3-Clause",
"dependencies": {
"@dhis2/analytics": "^2.6.11",
"@dhis2/analytics": "^2.6.12",
"@material-ui/core": "^3.1.2",
"lodash-es": "^4.17.11",
"react": "^16.6.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@
react-beautiful-dnd "^10.1.1"
styled-jsx "^3.2.1"

"@dhis2/analytics@^2.6.11":
version "2.6.11"
resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-2.6.11.tgz#ef04418f655de7f2c9639da4f0e0608b7b711ebf"
integrity sha512-COxLvHfkDuRgCqEwbZH9I62lTB1IBiv0+fFBibIGdAt1b+qcYvmxph7Z8WxWld55aq0oXuXGtvw+goMSFyn2LQ==
"@dhis2/analytics@^2.6.12":
version "2.6.12"
resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-2.6.12.tgz#0d34b604bbee16c2a9f4091551170811d7d7c8d1"
integrity sha512-cNtZvioufUWnd3ZNEwKnKnjnaieR5Rsl5TubLxnsLbOcVuEPQAmqXrQHqMRUXypl7yjxf1g/QHFDimfPRQAopA==
dependencies:
"@dhis2/d2-i18n" "^1.0.4"
"@dhis2/d2-ui-org-unit-dialog" "^6.3.0"
Expand Down

0 comments on commit ae8e741

Please sign in to comment.