diff --git a/src/components/sectionList/filters/filterSelectors/Filters.module.css b/src/components/sectionList/filters/filterSelectors/Filters.module.css index 6363b729..e885104f 100644 --- a/src/components/sectionList/filters/filterSelectors/Filters.module.css +++ b/src/components/sectionList/filters/filterSelectors/Filters.module.css @@ -12,7 +12,7 @@ } .identifiableSelectionFilter { - width: 320px; + width: 320px !important; } .filterWrapper { diff --git a/src/components/sectionList/listView/ManageListView.tsx b/src/components/sectionList/listView/ManageListView.tsx index 83b38cd0..d615250f 100644 --- a/src/components/sectionList/listView/ManageListView.tsx +++ b/src/components/sectionList/listView/ManageListView.tsx @@ -75,6 +75,7 @@ export const ManageListView = ({ filtersConfig, } }, [section.name]) + const hasAvailableFilters = filtersConfig.available.length > 0 const handleSave = async (values: FormValues) => { const isDefault = (arr: string[], def: string[]) => @@ -133,12 +134,16 @@ export const ManageListView = ({ > {i18n.t('Columns')} - handleChangeTab('filters', e)} - > - {i18n.t('Filters')} - + {hasAvailableFilters && ( + + handleChangeTab('filters', e) + } + > + {i18n.t('Filters')} + + )} @@ -148,12 +153,12 @@ export const ManageListView = ({ selectedLabel={i18n.t('Selected columns')} loading={query.isLoading} defaultOptions={defaultColumns} - availableOptions={columnsConfig.available.map( - (c) => ({ + availableOptions={columnsConfig.available + .map((c) => ({ label: c.label, value: c.path, - }) - )} + })) + .sort((a, b) => a.label.localeCompare(b.label))} /> @@ -163,12 +168,12 @@ export const ManageListView = ({ selectedLabel={i18n.t('Selected filters')} loading={query.isLoading} defaultOptions={defaultFilters} - availableOptions={filtersConfig.available.map( - (f) => ({ + availableOptions={filtersConfig.available + .map((f) => ({ label: f.label, value: f.filterKey, - }) - )} + })) + .sort((a, b) => a.label.localeCompare(b.label))} /> {submitError && ( diff --git a/src/lib/constants/translatedModelProperties.ts b/src/lib/constants/translatedModelProperties.ts index 702d87ac..8916498e 100644 --- a/src/lib/constants/translatedModelProperties.ts +++ b/src/lib/constants/translatedModelProperties.ts @@ -2,6 +2,7 @@ import i18n from '@dhis2/d2-i18n' const TRANSLATED_PROPERTY: Record = { aggregationType: i18n.t('Aggregation type'), + category: i18n.t('Category'), categoryCombo: i18n.t('Category combination'), categoryOption: i18n.t('Category option'), code: i18n.t('Code'), @@ -11,6 +12,7 @@ const TRANSLATED_PROPERTY: Record = { formName: i18n.t('Form name'), href: i18n.t('API URL'), id: i18n.t('Id'), + indicatorType: i18n.t('Indicator type'), lastUpdatedBy: i18n.t('Last updated by'), created: i18n.t('Created'), domainType: i18n.t('Domain type'), diff --git a/src/lib/sectionList/listViews/sectionListViewsConfig.ts b/src/lib/sectionList/listViews/sectionListViewsConfig.ts index 7265f060..ca6a2f8e 100644 --- a/src/lib/sectionList/listViews/sectionListViewsConfig.ts +++ b/src/lib/sectionList/listViews/sectionListViewsConfig.ts @@ -46,23 +46,31 @@ const DESCRIPTORS = { label: i18n.t('Public access'), filterKey: 'publicAccess', }, + name: { + path: 'displayName', + label: i18n.t('Name'), + }, + shortName: { + path: 'displayShortName', + label: i18n.t('Short name'), + }, } satisfies Record // This is the default views, and can be overriden per section in modelListViewsConfig below export const defaultModelViewConfig = { columns: { available: [ - 'name', - 'shortName', + DESCRIPTORS.name, 'code', 'created', 'createdBy', 'href', 'id', 'lastUpdatedBy', + 'lastUpdated', DESCRIPTORS.publicAccess, ], - default: ['name', DESCRIPTORS.publicAccess, 'lastUpdated'], + default: [DESCRIPTORS.name, DESCRIPTORS.publicAccess, 'lastUpdated'], }, filters: { available: [DESCRIPTORS.publicAccess], @@ -73,6 +81,11 @@ export const defaultModelViewConfig = { }, } satisfies ViewConfig +const defaultAvailableColumnsNoSharing = + defaultModelViewConfig.columns.available.filter( + (col) => col !== DESCRIPTORS.publicAccess + ) + /* this is the default views (eg. which columns and filters) to show in the List-page for each section Note: by default, the available columns are merged with columnsDefault.available above. If it's needed to override this for a section, set overrideDefaultAvailable to true @@ -83,9 +96,9 @@ export const defaultModelViewConfig = { export const modelListViewsConfig = { dataElement: { columns: { - available: ['zeroIsSignificant'], + available: [DESCRIPTORS.shortName, 'zeroIsSignificant'], default: [ - 'name', + DESCRIPTORS.name, { label: i18n.t('Domain type'), path: 'domainType' }, { label: i18n.t('Value type'), path: 'valueType' }, 'categoryCombo', @@ -98,15 +111,28 @@ export const modelListViewsConfig = { default: ['domainType', 'valueType', 'dataSet', 'categoryCombo'], }, }, + dataElementGroup: { + columns: { + available: [DESCRIPTORS.shortName], + }, + filters: {}, + }, + dataElementGroupSet: { + columns: { + available: [DESCRIPTORS.shortName], + }, + filters: {}, + }, dataSet: { columns: { default: [ - 'name', + DESCRIPTORS.name, { label: i18n.t('Form type'), path: 'formType' }, { label: i18n.t('Period type'), path: 'periodType' }, 'lastUpdated', DESCRIPTORS.publicAccess, ], + available: [DESCRIPTORS.shortName], }, filters: { default: ['formType'], @@ -114,8 +140,8 @@ export const modelListViewsConfig = { }, organisationUnit: { columns: { - available: [], - default: ['name', 'id', 'code', 'lastUpdated'], + available: [DESCRIPTORS.shortName], + default: [DESCRIPTORS.name, 'id', 'code', 'lastUpdated'], }, filters: { default: [], @@ -124,7 +150,8 @@ export const modelListViewsConfig = { categoryOption: { columns: { available: [ - 'name', + DESCRIPTORS.name, + DESCRIPTORS.shortName, 'code', 'created', 'createdBy', @@ -132,7 +159,11 @@ export const modelListViewsConfig = { 'id', DESCRIPTORS.publicAccess, ], - default: ['name', DESCRIPTORS.publicAccess, 'lastUpdated'], + default: [ + DESCRIPTORS.name, + DESCRIPTORS.publicAccess, + 'lastUpdated', + ], overrideDefaultAvailable: true, }, filters: { @@ -142,11 +173,12 @@ export const modelListViewsConfig = { category: { columns: { default: [ - 'name', + DESCRIPTORS.name, 'dataDimensionType', DESCRIPTORS.publicAccess, 'lastUpdated', ], + available: [DESCRIPTORS.shortName], }, filters: { default: ['dataDimensionType', 'categoryCombo'], @@ -155,11 +187,12 @@ export const modelListViewsConfig = { indicator: { columns: { default: [ - 'name', - { label: i18n.t('Indicator Type'), path: 'indicatorType' }, + DESCRIPTORS.name, + 'indicatorType', DESCRIPTORS.publicAccess, 'lastUpdated', ], + available: [DESCRIPTORS.shortName], }, filters: { default: ['indicatorType'], @@ -168,31 +201,28 @@ export const modelListViewsConfig = { indicatorType: { columns: { default: [ - 'name', + DESCRIPTORS.name, { label: i18n.t('Factor'), path: 'factor' }, 'lastUpdated', ], - available: [ - 'code', - 'created', - 'createdBy', - 'href', - 'id', - 'lastUpdatedBy', - ], + available: defaultAvailableColumnsNoSharing, + overrideDefaultAvailable: true, }, filters: { default: [], + available: [], + overrideDefaultAvailable: true, }, }, categoryOptionGroupSet: { columns: { default: [ - 'name', + DESCRIPTORS.name, 'dataDimensionType', DESCRIPTORS.publicAccess, 'lastUpdated', ], + available: [DESCRIPTORS.shortName], }, filters: { default: ['dataDimensionType'], @@ -201,11 +231,12 @@ export const modelListViewsConfig = { categoryOptionGroup: { columns: { default: [ - 'name', + DESCRIPTORS.name, 'dataDimensionType', DESCRIPTORS.publicAccess, 'lastUpdated', ], + available: [DESCRIPTORS.shortName], }, filters: { default: ['dataDimensionType'], @@ -214,7 +245,7 @@ export const modelListViewsConfig = { categoryCombo: { columns: { default: [ - 'name', + DESCRIPTORS.name, 'dataDimensionType', DESCRIPTORS.publicAccess, 'lastUpdated', @@ -227,8 +258,8 @@ export const modelListViewsConfig = { }, categoryOptionCombo: { columns: { - default: ['name', 'code', 'lastUpdated'], - available: ['categoryCombo', 'ignoreApproval'], + default: [DESCRIPTORS.name, 'code', 'lastUpdated'], + available: defaultAvailableColumnsNoSharing, // categoryOptionCombo does not have publicAccess overrideDefaultAvailable: true, }, diff --git a/src/pages/dataElements/List.spec.tsx b/src/pages/dataElements/List.spec.tsx index 9c65f1ed..22a18298 100644 --- a/src/pages/dataElements/List.spec.tsx +++ b/src/pages/dataElements/List.spec.tsx @@ -172,7 +172,7 @@ describe('Data Elements List', () => { dataElements: [ { ...FIRST_FILTERED_DATA_ELEMENT, - name: 'first page result', + displayName: 'first page result', }, ], } @@ -186,7 +186,7 @@ describe('Data Elements List', () => { dataElements: [ { ...FIRST_FILTERED_DATA_ELEMENT, - name: 'second page result', + displayName: 'second page result', }, ], } @@ -218,7 +218,7 @@ describe('Data Elements List', () => { ).toHaveAttribute('disabled') }) // next page - it('should allowing going to Next page', async () => { + it('should allow going to Next page', async () => { const user = userEvent.setup() const { getByTestId, findByText, queryByText } = await renderWithPager() @@ -270,7 +270,7 @@ describe('Data Elements List', () => { result: [ { ...FIRST_FILTERED_DATA_ELEMENT, - name: 'last page result', + displayName: 'last page result', }, ], }, diff --git a/src/pages/dataElements/__mocks__/list/dataElementsMock.json b/src/pages/dataElements/__mocks__/list/dataElementsMock.json index 274e6248..8d028fc8 100644 --- a/src/pages/dataElements/__mocks__/list/dataElementsMock.json +++ b/src/pages/dataElements/__mocks__/list/dataElementsMock.json @@ -9,6 +9,7 @@ "dataElements": [ { "name": "ANC 1st visit", + "displayName": "ANC 1st visit", "lastUpdated": "2017-03-02T16:52:07.101", "sharing": { "public": "r-------" @@ -31,6 +32,7 @@ }, { "name": "ANC 2nd visit", + "displayName": "ANC 2nd visit", "lastUpdated": "2024-03-05T22:55:32.803", "sharing": { "public": "r-------" @@ -53,6 +55,7 @@ }, { "name": "ANC 3rd visit", + "displayName": "ANC 3rd visit", "lastUpdated": "2024-03-05T23:09:47.216", "sharing": { "public": "r-------" @@ -75,6 +78,7 @@ }, { "name": "ANC 4th or more visits", + "displayName": "ANC 4th or more visits", "lastUpdated": "2024-03-05T09:48:09.192", "sharing": { "public": "rw------" @@ -97,6 +101,7 @@ }, { "name": "ARI treated with antibiotics (pneumonia) follow-up", + "displayName": "ARI treated with antibiotics (pneumonia) follow-up", "lastUpdated": "2024-03-05T23:10:04.850", "sharing": { "public": "rw------" @@ -119,6 +124,7 @@ }, { "name": "ARI treated with antibiotics (pneumonia) new", + "displayName": "ARI treated with antibiotics (pneumonia) new", "lastUpdated": "2024-03-05T22:52:47.886", "sharing": { "public": "r-------" @@ -141,6 +147,7 @@ }, { "name": "ARI treated with antibiotics (pneumonia) referrals", + "displayName": "ARI treated with antibiotics (pneumonia) referrals", "lastUpdated": "2024-03-05T09:48:09.193", "sharing": { "public": "rw------" @@ -163,6 +170,7 @@ }, { "name": "ARI treated without antibiotics (cough) follow-up", + "displayName": "ARI treated without antibiotics (cough) follow-up", "lastUpdated": "2024-03-05T09:48:09.191", "sharing": { "public": "rw------" @@ -185,6 +193,7 @@ }, { "name": "ARI treated without antibiotics (cough) new", + "displayName": "ARI treated without antibiotics (cough) new", "lastUpdated": "2024-03-05T09:48:09.194", "sharing": { "public": "rw------" @@ -207,6 +216,7 @@ }, { "name": "ARI treated without antibiotics (cough) referrals", + "displayName": "ARI treated without antibiotics (cough) referrals", "lastUpdated": "2024-03-05T09:48:09.191", "sharing": { "public": "rw------" @@ -229,6 +239,7 @@ }, { "name": "ART No clients who stopped TRT due to TRT failure", + "displayName": "ART No clients who stopped TRT due to TRT failure", "lastUpdated": "2024-03-05T09:48:09.194", "sharing": { "public": "rw------" @@ -251,6 +262,7 @@ }, { "name": "ART No clients who stopped TRT due to adverse clinical status/event", + "displayName": "ART No clients who stopped TRT due to adverse clinical status/event", "lastUpdated": "2024-03-05T09:48:09.191", "sharing": { "public": "rw------" @@ -273,6 +285,7 @@ }, { "name": "ART No clients with change of regimen due to drug toxicity", + "displayName": "ART No clients with change of regimen due to drug toxicity", "lastUpdated": "2024-03-05T09:48:09.195", "sharing": { "public": "rw------" @@ -295,6 +308,7 @@ }, { "name": "ART No clients with new adverse drug reaction", + "displayName": "ART No clients with new adverse drug reaction", "lastUpdated": "2024-03-05T09:48:09.191", "sharing": { "public": "rw------" @@ -317,6 +331,7 @@ }, { "name": "ART No started Opportunist Infection prophylaxis", + "displayName": "ART No started Opportunist Infection prophylaxis", "lastUpdated": "2024-03-05T09:48:09.191", "sharing": { "public": "rw------" @@ -339,6 +354,7 @@ }, { "name": "ART clients with new adverse clinical event", + "displayName": "ART clients with new adverse clinical event", "lastUpdated": "2024-03-05T09:48:09.192", "sharing": { "public": "rw------" @@ -361,6 +377,7 @@ }, { "name": "ART defaulters", + "displayName": "ART defaulters", "lastUpdated": "2024-03-05T09:48:09.192", "sharing": { "public": "rw------" @@ -383,6 +400,7 @@ }, { "name": "ART enrollment stage 1", + "displayName": "ART enrollment stage 1", "lastUpdated": "2024-03-05T09:48:09.194", "sharing": { "public": "rw------" @@ -405,6 +423,7 @@ }, { "name": "ART enrollment stage 2", + "displayName": "ART enrollment stage 2", "lastUpdated": "2024-03-05T09:48:09.190", "sharing": { "public": "rw------" @@ -427,6 +446,7 @@ }, { "name": "ART enrollment stage 3", + "displayName": "ART enrollment stage 3", "lastUpdated": "2024-03-05T09:48:09.193", "sharing": { "public": "rw------" diff --git a/src/pages/dataElements/__mocks__/list/filteredDataElementsMock.json b/src/pages/dataElements/__mocks__/list/filteredDataElementsMock.json index 55d6c2dd..465bc685 100644 --- a/src/pages/dataElements/__mocks__/list/filteredDataElementsMock.json +++ b/src/pages/dataElements/__mocks__/list/filteredDataElementsMock.json @@ -17,6 +17,7 @@ }, "id": "JuTpJ2Ywq5b", "name": "FILTERED Age of LLINs", + "displayName": "FILTERED Age of LLINs", "domainType": "TRACKER", "valueType": "INTEGER_ZERO_OR_POSITIVE", "lastUpdated": "2019-08-21T13:08:02.032",