Skip to content

Commit

Permalink
feat: split view maps (#154)
Browse files Browse the repository at this point in the history
* Period display radio

* Period display redux

* Split view layout

* feat: synchronized maps

* Multiple thematic layers

* Values by period

* Split view data

* Period names

* Display period in feature popup

* Period label component

* Basemap code cleaning

* GIS API upgrade

* Don't allow last 52 weeks for split view maps

* Period handling

* Period handling

* Refacotring map instance logic

* Layer bounds handling

* Map sync refactoring

* Attribution

* Zoom control

* Use layer id to sync maps

* Map controls styling for split view

* Style fix

* Map controls refactoring

* Refactor Leaflet styles

* Rename periodDisplay to renderingStrategy

* Split view support for favorites

* Support id from URL in plugin.html

* Folder refactoring

* Refactoring

* New shared MapView component

* Plugin map name

* Initial map view

* Default bounds for plugin maps

* Code cleaning

* Only allow one split view layer

* Styling

* Disalbe split view if other layers

* Legend fixes

* Revert period component testing

* Fix rendering strategy bug

* GIS API dependency upgrade

* Disabled failing test for facility layer

* chore: re-add the flaky facilitylayer test assertions

* Don't print webpack progress when building for Netlify

* Run prebuild on netlify

* Review fixes

* Display period fix

* Fit to layer bounds on each update

* Add missing prop type check

* Remove obsolete MapProvider

* Always fit to layer bounds if map is not zoomed

* GIS API upgrade

* Version bump
  • Loading branch information
turban authored Jul 16, 2019
1 parent f3f88ce commit 2a81b0d
Show file tree
Hide file tree
Showing 52 changed files with 1,466 additions and 871 deletions.
58 changes: 29 additions & 29 deletions cypress/fixtures/boundarylayer.json

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions cypress/fixtures/eventlayer.json

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions cypress/fixtures/facilitylayer.json

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions cypress/fixtures/smoke.json

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions cypress/fixtures/thematiclayer.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cypress/integration/layers/facilitylayer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ context('Facility Layers', () => {
.should('have.length', 1)
.click();
cy.get('body').click(); // Close the modal menu

cy.get('[data-test="layeredit-addbtn"]').click();

cy.get('[data-test="facilitydialog"]')
.should('have.length', 0)
.should('not.be.visible');
Expand Down
13 changes: 11 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-05-29T09:55:15.600Z\n"
"PO-Revision-Date: 2019-05-29T09:55:15.600Z\n"
"POT-Creation-Date: 2019-07-10T01:37:46.780Z\n"
"PO-Revision-Date: 2019-07-10T01:37:46.780Z\n"

msgid "Maps"
msgstr ""
Expand Down Expand Up @@ -415,6 +415,9 @@ msgstr ""
msgid "deleted"
msgstr ""

msgid "Split view can not be combined with other layer types."
msgstr ""

msgid "Filters"
msgstr ""

Expand Down Expand Up @@ -541,9 +544,15 @@ msgstr ""
msgid "Next year"
msgstr ""

msgid "Relative"
msgstr ""

msgid "Period type"
msgstr ""

msgid "Remove other layers to enable split map view."
msgstr ""

msgid "Program indicator"
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maps-app",
"version": "33.0.2",
"version": "33.0.3",
"description": "DHIS2 Maps",
"main": "src/app.js",
"repository": {
Expand Down Expand Up @@ -34,7 +34,7 @@
"cy:e2e:open:update": "CYPRESS_GEN_FIXTURES=true cypress open",
"prebuild": "yarn test && yarn localize && yarn manifest && rm -rf build && mkdir build && cp -r public/* ./build/",
"build": "NODE_ENV=production webpack --progress",
"build:netlify": "yarn build && d2-manifest package.json build/manifest.webapp --manifest.activities.dhis.href=\"https://play.dhis2.org/dev\"",
"build:netlify": "yarn prebuild && NODE_ENV=production webpack && d2-manifest package.json build/manifest.webapp --manifest.activities.dhis.href=\"https://play.dhis2.org/dev\"",
"manifest": "d2-manifest package.json public/manifest.webapp",
"lint": "eslint ./src",
"validate": "npm ls --depth 0 || yarn list",
Expand All @@ -52,7 +52,7 @@
"@dhis2/d2-ui-interpretations": "6.1.0",
"@dhis2/d2-ui-org-unit-dialog": "5.2.10",
"@dhis2/d2-ui-org-unit-tree": "5.2.10",
"@dhis2/gis-api": "^32.0.22",
"@dhis2/gis-api": "^33.0.3",
"@dhis2/ui": "^1.0.0-beta.15",
"@material-ui/core": "^3.9.3",
"@material-ui/icons": "^3.0.2",
Expand Down
22 changes: 18 additions & 4 deletions public/plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,33 @@
mapPlugin.username = 'admin';
mapPlugin.password = 'district';

const mapId = new URL(window.location.href).searchParams.get('id');

if (mapId) {
mapPlugin.load({
id: mapId,
el: 'map'
});
picker.style.display = 'none';
mapContainer.style.display = 'block';
}

function onReloadBtnPress(e) {
let config = {}
try {
config = JSON.parse(document.getElementById('inputMapConfig').value);
const configJson = document.getElementById('inputMapConfig').value;

if (configJson) {
config = JSON.parse(configJson);
}
} catch (e) {
console.error(e)
}

const id = document.getElementById('inputMapID').value;

if (id && id.length) {
config.id = {
id
}
config.id = id;
}

config = Object.assign({
Expand Down
9 changes: 8 additions & 1 deletion src/actions/layerEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ export const setPeriodName = periodName => ({
});

// Set period type (thematic)
export const setPeriodType = periodType => ({
export const setPeriodType = (periodType, clearPeriod = true) => ({
type: types.LAYER_EDIT_PERIOD_TYPE_SET,
periodType,
clearPeriod,
});

// Set period (event & thematic)
Expand Down Expand Up @@ -339,3 +340,9 @@ export const setFollowUpStatus = checked => ({
type: types.LAYER_EDIT_FOLLOW_UP_SET,
payload: checked,
});

// Set display mode for periods
export const setRenderingStrategy = display => ({
type: types.LAYER_EDIT_RENDERING_STRATEGY_SET,
payload: display,
});
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ getManifest('manifest.webapp')
: DHIS_CONFIG.baseUrl;

config.appUrl = baseUrl; // Base url for switching between apps
config.baseUrl = `${baseUrl}/api/32`; // Base url for Web API requests
config.baseUrl = `${baseUrl}/api/33`; // Base url for Web API requests

config.context = manifest.activities.dhis; // Added temporarily for util/api.js

Expand Down
29 changes: 13 additions & 16 deletions src/components/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
import i18n from '@dhis2/d2-i18n';
import HeaderBar from '@dhis2/ui/widgets/HeaderBar';
import mui3theme from '@dhis2/d2-ui-core/theme/mui3.theme';
import MapProvider from '../map/MapProvider';
import AppMenu from './AppMenu';
import LayersPanel from '../layers/LayersPanel';
import LayersToggle from '../layers/LayersToggle';
import Map from '../map/Map';
import MapContainer from '../map/MapContainer';
import BottomPanel from '../datatable/BottomPanel';
import LayerEdit from '../edit/LayerEdit';
import ContextMenu from '../map/ContextMenu';
Expand Down Expand Up @@ -44,20 +43,18 @@ export class App extends Component {
<FatalErrorBoundary>
<HeaderBar appName={i18n.t('Maps')} />
<MuiThemeProvider theme={theme}>
<MapProvider>
<AppMenu />
<InterpretationsPanel />
<LayersPanel />
<LayersToggle />
<Map />
<BottomPanel />
<LayerEdit />
<ContextMenu />
<AlertSnackbar />
<Message />
<DataDownloadDialog />
<OpenAsMapDialog />
</MapProvider>
<AppMenu />
<InterpretationsPanel />
<LayersPanel />
<LayersToggle />
<MapContainer />
<BottomPanel />
<LayerEdit />
<ContextMenu />
<AlertSnackbar />
<Message />
<DataDownloadDialog />
<OpenAsMapDialog />
</MuiThemeProvider>
</FatalErrorBoundary>
);
Expand Down
18 changes: 17 additions & 1 deletion src/components/edit/thematic/ThematicDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import OrgUnitLevelSelect from '../../orgunits/OrgUnitLevelSelect';
import OrgUnitTree from '../../orgunits/OrgUnitTree';
import PeriodSelect from '../../periods/PeriodSelect';
import PeriodTypeSelect from '../../periods/PeriodTypeSelect';
import RenderingStrategy from '../../periods/RenderingStrategy';
import ProgramSelect from '../../program/ProgramSelect';
import ProgramIndicatorSelect from '../../program/ProgramIndicatorSelect';
import RelativePeriodSelect from '../../periods/RelativePeriodSelect';
Expand Down Expand Up @@ -51,6 +52,7 @@ import {
setOrgUnitGroups,
setPeriod,
setPeriodType,
setRenderingStrategy,
setStartDate,
setEndDate,
setProgram,
Expand Down Expand Up @@ -115,6 +117,7 @@ export class ThematicDialog extends Component {
startDate: PropTypes.string,
endDate: PropTypes.string,
periodType: PropTypes.string,
renderingStrategy: PropTypes.string,
radiusHigh: PropTypes.number,
radiusLow: PropTypes.number,
valueType: PropTypes.string,
Expand All @@ -136,6 +139,7 @@ export class ThematicDialog extends Component {
toggleOrgUnit: PropTypes.func.isRequired,
setUserOrgUnits: PropTypes.func.isRequired,
setPeriodType: PropTypes.func.isRequired,
setRenderingStrategy: PropTypes.func.isRequired,
setProgram: PropTypes.func.isRequired,
setRadiusLow: PropTypes.func.isRequired,
setRadiusHigh: PropTypes.func.isRequired,
Expand Down Expand Up @@ -226,6 +230,7 @@ export class ThematicDialog extends Component {
labelFontWeight,
operand,
periodType,
renderingStrategy,
startDate,
endDate,
program,
Expand All @@ -252,6 +257,7 @@ export class ThematicDialog extends Component {
setStartDate,
setEndDate,
setPeriodType,
setRenderingStrategy,
setProgram,
setRadiusLow,
setRadiusHigh,
Expand Down Expand Up @@ -440,7 +446,8 @@ export class ThematicDialog extends Component {
>
<PeriodTypeSelect
value={periodType}
onChange={type => setPeriodType(type.id)}
period={period}
onChange={setPeriodType}
style={styles.select}
errorText={periodTypeError}
/>
Expand Down Expand Up @@ -485,6 +492,14 @@ export class ThematicDialog extends Component {
</div>
) : null,
]}
{periodType === 'relativePeriods' && (
<RenderingStrategy
value={renderingStrategy}
period={period}
layerId={id}
onChange={setRenderingStrategy}
/>
)}
</div>
)}
{tab === 'orgunits' && (
Expand Down Expand Up @@ -768,6 +783,7 @@ export default connect(
setOrgUnitGroups,
setPeriod,
setPeriodType,
setRenderingStrategy,
setStartDate,
setEndDate,
setProgram,
Expand Down
11 changes: 2 additions & 9 deletions src/components/layers/basemaps/BasemapList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ const styles = {
},
};

const BasemapList = (
{ classes, selectedID, basemaps, selectBasemap },
{ map }
) => (
const BasemapList = ({ classes, selectedID, basemaps, selectBasemap }) => (
<div className={classes.container} data-test="basemaplist">
{basemaps
.filter(basemap => map.hasLayerSupport(basemap.config.type))
// .filter(basemap => map.hasLayerSupport(basemap.config.type))
.map((basemap, index) => (
<Basemap
key={`basemap-${index}`}
Expand All @@ -29,10 +26,6 @@ const BasemapList = (
</div>
);

BasemapList.contextTypes = {
map: PropTypes.object,
};

BasemapList.propTypes = {
classes: PropTypes.object.isRequired,
selectedID: PropTypes.string.isRequired,
Expand Down
Loading

0 comments on commit 2a81b0d

Please sign in to comment.