Skip to content

Commit

Permalink
fix: fetch repetition data for LL to show in plugin (#2271) (#2281)
Browse files Browse the repository at this point in the history
* fix: fetch repetition data for LL to show in plugin

* chore: add PR template

(cherry picked from commit 25378ce)
  • Loading branch information
edoardo authored Apr 5, 2023
1 parent 38aaa83 commit 420f508
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
33 changes: 33 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Implements [DHIS2-XXXX](https://dhis2.atlassian.net/browse/DHIS2-XXXX)

**Requires https://github.com/dhis2/analytics/pull/XXX**

---

### Key features

1. _feature_

---

### Description

_text_

---

### TODO

- [ ] _task_

---

### Known issues

- [ ] _issue_

---

### Screenshots

_supporting text_
7 changes: 6 additions & 1 deletion src/api/fetchVisualization.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { getInstance } from 'd2'
import { getVisualizationId } from '../modules/item.js'
import { getEndPointName, MAP } from '../modules/itemTypes.js'
import {
getEndPointName,
MAP,
EVENT_VISUALIZATION,
} from '../modules/itemTypes.js'
import { getMapFields, getFavoriteFields } from './metadata.js'

export const apiFetchVisualization = async (item) => {
Expand All @@ -11,6 +15,7 @@ export const apiFetchVisualization = async (item) => {
: getFavoriteFields({
withDimensions: true,
withOptions: true,
withRepetition: item.type === EVENT_VISUALIZATION,
})

const d2 = await getInstance()
Expand Down
21 changes: 14 additions & 7 deletions src/api/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,36 @@ export const getItemFields = () => [
]

// Dimension
export const getDimensionFields = ({ withItems }) =>
export const getDimensionFields = ({ withItems, withRepetition }) =>
arrayClean([
'dimension',
'legendSet[id]',
'filter',
'programStage',
withItems ? `items[${getItemFields().join(',')}]` : ``,
withRepetition ? 'repetition' : '',
])

// Axis
export const getAxesFields = ({ withItems }) => [
`columns[${getDimensionFields({ withItems }).join(',')}]`,
`rows[${getDimensionFields({ withItems }).join(',')}]`,
`filters[${getDimensionFields({ withItems }).join(',')}]`,
export const getAxesFields = ({ withItems, withRepetition }) => [
`columns[${getDimensionFields({ withItems, withRepetition }).join(',')}]`,
`rows[${getDimensionFields({ withItems, withRepetition }).join(',')}]`,
`filters[${getDimensionFields({ withItems, withRepetition }).join(',')}]`,
]

// Favorite
export const getFavoriteFields = ({ withDimensions, withOptions }) => {
export const getFavoriteFields = ({
withDimensions,
withOptions,
withRepetition,
}) => {
return arrayClean([
`${getIdNameFields({ rename: true }).join(',')}`,
'type',
'displayDescription~rename(description)',
withDimensions ? `${getAxesFields({ withItems: true }).join(',')}` : ``,
withDimensions
? `${getAxesFields({ withItems: true, withRepetition }).join(',')}`
: ``,
withOptions
? [
'*',
Expand Down

0 comments on commit 420f508

Please sign in to comment.