Skip to content

Commit

Permalink
Merge pull request #5752 from beyondessential/release-2024-27
Browse files Browse the repository at this point in the history
Release 2024-27
  • Loading branch information
avaek authored Jul 7, 2024
2 parents accbcc4 + 9f2506b commit 0110eb2
Show file tree
Hide file tree
Showing 61 changed files with 2,442 additions and 804 deletions.
9 changes: 4 additions & 5 deletions packages/admin-panel/src/editor/FieldsEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export const FieldsEditor = ({ fields, recordData, onEditField, onSetFormFile })
if (accessor) {
return accessor(recordData);
}
if (editConfig.sourceKey) {
return recordData[editConfig.sourceKey];
}
return recordData[source];
};

Expand Down Expand Up @@ -123,11 +126,7 @@ export const FieldsEditor = ({ fields, recordData, onEditField, onSetFormFile })
return [...result, field];
}, []);

return (
<EditorWrapper className="fields">
{visibleFormItems.map(getFieldInput)}
</EditorWrapper>
);
return <EditorWrapper className="fields">{visibleFormItems.map(getFieldInput)}</EditorWrapper>;
};

FieldsEditor.propTypes = {
Expand Down
2 changes: 0 additions & 2 deletions packages/admin-panel/src/pages/resources/ResourcePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ ResourcePage.propTypes = {
exportConfig: PropTypes.object,
deleteConfig: PropTypes.object,
ExportModalComponent: PropTypes.elementType,
TableComponent: PropTypes.elementType,
LinksComponent: PropTypes.elementType,
title: PropTypes.string,
baseFilter: PropTypes.object,
Expand All @@ -179,7 +178,6 @@ ResourcePage.defaultProps = {
exportConfig: {},
deleteConfig: {},
ExportModalComponent: null,
TableComponent: null,
LinksComponent: null,
onProcessDataForSave: null,
title: null,
Expand Down
7 changes: 4 additions & 3 deletions packages/admin-panel/src/routes/projects/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,17 @@ const NEW_PROJECT_COLUMNS = [
},
...CREATE_FIELDS,
{
Header: 'Country code(s)',
Header: 'Countries',
source: 'country.code',
Filter: ArrayFilter,
Cell: ({ value }) => prettyArray(value),
editConfig: {
optionsEndpoint: 'countries',
optionLabelKey: 'country.code',
optionLabelKey: 'country.name',
optionValueKey: 'country.id',
sourceKey: 'countries',
allowMultipleValues: true,
pageSize: 'ALL',
type: 'checkboxList',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-panel/src/routes/surveys/dataMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const FIELDS = [
},
},
{
Header: 'Data service sonfiguration',
Header: 'Data service configuration',
source: 'service_config',
Cell: DataSourceConfigView,
editConfig: DATA_ELEMENT_FIELD_EDIT_CONFIG,
Expand Down
5 changes: 3 additions & 2 deletions packages/admin-panel/src/routes/surveys/surveys.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ const SURVEY_FIELDS = {
country_ids: {
Header: 'Countries',
source: 'countryNames', // TODO: cleanup as part of RN-910
required: true,
editConfig: {
type: 'checkboxList',
sourceKey: 'countryNames',
optionsEndpoint: 'countries',
optionLabelKey: 'name',
optionValueKey: 'name',
allowMultipleValues: true,
labelTooltip: 'Select the countries this survey should be available in',
required: true,
pageSize: 'ALL',
},
},
permission_group_id: {
Expand Down
25 changes: 16 additions & 9 deletions packages/admin-panel/src/routes/users/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ import { getPluralForm } from '../../pages/resources/resourceName';

const RESOURCE_NAME = { singular: 'permission' };

const EntityField = {
Header: 'Entity',
source: 'entity.name',
editConfig: {
optionsEndpoint: 'entities',
type: 'checkboxList',
baseFilter: { type: 'country' },
optionLabelKey: 'entity.name',
optionValueKey: 'entity.id',
allowMultipleValues: true,
labelTooltip: 'Select the countries for which this permission applies',
pageSize: 'ALL',
sourceKey: 'entity_id',
},
};
export const PERMISSIONS_ENDPOINT = 'userEntityPermissions';
export const PERMISSIONS_COLUMNS = [
{
Expand Down Expand Up @@ -77,15 +92,7 @@ const CREATE_CONFIG = {
allowMultipleValues: true,
},
},
{
Header: 'Entity',
source: 'entity.name',
editConfig: {
optionsEndpoint: 'entities',
baseFilter: { type: 'country' },
allowMultipleValues: true,
},
},
EntityField,
{
Header: 'Permission group',
source: 'permission_group.name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { prettyArray } from '../../utilities';

export const RESOURCE_NAME = { singular: 'dashboard relation' };

// export for use on users page
export const DASHBOARD_RELATION_ENDPOINT = 'dashboardRelations';
export const DASHBOARD_RELATION_COLUMNS = [
{

export const FIELDS = {
DASHBOARD_CODE: {
Header: 'Dashboard code',
source: 'dashboard.code',
editConfig: {
Expand All @@ -21,7 +21,7 @@ export const DASHBOARD_RELATION_COLUMNS = [
sourceKey: 'dashboard_id',
},
},
{
DASHBOARD_ITEM_CODE: {
Header: 'Dashboard item code',
source: 'dashboard_item.code',
editConfig: {
Expand All @@ -31,7 +31,7 @@ export const DASHBOARD_RELATION_COLUMNS = [
sourceKey: 'child_id',
},
},
{
PERMISSION_GROUPS: {
Header: 'Permission groups',
source: 'permission_groups',
Filter: ArrayFilter,
Expand All @@ -44,7 +44,7 @@ export const DASHBOARD_RELATION_COLUMNS = [
allowMultipleValues: true,
},
},
{
ENTITY_TYPES: {
Header: 'Entity types',
source: 'entity_types',
Filter: ArrayFilter,
Expand All @@ -58,13 +58,13 @@ export const DASHBOARD_RELATION_COLUMNS = [
secondaryLabel: 'Input the entity types you want. e.g: ‘country’, ‘sub_district’',
},
},
{
ATTRIBUTES_FILTER: {
Header: 'Attributes filter',
source: 'attributes_filter',
type: 'jsonTooltip',
editConfig: { type: 'jsonEditor' },
},
{
PROJECT_CODES: {
Header: 'Project codes',
source: 'project_codes',
Filter: ArrayFilter,
Expand All @@ -77,10 +77,20 @@ export const DASHBOARD_RELATION_COLUMNS = [
allowMultipleValues: true,
},
},
{
SORT_ORDER: {
Header: 'Sort order',
source: 'sort_order',
},
};

export const DASHBOARD_RELATION_COLUMNS = [
FIELDS.DASHBOARD_CODE,
FIELDS.DASHBOARD_ITEM_CODE,
FIELDS.PERMISSION_GROUPS,
FIELDS.ENTITY_TYPES,
FIELDS.ATTRIBUTES_FILTER,
FIELDS.PROJECT_CODES,
FIELDS.SORT_ORDER,
];

const COLUMNS = [
Expand Down
57 changes: 17 additions & 40 deletions packages/admin-panel/src/routes/visualisations/dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd
*/

import { RESOURCE_NAME as DASHBOARD_RELATION_RESOURCE_NAME } from './dashboardRelations';
import {
DASHBOARD_RELATION_ENDPOINT,
FIELDS as DASHBOARD_RELATION_FIELDS,
RESOURCE_NAME as DASHBOARD_RELATION_RESOURCE_NAME,
} from './dashboardRelations';

const RESOURCE_NAME = { singular: 'dashboard' };

Expand Down Expand Up @@ -61,44 +65,10 @@ const RELATION_FIELDS = [
source: 'dashboard_item.code',
editable: false,
},
{
Header: 'Permission groups',
source: 'permission_groups',
editConfig: {
optionsEndpoint: 'permissionGroups',
optionLabelKey: 'name',
optionValueKey: 'name',
sourceKey: 'permission_groups',
allowMultipleValues: true,
},
},
{
Header: 'Entity types',
source: 'entity_types',
editConfig: {
type: 'autocomplete',
allowMultipleValues: true,
canCreateNewOptions: true,
optionLabelKey: 'entityTypes',
optionValueKey: 'entityTypes',
secondaryLabel: 'Input the entity types you want. e.g. ‘country’, ‘sub_district’',
},
},
{
Header: 'Project codes',
source: 'project_codes',
editConfig: {
optionsEndpoint: 'projects',
optionLabelKey: 'code',
optionValueKey: 'code',
sourceKey: 'project_codes',
allowMultipleValues: true,
},
},
{
Header: 'Sort order',
source: 'sort_order',
},
DASHBOARD_RELATION_FIELDS.PERMISSION_GROUPS,
DASHBOARD_RELATION_FIELDS.ENTITY_TYPES,
DASHBOARD_RELATION_FIELDS.PROJECT_CODES,
DASHBOARD_RELATION_FIELDS.SORT_ORDER,
];

const RELATION_COLUMNS = [
Expand All @@ -108,10 +78,17 @@ const RELATION_COLUMNS = [
type: 'edit',
source: 'id',
actionConfig: {
editEndpoint: 'dashboardRelations',
editEndpoint: DASHBOARD_RELATION_ENDPOINT,
fields: RELATION_FIELDS,
},
},
{
Header: 'Delete',
type: 'delete',
actionConfig: {
endpoint: DASHBOARD_RELATION_ENDPOINT,
},
},
];

const CREATE_CONFIG = {
Expand Down
Loading

0 comments on commit 0110eb2

Please sign in to comment.