diff --git a/i18n/en.pot b/i18n/en.pot index e33f84d5d..ab7b91dfb 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -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: 2020-02-09T01:43:57.112Z\n" -"PO-Revision-Date: 2020-02-09T01:43:57.112Z\n" +"POT-Creation-Date: 2020-02-12T20:02:08.021Z\n" +"PO-Revision-Date: 2020-02-12T20:02:08.021Z\n" msgid "Dashboard" msgstr "" @@ -127,12 +127,15 @@ msgstr "" msgid "Share" msgstr "" -msgid "Pivot tables" +msgid "Visualizations" msgstr "" msgid "Visualizer" msgstr "" +msgid "Pivot tables" +msgstr "" + msgid "Charts" msgstr "" diff --git a/package.json b/package.json index a74020e77..87aedb1e9 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "name": "DHIS2" }, "dhis2": { - "apiVersion": "31" + "apiVersion": "34" }, "activities": { "dhis": { diff --git a/src/components/Item/Item.js b/src/components/Item/Item.js index 2ceb3f9d8..8082941a6 100644 --- a/src/components/Item/Item.js +++ b/src/components/Item/Item.js @@ -10,6 +10,7 @@ import AppItem from './AppItem/Item'; import SpacerItem from './SpacerItem/Item'; import { APP, + VISUALIZATION, REPORT_TABLE, CHART, MAP, @@ -26,6 +27,7 @@ import { DEFAULT_STATE_ITEM_FILTERS } from '../../reducers/itemFilters'; const getGridItem = type => { switch (type) { + case VISUALIZATION: case REPORT_TABLE: case CHART: case MAP: diff --git a/src/components/Item/VisualizationItem/Item.js b/src/components/Item/VisualizationItem/Item.js index df270147b..90fa8cee8 100644 --- a/src/components/Item/VisualizationItem/Item.js +++ b/src/components/Item/VisualizationItem/Item.js @@ -20,6 +20,7 @@ import { acSetActiveVisualizationType, } from '../../../actions/visualizations'; import { + VISUALIZATION, MAP, CHART, REPORT_TABLE, @@ -145,6 +146,7 @@ export class Item extends Component { }; switch (activeType) { + case VISUALIZATION: case CHART: case REPORT_TABLE: { return ( diff --git a/src/components/Item/VisualizationItem/plugin.js b/src/components/Item/VisualizationItem/plugin.js index d78a390aa..b508d365d 100644 --- a/src/components/Item/VisualizationItem/plugin.js +++ b/src/components/Item/VisualizationItem/plugin.js @@ -42,27 +42,17 @@ export const extractFavorite = item => { return null; } - switch (item.type) { - case REPORT_TABLE: - return item.reportTable; - case CHART: - return item.chart; - case MAP: - return item.map; - case EVENT_REPORT: - return item.eventReport; - case EVENT_CHART: - return item.eventChart; - default: - return ( - item.reportTable || - item.chart || - item.map || - item.eventReport || - item.eventChart || - {} - ); - } + const propName = itemTypeMap[item.type].propName; + + return ( + item[propName] || + (item.reportTable || + item.chart || + item.map || + item.eventReport || + item.eventChart || + {}) + ); }; export const extractMapView = map => diff --git a/src/components/ItemSelector/CategorizedMenuGroup.js b/src/components/ItemSelector/CategorizedMenuGroup.js index bbf72b0b6..58b8d6f8c 100644 --- a/src/components/ItemSelector/CategorizedMenuGroup.js +++ b/src/components/ItemSelector/CategorizedMenuGroup.js @@ -9,7 +9,7 @@ import ContentMenuItem from './ContentMenuItem'; import { tAddListItemContent } from './actions'; import { acAddDashboardItem } from '../../actions/editDashboard'; -import { getItemUrl, APP } from '../../modules/itemTypes'; +import { getItemUrl, APP, VISUALIZATION } from '../../modules/itemTypes'; import { categorizedItems, listItemTypes } from './selectableItems'; import classes from './styles/CategorizedMenuGroup.module.css'; @@ -59,6 +59,7 @@ class CategorizedMenuGroup extends Component { ( ); -const ContentMenuItem = ({ type, name, onInsert, url }) => { +const ContentMenuItem = ({ type, name, onInsert, url, visType }) => { const ItemIcon = getItemIcon(type); + const renderedItemIcon = + type === VISUALIZATION ? ( + visTypeIcons[visType] + ) : ( + + ); + return ( { label={
- + + {renderedItemIcon} + {name} {url ? : null}
@@ -55,6 +63,7 @@ ContentMenuItem.propTypes = { name: PropTypes.string, type: PropTypes.string, url: PropTypes.string, + visType: PropTypes.string, onInsert: PropTypes.func, }; diff --git a/src/components/ItemSelector/ItemSelector.js b/src/components/ItemSelector/ItemSelector.js index b551df8b0..954739b45 100644 --- a/src/components/ItemSelector/ItemSelector.js +++ b/src/components/ItemSelector/ItemSelector.js @@ -7,7 +7,7 @@ import { InputField, Menu } from '@dhis2/ui-core'; import CategorizedMenuGroup from './CategorizedMenuGroup'; import SinglesMenuGroup from './SinglesMenuGroup'; import { singleItems, categorizedItems } from './selectableItems'; -import { itemTypeMap } from '../../modules/itemTypes'; +import { itemTypeMap, getDefaultItemCount } from '../../modules/itemTypes'; import './styles/ItemSelector.css'; @@ -62,11 +62,12 @@ class ItemSelector extends React.Component { }) .map(type => { const itemType = itemTypeMap[type]; + const itemCount = getDefaultItemCount(type); const allItems = this.state.items[itemType.endPointName]; - const hasMore = allItems.length > 5; + const hasMore = allItems.length > itemCount; const items = this.state.maxOptions.has(itemType.id) ? allItems - : allItems.slice(0, 5); + : allItems.slice(0, itemCount); return ( item.type === TEXT && item.text !== spacerContent; export const isVisualizationType = item => !!itemTypeMap[item.type].isVisualizationType; - export const hasMapView = itemType => itemTypeMap[itemType].domainType === DOMAIN_TYPE_AGGREGATE; - export const isTrackerDomainType = itemType => itemTypeMap[itemType].domainType === DOMAIN_TYPE_TRACKER; +export const getDefaultItemCount = itemType => + itemTypeMap[itemType].defaultItemCount || 5; // Item type map export const itemTypeMap = { + [VISUALIZATION]: { + id: VISUALIZATION, + endPointName: 'visualizations', + propName: 'visualization', + pluralTitle: i18n.t('Visualizations'), + appUrl: id => `dhis-web-data-visualizer/#/${id}`, + appName: i18n.t('Visualizer'), + defaultItemCount: 10, + }, [REPORT_TABLE]: { id: REPORT_TABLE, endPointName: 'reportTables',