Skip to content

Commit

Permalink
fix: roll back and renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Feb 4, 2025
1 parent d5baa60 commit e306ae3
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const FEATURES = Object.freeze({
trackerImageEndpoint: 'trackerImageEndpoint',
trackerFileEndpoint: 'trackerFileEndpoint',
trackedEntitiesCSV: 'trackedEntitiesCSV',
newAocApiSeparator: 'newAocApiSeparator',
newUIDsSeparator: 'newUIDsSeparator',
newEntityFilterQueryParam: 'newEntityFilterQueryParam',
newNoteEndpoint: 'newNoteEndpoint',
newRelationshipQueryParam: 'newRelationshipQueryParam',
Expand All @@ -26,7 +26,7 @@ const MINOR_VERSION_SUPPORT = Object.freeze({
[FEATURES.newTransferQueryParam]: 41,
[FEATURES.changelogs]: 41,
[FEATURES.trackedEntitiesCSV]: 40,
[FEATURES.newAocApiSeparator]: 41,
[FEATURES.newUIDsSeparator]: 41,
[FEATURES.newEntityFilterQueryParam]: 41,
[FEATURES.newNoteEndpoint]: 42,
[FEATURES.newRelationshipQueryParam]: 41,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const getApiCategoriesArgument = (categories: ?{ [id: string]: string}, serverMi
if (!categories) {
return null;
}
const useNewSeparator = hasAPISupportForFeature(serverMinorVersion, FEATURES.newAocApiSeparator);
const newUIDsSeparator = hasAPISupportForFeature(serverMinorVersion, FEATURES.newUIDsSeparator);

return {
attributeCategoryOptions: Object
.keys(categories)

.map(key => categories[key])
.join(useNewSeparator ? ',' : ';'),
.join(newUIDsSeparator ? ',' : ';'),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ export const loadViewEventDataEntry =
let attributeCategoryOptions;

if (eventContainer.event && eventContainer.event.attributeCategoryOptions) {
const useNewAocApiSeparator = hasAPISupportForFeature(serverMinorVersion, FEATURES.newAocApiSeparator);
const newUIDsSeparator = hasAPISupportForFeature(serverMinorVersion, FEATURES.newUIDsSeparator);
// $FlowFixMe - this should work
const attributeCategoryOptionIds = eventContainer.event?.attributeCategoryOptions.split(useNewAocApiSeparator ? ',' : ';');
const attributeCategoryOptionIds = eventContainer.event?.attributeCategoryOptions.split(newUIDsSeparator ? ',' : ';');
const getCategoryOptionsFromIndexedDB = async (optionIds) => {
const categoryOptionsPromises = optionIds.map(async (optionId) => {
const cachedCategoryOption = await getCachedSingleResourceFromKeyAsync(userStores.CATEGORY_OPTIONS, optionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const getApiCategoriesQueryArgument = (categories: ?{ [id: string]: string}, cat
if (!categories || !categoryCombinationId) {
return null;
}
const newUIDsSeparator = featureAvailable(FEATURES.newAocApiSeparator);
const newUIDsSeparator = featureAvailable(FEATURES.newUIDsSeparator);
const { aCCQueryParam, aCOQueryParam }: { aCCQueryParam: string, aCOQueryParam: string } = featureAvailable(
FEATURES.newEntityFilterQueryParam,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const getEventListData = async (
};
}

const useNewSeparator = featureAvailable(FEATURES.newAocApiSeparator);
const useNewSeparator = featureAvailable(FEATURES.newUIDsSeparator);

const trackedEntityIds = apiEvents
.reduce((acc, { trackedEntity }) => (acc.includes(trackedEntity) ? acc : [...acc, trackedEntity]), [])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import { pipe, FEATURES, featureAvailable } from 'capture-core-utils';
import { pipe } from 'capture-core-utils';
import type { BooleanFilterData } from '../../../../../ListView';

const booleanFilterValues = {
Expand All @@ -12,10 +12,7 @@ export function convertBoolean(filter: BooleanFilterData) {
values => values.map(filterValue => booleanFilterValues[filterValue]),
values =>
(values.length > 1 ?
{
valueString: values.join(featureAvailable(FEATURES.newAocApiSeparator) ? ',' : ';'),
single: false,
} :
{ valueString: values.join(';'), single: false } :
{ valueString: values[0], single: true }
),
({ valueString, single }) => (single ? `eq:${valueString}` : `in:${valueString}`),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import { pipe, FEATURES, featureAvailable } from 'capture-core-utils';
import { pipe } from 'capture-core-utils';
import { convertDataTypeValueToRequest } from './basicDataTypeConverters';
import { typeof dataElementTypes } from '../../../../../../../metaData';
import type { OptionSetFilterData } from '../../../../../../ListView';
Expand All @@ -11,7 +11,7 @@ export function convertOptionSet(
) {
return pipe(
values => values.map(filterValue => escapeString(convertDataTypeValueToRequest(filterValue, type))),
values => values.join(featureAvailable(FEATURES.newAocApiSeparator) ? ',' : ';'),
values => values.join(';'),
valueString => `in:${valueString}`,
)(sourceValue.values);
}
2 changes: 1 addition & 1 deletion src/core_modules/capture-core/converters/clientToServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function convertCategoryOptionsToServer(
acc.push(value[categoryId]);
}
return acc;
}, []).join(hasAPISupportForFeature(serverMinorVersion, FEATURES.newAocApiSeparator) ? ',' : ';');
}, []).join(hasAPISupportForFeature(serverMinorVersion, FEATURES.newUIDsSeparator) ? ',' : ';');
}
return value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export const convertEventAttributeOptions = (event: Object, serverMinorVersion:
.filter(key => key.startsWith(`${attributeCategoryKey}-`));

if (editedAttributeOptions.length > 0) {
const useNewAocApiSeparator = hasAPISupportForFeature(serverMinorVersion, FEATURES.newAocApiSeparator);
const newUIDsSeparator = hasAPISupportForFeature(serverMinorVersion, FEATURES.newUIDsSeparator);
const newAttributeCategoryOptions = [];
editedAttributeOptions.forEach((key) => {
newAttributeCategoryOptions.push(event[key]);
delete event[key];
});
return {
...event,
attributeCategoryOptions: newAttributeCategoryOptions.join(useNewAocApiSeparator ? ',' : ';'),
attributeCategoryOptions: newAttributeCategoryOptions.join(newUIDsSeparator ? ',' : ';'),
};
}
return event;
Expand Down

0 comments on commit e306ae3

Please sign in to comment.