Skip to content

Commit

Permalink
feat: enable EVENT_VISUALIZATION dashboard item types
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Mar 2, 2023
1 parent 4f0abd8 commit 1dd409c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/api/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const getFavoritesFields = () => [
`map[${getFavoriteFields({ withDimensions: false }).join(',')}]`,
`eventReport[${getFavoriteFields({ withDimensions: false }).join(',')}]`,
`eventChart[${getFavoriteFields({ withDimensions: false }).join(',')}]`,
`eventVisualization[${getFavoriteFields({ withDimensions: false }).join(',')}]`,
]

// List item
Expand Down
2 changes: 2 additions & 0 deletions src/components/Item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
MAP,
EVENT_CHART,
EVENT_REPORT,
EVENT_VISUALIZATION,
MESSAGES,
REPORTS,
RESOURCES,
Expand Down Expand Up @@ -35,6 +36,7 @@ const getGridItem = (type) => {
case MAP:
case EVENT_CHART:
case EVENT_REPORT:
case EVENT_VISUALIZATION:
return VisualizationItem
case MESSAGES:
return MessagesItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
REPORT_TABLE,
EVENT_CHART,
EVENT_REPORT,
EVENT_VISUALIZATION,
isTrackerDomainType,
hasMapView,
} from '../../../../modules/itemTypes.js'
Expand Down Expand Up @@ -47,7 +48,7 @@ const ViewAsMenuItems = ({
icon={<IconVisualizationColumn16 />}
/>
)}
{activeType !== REPORT_TABLE && activeType !== EVENT_REPORT && (
{activeType !== REPORT_TABLE && activeType !== EVENT_REPORT && activeType !== EVENT_VISUALIZATION && (
<MenuItem
tooltip={
notSupported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
MAP,
EVENT_REPORT,
EVENT_CHART,
EVENT_VISUALIZATION,
} from '../../../../modules/itemTypes.js'
import getVisualizationContainerDomId from '../getVisualizationContainerDomId.js'
import { loadExternalScript } from './loadExternalScript.js'
Expand All @@ -23,7 +24,7 @@ const itemTypeToScriptPath = {
}

const hasIntegratedPlugin = (type) =>
[CHART, REPORT_TABLE, VISUALIZATION].includes(type)
[CHART, REPORT_TABLE, VISUALIZATION, EVENT_VISUALIZATION].includes(type)

export const getPlugin = async (type) => {
if (hasIntegratedPlugin(type)) {
Expand Down
5 changes: 4 additions & 1 deletion src/components/styles/ItemGrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}

.react-grid-item.edit,
.react-grid-item.EVENT_VISUALIZATION,
.react-grid-item.RESOURCES,
.react-grid-item.TEXT,
.react-grid-item.MESSAGES,
Expand Down Expand Up @@ -67,11 +68,13 @@
.CHART .dashboard-item-content,
.VISUALIZATION .dashboard-item-content,
.MAP .dashboard-item-content,
.EVENT_CHART .dashboard-item-content {
.EVENT_CHART .dashboard-item-content,
.EVENT_VISUALIZATION .dashboard-item-content {
overflow: hidden;
}

.react-grid-item.edit .dashboard-item-content,
.react-grid-item.EVENT_VISUALIZATION .dashboard-item-content,
.react-grid-item.RESOURCES .dashboard-item-content,
.react-grid-item.TEXT .dashboard-item-content,
.react-grid-item.MESSAGES .dashboard-item-content,
Expand Down
14 changes: 14 additions & 0 deletions src/modules/itemTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const CHART = 'CHART'
export const MAP = 'MAP'
export const EVENT_REPORT = 'EVENT_REPORT'
export const EVENT_CHART = 'EVENT_CHART'
export const EVENT_VISUALIZATION = 'EVENT_VISUALIZATION'
export const APP = 'APP'
export const REPORTS = 'REPORTS'
export const RESOURCES = 'RESOURCES'
Expand Down Expand Up @@ -123,6 +124,18 @@ export const itemTypeMap = {
appUrl: (id) => `dhis-web-event-visualizer/?id=${id}`,
appName: 'Event Visualizer',
},
[EVENT_VISUALIZATION]: {
id: EVENT_VISUALIZATION,
endPointName: 'eventVisualizations',
propName: 'eventVisualization',
pluralTitle: i18n.t('Event visualizations'),
domainType: DOMAIN_TYPE_TRACKER,
isVisualizationType: true,
// TODO change to the path for the bundled app
appUrl: (id) => `api/apps/line-listing/index.html#/${id}`,
appName: 'Line Listing',
appKey: 'line-listing',
},
[APP]: {
endPointName: 'apps',
propName: 'appKey',
Expand Down Expand Up @@ -206,6 +219,7 @@ export const getItemIcon = (type) => {
return IconFileDocument24
case CHART:
case EVENT_CHART:
case EVENT_VISUALIZATION:
return IconVisualizationColumn24
case MAP:
return IconWorld24
Expand Down
2 changes: 2 additions & 0 deletions src/pages/edit/ItemSelector/selectableItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
MAP,
EVENT_CHART,
EVENT_REPORT,
EVENT_VISUALIZATION,
REPORTS,
RESOURCES,
APP,
Expand Down Expand Up @@ -42,6 +43,7 @@ export const categorizedItems = [
MAP,
EVENT_REPORT,
EVENT_CHART,
EVENT_VISUALIZATION,
REPORTS,
RESOURCES,
APP,
Expand Down

0 comments on commit 1dd409c

Please sign in to comment.