Skip to content

Commit

Permalink
Backport fixes v33 (#313)
Browse files Browse the repository at this point in the history
* Backport of #265

* Backport of #262

* Backport of #263

* Backport of #264

* Linting fixes
  • Loading branch information
turban authored Nov 20, 2019
1 parent f5b417d commit e1dca74
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 38 deletions.
10 changes: 8 additions & 2 deletions 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-09-03T08:55:52.263Z\n"
"PO-Revision-Date: 2019-09-03T08:55:52.263Z\n"
"POT-Creation-Date: 2019-11-20T11:07:38.479Z\n"
"PO-Revision-Date: 2019-11-20T11:07:38.479Z\n"

msgid "Maps"
msgstr ""
Expand Down Expand Up @@ -591,6 +591,12 @@ msgstr ""
msgid "Boundaries"
msgstr ""

msgid "Alert"
msgstr ""

msgid "No boundaries found"
msgstr ""

msgid "Access denied"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maps-app",
"version": "33.0.16",
"version": "33.0.17",
"description": "DHIS2 Maps",
"main": "src/app.js",
"repository": {
Expand Down
10 changes: 7 additions & 3 deletions src/components/classification/NumericLegendStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ export class NumericLegendStyle extends Component {

if (dataItem !== prevDataItem) {
if (dataItem.legendSet) {
setClassification(Number(CLASSIFICATION_PREDEFINED));
setClassification(CLASSIFICATION_PREDEFINED);
setLegendSet(dataItem.legendSet);
} else {
setClassification(Number(CLASSIFICATION_EQUAL_INTERVALS));
setClassification(CLASSIFICATION_EQUAL_INTERVALS);
}
}

if (method !== prevMethod && method === CLASSIFICATION_PREDEFINED) {
if (
method !== prevMethod &&
method === CLASSIFICATION_PREDEFINED &&
dataItem
) {
setLegendSet(dataItem.legendSet);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/dimensions/DimensionFilterRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class DimensionFilterRow extends Component {
<div className={classes.container}>
<DimensionSelect
dimension={dimension}
onChange={dimension => this.onChange(dimension.id, items)}
onChange={selectedDimension =>
this.onChange(selectedDimension.id)
}
/>
<DimensionItemsSelect
dimension={dimension}
Expand Down
2 changes: 1 addition & 1 deletion src/components/edit/thematic/ThematicDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class ThematicDialog extends Component {
onLayerValidation,
} = this.props;

if (rows) {
if (rows !== prev.rows) {
const orgUnits = getOrgUnitNodesFromRows(rows);

// Load organisation unit tree path (temporary solution, as favorites don't include paths)
Expand Down
5 changes: 1 addition & 4 deletions src/components/filter/FilterSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const styles = {
float: 'left',
width: 'calc((100% - 48px) / 8 * 3)',
},
datePicker: {
width: 164,
},
};

export class FilterSelect extends Component {
Expand Down Expand Up @@ -126,7 +123,7 @@ export class FilterSelect extends Component {
label={i18n.t('Date')}
value={value}
onChange={date => onChange(`${operator}:${date}`)}
style={styles.datePicker}
style={styles.textField}
/>
) : null,
];
Expand Down
4 changes: 4 additions & 0 deletions src/components/map/ThematicLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
} from '../../constants/layers';

class ThematicLayer extends Layer {
static defaultProps = {
renderingStrategy: 'SINGLE',
};

createLayer() {
const {
id,
Expand Down
16 changes: 6 additions & 10 deletions src/components/periods/PeriodSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,10 @@ class PeriodSelect extends Component {
};

state = {
year: getYear(),
year: null,
periods: null,
};

constructor(props) {
super(props);
this.periodIndex = null;
}

componentDidMount() {
this.setPeriods();
}
Expand All @@ -64,11 +59,11 @@ class PeriodSelect extends Component {
if (periodType !== prevProps.periodType) {
this.setPeriods();
} else if (periods && !period) {
onChange(filterFuturePeriods(periods)[0]); // Autoselect most recent period
onChange(filterFuturePeriods(periods)[0] || periods[0]); // Autoselect most recent period
}

// Change period if year is changed (but keep period index)
if (period && year !== prevState.year) {
if (period && prevState.periods && year !== prevState.year) {
const periodIndex = prevState.periods.findIndex(
item => item.id === period.id
);
Expand Down Expand Up @@ -130,15 +125,16 @@ class PeriodSelect extends Component {

setPeriods() {
const { periodType, period, locale } = this.props;
const year = this.state.year || getYear(period && period.startDate);
let periods;

if (periodType) {
periods = createPeriods(locale, periodType, this.state.year);
periods = createPeriods(locale, periodType, year);
} else if (period) {
periods = [period]; // If period is loaded in favorite
}

this.setState({ periods });
this.setState({ periods, year });
}

nextYear = () => {
Expand Down
12 changes: 8 additions & 4 deletions src/loaders/thematicLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import {
} from '../util/analytics';
import { createAlert } from '../util/alerts';
import { formatLocaleDate } from '../util/time';
import { DEFAULT_RADIUS_LOW, DEFAULT_RADIUS_HIGH } from '../constants/layers';
import {
DEFAULT_RADIUS_LOW,
DEFAULT_RADIUS_HIGH,
CLASSIFICATION_PREDEFINED,
} from '../constants/layers';

const thematicLoader = async config => {
let error;
Expand Down Expand Up @@ -50,7 +54,7 @@ const thematicLoader = async config => {
radiusHigh = DEFAULT_RADIUS_HIGH,
classes,
colorScale,
renderingStrategy,
renderingStrategy = 'SINGLE',
} = config;

const isSingle = renderingStrategy === 'SINGLE';
Expand All @@ -69,7 +73,7 @@ const thematicLoader = async config => {
const dataItem = getDataItemFromColumns(columns);
const name = names[dataItem.id];
let legendSet = config.legendSet;
let method = legendSet ? 1 : config.method; // Favorites often have wrong method
let method = legendSet ? CLASSIFICATION_PREDEFINED : config.method; // Favorites often have wrong method
let alert;

if (legendSet) {
Expand Down Expand Up @@ -241,7 +245,7 @@ const loadData = async config => {
valueType,
relativePeriodDate,
aggregationType,
renderingStrategy,
renderingStrategy = 'SINGLE',
} = config;
const orgUnits = getOrgUnitsFromRows(rows);
const period = getPeriodFromFilters(filters);
Expand Down
8 changes: 2 additions & 6 deletions src/loaders/trackedEntityLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,13 @@ const trackedEntityLoader = async config => {
}

if (program) {
url += `&program=${
program.id
}&programStatus=${programStatus}&programStartDate=${startDate}&programEndDate=${endDate}`;
url += `&program=${program.id}&programStatus=${programStatus}&programStartDate=${startDate}&programEndDate=${endDate}`;

if (followUp !== undefined) {
url += `&followUp=${followUp ? 'TRUE' : 'FALSE'}`;
}
} else {
url += `&trackedEntityType=${
trackedEntityType.id
}&lastUpdatedStartDate=${startDate}&lastUpdatedEndDate=${endDate}`;
url += `&trackedEntityType=${trackedEntityType.id}&lastUpdatedStartDate=${startDate}&lastUpdatedEndDate=${endDate}`;
}

// https://docs.dhis2.org/master/en/developer/html/webapi_tracker_api.html#webapi_tei_grid_query_request_syntax
Expand Down
4 changes: 1 addition & 3 deletions src/util/analyticalObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ export const setCurrentAnalyticalObject = async ao => {
// Sets analytical object to open it in another app
export const setAnalyticalObjectAndSwitchApp = async (layer, openAs) => {
const ao = getAnalyticalObjectFromThematicLayer(layer);
const url = `${config.appUrl}/${
APP_URLS[openAs]
}/#/currentAnalyticalObject`;
const url = `${config.appUrl}/${APP_URLS[openAs]}/#/currentAnalyticalObject`;

await setCurrentAnalyticalObject(ao);

Expand Down
4 changes: 1 addition & 3 deletions src/util/dom-to-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,7 @@ function newUtil() {
resolve(placeholder);
} else {
fail(
`cannot fetch resource: ${url}, status: ${
request.status
}`
`cannot fetch resource: ${url}, status: ${request.status}`
);
}

Expand Down

0 comments on commit e1dca74

Please sign in to comment.