Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/decode-uri-compone…
Browse files Browse the repository at this point in the history
…nt-0.2.2

# Conflicts:
#	yarn.lock
  • Loading branch information
Sharmyn28 committed Oct 23, 2023
2 parents 83d2912 + e3332d2 commit 307474f
Show file tree
Hide file tree
Showing 34 changed files with 1,466 additions and 678 deletions.
25 changes: 23 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-07-05T09:36:08.695Z\n"
"PO-Revision-Date: 2023-07-05T09:36:08.695Z\n"
"POT-Creation-Date: 2023-10-06T16:23:08.006Z\n"
"PO-Revision-Date: 2023-10-06T16:23:08.006Z\n"

msgid ""
"The initial configuration of the app has been completed and it is now ready "
Expand Down Expand Up @@ -379,6 +379,9 @@ msgstr "Manual"
msgid "How often should data sync?"
msgstr "How often should data sync?"

msgid "Disable TEI referrals"
msgstr "Disable TEI referrals"

msgid "Encrypt device database"
msgstr "Encrypt device database"

Expand All @@ -397,6 +400,9 @@ msgstr "Maximum file size limit for download (Kb)"
msgid "Show percentage (%) complete in Program toolbar"
msgstr "Show percentage (%) complete in Program toolbar"

msgid "Do not collapse sections in form"
msgstr "Do not collapse sections in form"

msgid "Analytics reporting ID (Matomo)"
msgstr "Analytics reporting ID (Matomo)"

Expand Down Expand Up @@ -856,6 +862,15 @@ msgstr ""
"apply to all programs a mobile user has access to. Settings specific to "
"individual programs can also be applied."

msgid "TEI Header"
msgstr "TEI Header"

msgid "Advanced options"
msgstr "Advanced options"

msgid "Filter"
msgstr "Filter"

msgid "Enrollment Date"
msgstr "Enrollment Date"

Expand All @@ -871,6 +886,12 @@ msgstr "Event status"
msgid "Follow up"
msgstr "Follow up"

msgid "There are no Program Indicators with valid expressions for Android"
msgstr "There are no Program Indicators with valid expressions for Android"

msgid "Disable elements do not meet Android criteria"
msgstr "Disable elements do not meet Android criteria"

