From dc27c7c71f0636129497a1f03fa50301e48715da Mon Sep 17 00:00:00 2001 From: Rohan Port <59544282+rohan-bes@users.noreply.github.com> Date: Mon, 5 Sep 2022 13:25:53 +1000 Subject: [PATCH 1/6] hotfix: Fix broken PSSS Countries tab (#4142) --- packages/ui-components/src/components/Table/Table.js | 4 ++-- packages/ui-components/src/components/Table/TablePaginator.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ui-components/src/components/Table/Table.js b/packages/ui-components/src/components/Table/Table.js index 645674f450..39459b6a86 100644 --- a/packages/ui-components/src/components/Table/Table.js +++ b/packages/ui-components/src/components/Table/Table.js @@ -7,7 +7,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import MuiTable from '@material-ui/core/Table'; -import { TablePaginator } from './TablePaginator'; +import { TablePaginator, DEFAULT_ROWS_PER_PAGE_OPTIONS } from './TablePaginator'; import { TableHeader } from './TableHeader'; import { TableBody } from './TableBody'; import { TableMessageProvider } from './TableMessageProvider'; @@ -128,7 +128,7 @@ Table.defaultProps = { order: 'asc', page: null, rowsPerPage: 10, - rowsPerPageOptions: null, + rowsPerPageOptions: DEFAULT_ROWS_PER_PAGE_OPTIONS, rowIdKey: 'id', className: null, }; diff --git a/packages/ui-components/src/components/Table/TablePaginator.js b/packages/ui-components/src/components/Table/TablePaginator.js index 1d6f399b31..2e13cc5c0e 100644 --- a/packages/ui-components/src/components/Table/TablePaginator.js +++ b/packages/ui-components/src/components/Table/TablePaginator.js @@ -10,7 +10,7 @@ import styled from 'styled-components'; import PropTypes from 'prop-types'; import { tableColumnShape } from './tableColumnShape'; -const ROWS_PER_PAGE_OPTIONS = [10, 25, 50]; +export const DEFAULT_ROWS_PER_PAGE_OPTIONS = [10, 25, 50]; const TableFooter = styled(MuiTableFooter)` .MuiTableCell-footer.MuiTablePagination-root { @@ -125,6 +125,6 @@ TablePaginator.defaultProps = { onChangeRowsPerPage: null, page: null, rowsPerPage: 10, - rowsPerPageOptions: ROWS_PER_PAGE_OPTIONS, + rowsPerPageOptions: DEFAULT_ROWS_PER_PAGE_OPTIONS, isFetching: false, }; From 461221106897439e2b63bd15878249965d744573 Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 6 Sep 2022 09:26:06 +1000 Subject: [PATCH 2/6] (hotfix) MAUI-1228 Map overlay look deeper for polygon data (#4145) --- .../InteractivePolygonLayer.js | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js index bbc973660c..f0188cfce1 100644 --- a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js +++ b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js @@ -103,21 +103,38 @@ const mapStateToProps = (state, ownProps) => { const permanentLabels = selectAreRegionLabelsPermanent(state); // orginal data // If the org unit's grandchildren are polygons and have a measure, display grandchildren - // rather than children + // rather than children (recursive) let displayedChildren = currentChildren; let measureOrgUnits = []; if (selectHasPolygonMeasure(state)) { measureOrgUnits = selectMeasuresWithDisplayInfo(state, displayedMapOverlayCodes); const measureOrgUnitCodes = measureOrgUnits.map(orgUnit => orgUnit.organisationUnitCode); - const grandchildren = currentChildren - .map(area => selectOrgUnitChildren(state, area.organisationUnitCode)) - .reduce((acc, val) => acc.concat(val), []); // equivelent to .flat(), for IE - - const hasShadedGrandchildren = - grandchildren && - grandchildren.some(child => measureOrgUnitCodes.includes(child.organisationUnitCode)); - if (hasShadedGrandchildren) displayedChildren = grandchildren; + + const getDisplayedDescendants = parents => { + if (!Array.isArray(parents) || parents.length === 0) return parents; + + const children = parents + .map(area => selectOrgUnitChildren(state, area.organisationUnitCode)) + .reduce((acc, val) => acc.concat(val), []); // equivelent to .flat(), for IE + if (children.length === 0) return null; + + // if this is the measure layer return it + const hasShadedPolygonChildren = + children && + children.some( + child => + organisationUnitIsArea(child) && + measureOrgUnitCodes.includes(child.organisationUnitCode), + ); + if (hasShadedPolygonChildren) return children; + + // otherwise look deeper + return getDisplayedDescendants(children); + }; + + const displayedDescendants = getDisplayedDescendants(currentChildren); + if (displayedDescendants) displayedChildren = displayedDescendants; } const getChildren = organisationUnitCode => selectOrgUnitChildren(state, organisationUnitCode); From 3b51777a7c53d32269ba6e4ecfec98e79a1df66d Mon Sep 17 00:00:00 2001 From: Igor Nadj Date: Tue, 6 Sep 2022 11:09:30 +1000 Subject: [PATCH 3/6] Hotfix: MAUI-1228 prevent infinite loop --- .../Map/DataVisualsLayer/InteractivePolygonLayer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js index f0188cfce1..95a7415bc6 100644 --- a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js +++ b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js @@ -111,8 +111,9 @@ const mapStateToProps = (state, ownProps) => { measureOrgUnits = selectMeasuresWithDisplayInfo(state, displayedMapOverlayCodes); const measureOrgUnitCodes = measureOrgUnits.map(orgUnit => orgUnit.organisationUnitCode); - const getDisplayedDescendants = parents => { - if (!Array.isArray(parents) || parents.length === 0) return parents; + const getDisplayedDescendants = (parents, depth) => { + if (depth > 5) return null; // prevent infinite loops + if (!Array.isArray(parents) || parents.length === 0) return null; const children = parents .map(area => selectOrgUnitChildren(state, area.organisationUnitCode)) @@ -130,10 +131,10 @@ const mapStateToProps = (state, ownProps) => { if (hasShadedPolygonChildren) return children; // otherwise look deeper - return getDisplayedDescendants(children); + return getDisplayedDescendants(children, depth + 1); }; - const displayedDescendants = getDisplayedDescendants(currentChildren); + const displayedDescendants = getDisplayedDescendants(currentChildren, 1); if (displayedDescendants) displayedChildren = displayedDescendants; } From 1e475a2ed1a5b6476374a409f39047242fdceb8b Mon Sep 17 00:00:00 2001 From: Igor Nadj Date: Tue, 6 Sep 2022 12:21:21 +1000 Subject: [PATCH 4/6] Revert "Hotfix: MAUI-1228 prevent infinite loop" This reverts commit 3b51777a7c53d32269ba6e4ecfec98e79a1df66d. --- .../Map/DataVisualsLayer/InteractivePolygonLayer.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js index 95a7415bc6..f0188cfce1 100644 --- a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js +++ b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js @@ -111,9 +111,8 @@ const mapStateToProps = (state, ownProps) => { measureOrgUnits = selectMeasuresWithDisplayInfo(state, displayedMapOverlayCodes); const measureOrgUnitCodes = measureOrgUnits.map(orgUnit => orgUnit.organisationUnitCode); - const getDisplayedDescendants = (parents, depth) => { - if (depth > 5) return null; // prevent infinite loops - if (!Array.isArray(parents) || parents.length === 0) return null; + const getDisplayedDescendants = parents => { + if (!Array.isArray(parents) || parents.length === 0) return parents; const children = parents .map(area => selectOrgUnitChildren(state, area.organisationUnitCode)) @@ -131,10 +130,10 @@ const mapStateToProps = (state, ownProps) => { if (hasShadedPolygonChildren) return children; // otherwise look deeper - return getDisplayedDescendants(children, depth + 1); + return getDisplayedDescendants(children); }; - const displayedDescendants = getDisplayedDescendants(currentChildren, 1); + const displayedDescendants = getDisplayedDescendants(currentChildren); if (displayedDescendants) displayedChildren = displayedDescendants; } From aa699f0fb1c12158fa9e3462918a6d45bfa8a27e Mon Sep 17 00:00:00 2001 From: Igor Nadj Date: Tue, 6 Sep 2022 12:21:23 +1000 Subject: [PATCH 5/6] Revert "(hotfix) MAUI-1228 Map overlay look deeper for polygon data (#4145)" This reverts commit 461221106897439e2b63bd15878249965d744573. --- .../InteractivePolygonLayer.js | 35 +++++-------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js index f0188cfce1..bbc973660c 100644 --- a/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js +++ b/packages/web-frontend/src/containers/Map/DataVisualsLayer/InteractivePolygonLayer.js @@ -103,38 +103,21 @@ const mapStateToProps = (state, ownProps) => { const permanentLabels = selectAreRegionLabelsPermanent(state); // orginal data // If the org unit's grandchildren are polygons and have a measure, display grandchildren - // rather than children (recursive) + // rather than children let displayedChildren = currentChildren; let measureOrgUnits = []; if (selectHasPolygonMeasure(state)) { measureOrgUnits = selectMeasuresWithDisplayInfo(state, displayedMapOverlayCodes); const measureOrgUnitCodes = measureOrgUnits.map(orgUnit => orgUnit.organisationUnitCode); - - const getDisplayedDescendants = parents => { - if (!Array.isArray(parents) || parents.length === 0) return parents; - - const children = parents - .map(area => selectOrgUnitChildren(state, area.organisationUnitCode)) - .reduce((acc, val) => acc.concat(val), []); // equivelent to .flat(), for IE - if (children.length === 0) return null; - - // if this is the measure layer return it - const hasShadedPolygonChildren = - children && - children.some( - child => - organisationUnitIsArea(child) && - measureOrgUnitCodes.includes(child.organisationUnitCode), - ); - if (hasShadedPolygonChildren) return children; - - // otherwise look deeper - return getDisplayedDescendants(children); - }; - - const displayedDescendants = getDisplayedDescendants(currentChildren); - if (displayedDescendants) displayedChildren = displayedDescendants; + const grandchildren = currentChildren + .map(area => selectOrgUnitChildren(state, area.organisationUnitCode)) + .reduce((acc, val) => acc.concat(val), []); // equivelent to .flat(), for IE + + const hasShadedGrandchildren = + grandchildren && + grandchildren.some(child => measureOrgUnitCodes.includes(child.organisationUnitCode)); + if (hasShadedGrandchildren) displayedChildren = grandchildren; } const getChildren = organisationUnitCode => selectOrgUnitChildren(state, organisationUnitCode); From d7350d9d8e1e826b977ed5e1a9ddf71626d1e1af Mon Sep 17 00:00:00 2001 From: Igor Nadj Date: Tue, 6 Sep 2022 12:22:16 +1000 Subject: [PATCH 6/6] Revert "MAUI-4136 Add facilities to penfaa project (#4136)" This reverts commit 81f1d0c60025cee835e1411555086e24f5c95129. --- ...42432-AddFacilitiesPenfaa-modifies-data.js | 137 ------------------ 1 file changed, 137 deletions(-) delete mode 100644 packages/database/src/migrations/20220901042432-AddFacilitiesPenfaa-modifies-data.js diff --git a/packages/database/src/migrations/20220901042432-AddFacilitiesPenfaa-modifies-data.js b/packages/database/src/migrations/20220901042432-AddFacilitiesPenfaa-modifies-data.js deleted file mode 100644 index fdb073b53e..0000000000 --- a/packages/database/src/migrations/20220901042432-AddFacilitiesPenfaa-modifies-data.js +++ /dev/null @@ -1,137 +0,0 @@ -'use strict'; - -const { generateId, nameToId } = require('../utilities'); - -var dbm; -var type; -var seed; - -/** - * We receive the dbmigrate dependency from dbmigrate initially. - * This enables us to not have to rely on NODE_PATH. - */ -exports.setup = function (options, seedLink) { - dbm = options.dbmigrate; - type = dbm.dataType; - seed = seedLink; -}; - -// Current hierarchy -// country -// |- district -// |- sub_district -// |- ... - -// New hierarchy -// country -// |- district -// |- facility <-- add facilities to alt. hierarchy. All facilities already exist. -// |- sub_district -// |- ... - -const HIERARCHY_CODE = 'penfaa_samoa'; - -// a subset of facilities in Samoa -const FACILITIES = [ - // parent_code code - ['WS_Upolu', 'WS_001'], - ['WS_Savaii', 'WS_002'], - ['WS_Upolu', 'WS_003'], - ['WS_Upolu', 'WS_004'], - ['WS_Upolu', 'WS_005'], - ['WS_Savaii', 'WS_006'], - ['WS_Upolu', 'WS_007'], - ['WS_Upolu', 'WS_008'], - ['WS_Savaii', 'WS_009'], - ['WS_Savaii', 'WS_011'], - ['WS_Savaii', 'WS_012'], - ['WS_Upolu', 'WS_014'], -]; - -const SUB_DISTRICTS = [ - // parent_code code - ['WS_004', 'WS_sd01'], - ['WS_004', 'WS_sd02'], - ['WS_004', 'WS_sd03'], - ['WS_004', 'WS_sd04'], - ['WS_001', 'WS_sd05'], - ['WS_011', 'WS_sd06'], - ['WS_003', 'WS_sd07'], - ['WS_003', 'WS_sd08'], - ['WS_005', 'WS_sd09'], - ['WS_005', 'WS_sd10'], - ['WS_006', 'WS_sd11'], - ['WS_006', 'WS_sd12'], - ['WS_006', 'WS_sd13'], - ['WS_006', 'WS_sd14'], - ['WS_006', 'WS_sd15'], - ['WS_007', 'WS_sd16'], - ['WS_007', 'WS_sd17'], - ['WS_011', 'WS_sd18'], - ['WS_014', 'WS_sd19'], - ['WS_014', 'WS_sd20'], - ['WS_014', 'WS_sd21'], - ['WS_014', 'WS_sd22'], - ['WS_001', 'WS_sd23'], - ['WS_009', 'WS_sd24'], - ['WS_009', 'WS_sd25'], - ['WS_009', 'WS_sd26'], - ['WS_009', 'WS_sd27'], - ['WS_009', 'WS_sd28'], - ['WS_008', 'WS_sd29'], - ['WS_003', 'WS_sd30'], - ['WS_003', 'WS_sd31'], - ['WS_002', 'WS_sd32'], - ['WS_012', 'WS_sd33'], - ['WS_012', 'WS_sd34'], - ['WS_008', 'WS_sd35'], - ['WS_008', 'WS_sd36'], - ['WS_004', 'WS_sd37'], - ['WS_004', 'WS_sd38'], - ['WS_004', 'WS_sd39'], - ['WS_004', 'WS_sd40'], - ['WS_002', 'WS_sd41'], - ['WS_002', 'WS_sd42'], - ['WS_012', 'WS_sd43'], - ['WS_008', 'WS_sd44'], - ['WS_005', 'WS_sd45'], - ['WS_014', 'WS_sd46'], - ['WS_014', 'WS_sd47'], - ['WS_014', 'WS_sd48'], - ['WS_014', 'WS_sd49'], - ['WS_011', 'WS_sd50'], - ['WS_011', 'WS_sd51'], -]; - -exports.up = async function (db) { - const entityHierarchyId = await nameToId(db, 'entity_hierarchy', HIERARCHY_CODE); - - for (const [parentSubDistrictCode, facilityCode] of FACILITIES) { - await db.runSql(` - INSERT INTO entity_relation (id, parent_id, child_id, entity_hierarchy_id) - VALUES ( - '${generateId()}', - (SELECT id FROM entity WHERE code = '${parentSubDistrictCode}'), - (SELECT id FROM entity WHERE code = '${facilityCode}'), - '${entityHierarchyId}' - ) - `); - } - - for (const [parentFacilityCode, subDistrictCode] of SUB_DISTRICTS) { - await db.runSql(` - UPDATE entity_relation - SET parent_id = (SELECT id FROM entity WHERE code = '${parentFacilityCode}') - WHERE child_id = (SELECT id FROM entity WHERE code = '${subDistrictCode}') - AND entity_hierarchy_id = '${entityHierarchyId}' - `); - } -}; - -exports.down = async function (db) { - return null; -}; - -exports._meta = { - version: 1, -};