Skip to content

Commit df530e2

Browse files
authored
fix: omit optionSetId from dataItems query on DHIS2 < v42 (#1839)
1 parent c372fa4 commit df530e2

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/api/dimensions.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ const recommendedDimensionsQuery = {
4646

4747
export const dataItemsQuery = {
4848
resource: 'dataItems',
49-
params: ({ nameProp, filter, searchTerm, page }) => {
50-
let fields = `id,${nameProp}~rename(name),dimensionItemType,expression,optionSetId`
49+
params: ({ nameProp, filter, searchTerm, page, supportsOptionSetId }) => {
50+
let fields = `id,${nameProp}~rename(name),dimensionItemType,expression${
51+
supportsOptionSetId ? ',optionSetId' : ''
52+
}`
5153
const filters = []
5254

5355
// TODO: Extract all of this logic out of the query?
@@ -289,6 +291,7 @@ export const apiFetchOptions = ({
289291
filter,
290292
searchTerm,
291293
page,
294+
supportsOptionSetId,
292295
}) => {
293296
switch (filter?.dataType) {
294297
case DIMENSION_TYPE_INDICATOR: {
@@ -335,6 +338,7 @@ export const apiFetchOptions = ({
335338
filter,
336339
searchTerm,
337340
page,
341+
supportsOptionSetId,
338342
})
339343
}
340344
}
@@ -433,6 +437,7 @@ const fetchDataItems = async ({
433437
filter,
434438
searchTerm,
435439
page,
440+
supportsOptionSetId,
436441
}) => {
437442
const dataItemsData = await dataEngine.query(
438443
{ dataItems: dataItemsQuery },
@@ -442,6 +447,7 @@ const fetchDataItems = async ({
442447
filter,
443448
searchTerm,
444449
page,
450+
supportsOptionSetId,
445451
},
446452
onError,
447453
}

src/components/DataDimension/DataDimension.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const DataDimension = ({
5656
const supportsEDI = dataTypes
5757
.map(({ id }) => id)
5858
.includes(DIMENSION_TYPE_EXPRESSION_DIMENSION_ITEM)
59+
const supportsOptionSetId = serverVersion.minor >= 42
5960

6061
const [currentCalculation, setCurrentCalculation] = useState()
6162
const [currentDataItem, setCurrentDataItem] = useState()
@@ -126,6 +127,7 @@ const DataDimension = ({
126127
dataTypes={dataTypes}
127128
itemsRef={itemsRef}
128129
supportsEDI={supportsEDI}
130+
supportsOptionSetId={supportsOptionSetId}
129131
onEDISave={onCalculationSave}
130132
isOptionViewMode={Boolean(currentDataItem)}
131133
currentCalculation={currentCalculation}

src/components/DataDimension/ItemSelector/ItemSelector.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const ItemSelector = ({
136136
onEditClick,
137137
isOptionViewMode,
138138
supportsEDI,
139+
supportsOptionSetId,
139140
height = TRANSFER_HEIGHT,
140141
heightCalculation,
141142
maxSelections,
@@ -176,6 +177,7 @@ const ItemSelector = ({
176177
page,
177178
filter: state.filter,
178179
searchTerm: state.searchTerm,
180+
supportsOptionSetId,
179181
})
180182
const newOptions = []
181183
result.dimensionItems?.forEach((item) => {
@@ -492,6 +494,7 @@ ItemSelector.propTypes = {
492494
setCurrentCalculation: PropTypes.func,
493495
setInfoDataItem: PropTypes.func,
494496
supportsEDI: PropTypes.bool,
497+
supportsOptionSetId: PropTypes.bool,
495498
onEDISave: PropTypes.func,
496499
onEditClick: PropTypes.func,
497500
}

0 commit comments

Comments
 (0)