msgid "Enrollment Status"
msgstr "Enrollment Status"

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"author": "UiO <milagros@dhis2.org>",
"private": true,
"dependencies": {
"@dhis2/app-runtime": "^3.4.4",
"@dhis2/app-runtime": "^3.9.4",
"@dhis2/d2-i18n": "^1.1.1",
"@dhis2/d2-ui-core": "^6.3.0",
"@dhis2/d2-ui-table": "^6.3.0",
"@dhis2/ui": "^8.2.1",
"@dhis2/ui": "^8.13.15",
"@material-ui/core": "^3.9.2",
"d2": "^31.7",
"d3-color": "^3.1.0",
Expand Down
19 changes: 18 additions & 1 deletion src/auth/AuthWall.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { useAlert, useConfig, useDataMutation } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import isNil from 'lodash/isNil'
import PropTypes from 'prop-types'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import DialogFirstLaunch from '../components/dialog/DialogFirstLaunch'
import { deletePrevDataStoreMutation, useCreateFirstSetup } from '../modules'
import {
updateInfoMutation,
useAndroidSettingsVersion,
} from './useAndroidSettingsVersion'
import { useIsAuthorized } from './useIsAuthorized'

const AuthWall = ({ children }) => {
const { hasAuthority, hasNamespace, hasOutDateNamespace } =
useIsAuthorized()
const { isInfoUpdated } = useAndroidSettingsVersion()
const { apiVersion } = useConfig()
const [hasDatastoreAccess, setDatastoreAccess] = useState(hasNamespace)
const [mutate] = useDataMutation(deletePrevDataStoreMutation)
const [mutateUpdateInfo] = useDataMutation(updateInfoMutation)
const { createSetup } = useCreateFirstSetup()
const { show } = useAlert(
({ success }) =>
Expand All @@ -25,6 +32,16 @@ const AuthWall = ({ children }) => {
({ success }) => (success ? { success: true } : { critical: true })
)

useEffect(() => {
if (!isNil(isInfoUpdated) && !isInfoUpdated) {
updateInfoVersion().catch((e) => console.error(e))
}
}, [isInfoUpdated])

const updateInfoVersion = async () => {
await mutateUpdateInfo()
}

const handleSave = async () => {
if (hasOutDateNamespace) {
await mutate()
Expand Down
37 changes: 37 additions & 0 deletions src/auth/useAndroidSettingsVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useDataQuery } from '@dhis2/app-runtime'
import { INFO, NAMESPACE } from '../constants/data-store'
import { infoDefault } from '../constants/info'

export const getKeyInfo = {
info: {
resource: `dataStore/${NAMESPACE}/${INFO}`,
},
}

export const updateInfoMutation = {
resource: `dataStore/${NAMESPACE}/${INFO}`,
type: 'update',
data: { ...infoDefault },
}

const isUpdatedVersion = (currentVersion, updatedVersion) =>
currentVersion === updatedVersion

export const useAndroidSettingsVersion = () => {
const { data } = useDataQuery(getKeyInfo)

return {
isInfoUpdated:
data &&
isUpdatedVersion(
data.info?.androidSettingsVersion,
infoDefault.androidSettingsVersion
),
isDatastoreUpdated:
data &&
isUpdatedVersion(
data.info?.dataStoreVersion,
infoDefault.dataStoreVersion
),
}
}
28 changes: 28 additions & 0 deletions src/components/field/DisableReferral.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'
import React from 'react'
import { DISABLE_REFERRALS } from '../../constants'
import { CheckboxField } from './CheckboxField'

export const DisableReferral = ({
isTrackerProgram,
handleChange,
settings,
}) => (
<>
{isTrackerProgram && (
<CheckboxField
name={DISABLE_REFERRALS}
label={i18n.t('Disable TEI referrals')}
onChange={handleChange}
checked={settings[DISABLE_REFERRALS]}
/>
)}
</>
)

DisableReferral.propTypes = {
isTrackerProgram: PropTypes.bool,
handleChange: PropTypes.func,
settings: PropTypes.object,
}
5 changes: 4 additions & 1 deletion src/components/field/GlobalProgramCompletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const CODE = 'completionSpinner'

export const GlobalProgramCompletion = ({ disable, settings, onChange }) => {
const handleChange = (e) => {
onChange({ [e.name]: e.checked })
onChange({
...settings,
[e.name]: e.checked,
})
}

return (
Expand Down
38 changes: 38 additions & 0 deletions src/components/field/GlobalProgramDisableReferral.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import i18n from '@dhis2/d2-i18n'
import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import { DISABLE_REFERRALS } from '../../constants'
import { CheckboxField } from './CheckboxField'
import styles from './Field.module.css'

export const GlobalProgramDisableReferral = ({
disable,
settings,
onChange,
}) => {
const handleChange = (e) => {
onChange({
...settings,
[e.name]: e.checked,
})
}

return (
<div className={cx(styles.rowBMargin24)}>
<CheckboxField
name={DISABLE_REFERRALS}
label={i18n.t('Disable TEI referrals')}
onChange={handleChange}
disabled={disable}
checked={settings[DISABLE_REFERRALS]}
/>
</div>
)
}

GlobalProgramDisableReferral.propTypes = {
disable: PropTypes.bool,
settings: PropTypes.object,
onChange: PropTypes.func,
}
35 changes: 35 additions & 0 deletions src/components/field/GlobalProgramHideSections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import i18n from '@dhis2/d2-i18n'
import cx from 'classnames'
import PropTypes from 'prop-types'
import React from 'react'
import { COLLAPSIBLE_SECTIONS } from '../../constants'
import { CheckboxField } from './CheckboxField'
import styles from './Field.module.css'
import { GlobalProgramDisableReferral } from './GlobalProgramDisableReferral'

export const GlobalProgramHideSections = ({ disable, settings, onChange }) => {
const handleChange = (e) => {
onChange({
...settings,
[e.name]: e.checked,
})
}

return (
<div className={cx(styles.rowBMargin24)}>
<CheckboxField
name={COLLAPSIBLE_SECTIONS}
label={i18n.t('Do not collapse sections in form')}
onChange={handleChange}
disabled={disable}
checked={settings[COLLAPSIBLE_SECTIONS]}
/>
</div>
)
}

GlobalProgramDisableReferral.propTypes = {
disable: PropTypes.bool,
settings: PropTypes.object,
onChange: PropTypes.func,
}
19 changes: 19 additions & 0 deletions src/components/field/HideFormSections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'
import React from 'react'
import { COLLAPSIBLE_SECTIONS } from '../../constants'
import { CheckboxField } from './CheckboxField'

export const HideFormSections = ({ settings, handleChange }) => (
<CheckboxField
name={COLLAPSIBLE_SECTIONS}
label={i18n.t('Do not collapse sections in form')}
onChange={handleChange}
checked={settings[COLLAPSIBLE_SECTIONS]}
/>
)

HideFormSections.propTypes = {
handleChange: PropTypes.func,
settings: PropTypes.object,
}
1 change: 1 addition & 0 deletions src/components/field/ReservedValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const ReservedValues = ({ onChange, value, ...props }) => {
value={value[CODE]}
warning={value[CODE] >= MAXVALUE}
step="10"
min="0"
inputWidth="120px"
validationText={i18n.t(
'Recommended maximum is {{maxValue}} reserved values',
Expand Down
20 changes: 20 additions & 0 deletions src/components/field/Section.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FieldSet, Legend } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import styles from './Section.module.css'

export const Section = ({ legend, children }) => (
<div className={styles.container}>
<FieldSet>
<Legend className={styles.legend}>
<span> {legend} </span>
</Legend>
{children}
</FieldSet>
</div>
)

Section.propTypes = {
legend: PropTypes.string,
children: PropTypes.element.isRequired,
}
16 changes: 16 additions & 0 deletions src/components/field/Section.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.legend {
display: inline-block;
padding-bottom: var(--spacers-dp16);
font-size: 15px;
color: var(--colors-grey900);
font-weight: 500;
letter-spacing: 0.2px;
}

.container {
padding: var(--spacers-dp16) 0;
}

.container:not(:last-child) {
margin-bottom: var(--spacers-dp8);
}
5 changes: 5 additions & 0 deletions src/components/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ export * from './AddNewSetting'
export * from './ButtonField'
export * from './CheckboxField'
export * from './DataSync'
export * from './DisableReferral'
export * from './EncryptDB'
export * from './FieldSection'
export * from './FileMaxSize'
export * from './GlobalProgramCompletion'
export * from './GlobalProgramDisableReferral'
export * from './GlobalProgramHideSections'
export * from './HideFormSections'
export * from './MatomoId'
export * from './MatomoUrl'
export * from './MessageOfDay'
Expand All @@ -15,6 +19,7 @@ export * from './OptionalTEISearch'
export * from './PhoneNumberField'
export * from './ProgramCompletionSpinner'
export * from './ReservedValues'
export * from './Section'
export * from './SelectField'
export * from './ShareScreen'
export * from './SmsGateway'
Expand Down
6 changes: 6 additions & 0 deletions src/constants/appearance-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export const appearanceDefault = {
programConfiguration: {
globalSettings: {
completionSpinner: true,
disableReferrals: false,
disableCollapsibleSections: true,
},
specificSettings: {},
},
Expand Down Expand Up @@ -86,3 +88,7 @@ export const appearanceDefault = {
},
},
}

export const COMPLETION_SPINNER = 'completionSpinner'
export const DISABLE_REFERRALS = 'disableReferrals'
export const COLLAPSIBLE_SECTIONS = 'disableCollapsibleSections'
1 change: 1 addition & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './appearance-settings'
2 changes: 1 addition & 1 deletion src/constants/info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const infoDefault = {
dataStoreVersion: '2.0',
androidSettingsVersion: '2.3.0',
androidSettingsVersion: '2.3.1',
}
Loading

0 comments on commit 307474f

Please sign in to comment.