Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/generate-and-sync-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Check for contract changes
id: diff
run: |
if git diff --quiet HEAD -- contracts; then
if git diff --quiet origin/master -- contracts; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
Expand Down
3 changes: 3 additions & 0 deletions contracts/analyticsTableHooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GET analyticsTableHooks usage

used to populate analytics table hooks form
7 changes: 7 additions & 0 deletions contracts/analyticsTableHooks/contract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "analyticsTableHooks",
"httpMethod": "GET",
"requestUrl": "/analyticsTableHooks/{id}",
"responseStatus": 200,
"jsonSchema": "contracts/metadata-management-app/analyticsTableHooks/json-schema.json"
}
57 changes: 57 additions & 0 deletions contracts/analyticsTableHooks/json-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"displayName": {
"type": "string"
},
"sql": {
"type": "string"
},
"analyticsTableType": {
"type": "string",
"enum": [
"DATA_VALUE",
"COMPLETENESS",
"COMPLETENESS_TARGET",
"ORG_UNIT_TARGET",
"EVENT",
"ENROLLMENT",
"OWNERSHIP",
"VALIDATION_RESULT",
"TRACKED_ENTITY_INSTANCE_EVENTS",
"TRACKED_ENTITY_INSTANCE_ENROLLMENTS",
"TRACKED_ENTITY_INSTANCE"
]
},
"phase": {
"type": "string",
"enum": ["RESOURCE_TABLE_POPULATED", "ANALYTICS_TABLE_POPULATED"]
},
"resourceTableType": {
"type": "string",
"enum": [
"ORG_UNIT_STRUCTURE",
"DATA_SET_ORG_UNIT_CATEGORY",
"CATEGORY_OPTION_COMBO_NAME",
"DATA_ELEMENT_GROUP_SET_STRUCTURE",
"INDICATOR_GROUP_SET_STRUCTURE",
"ORG_UNIT_GROUP_SET_STRUCTURE",
"CATEGORY_STRUCTURE",
"DATA_ELEMENT_STRUCTURE",
"PERIOD_STRUCTURE",
"DATE_PERIOD_STRUCTURE",
"DATA_ELEMENT_CATEGORY_OPTION_COMBO",
"DATA_APPROVAL_REMAP_LEVEL",
"DATA_APPROVAL_MIN_LEVEL"
]
}
},
"required": ["id", "name", "sql", "phase"],
"additionalProperties": true
}
10 changes: 10 additions & 0 deletions src/contracts/generateContracts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mkdirSync, writeFileSync } from 'node:fs'
import { z, ZodObject, ZodRawShape } from 'zod'
import { zodToJsonSchema } from 'zod-to-json-schema'
import { analyticsTableHookFormSchema } from '../pages/analyticsTableHooks/form'
import { categoryFormSchema } from '../pages/categories/form'

const generateContract = <T extends ZodRawShape>({
Expand Down Expand Up @@ -55,4 +56,13 @@ describe('contracts', () => {
usage: 'used to populate edit category form',
})
})
it('should generate get analytics table hooks contracts', () => {
generateContract({
method: 'GET',
path: '/analyticsTableHooks/{id}',
name: 'analyticsTableHooks',
expectedSchema: analyticsTableHookFormSchema,
usage: 'used to populate analytics table hooks form',
})
})
})
48 changes: 48 additions & 0 deletions src/lib/constants/translatedModelConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,51 @@ const VALIDATION_STRATEGY = {
ON_UPDATE_AND_INSERT: i18n.t('On update and insert'),
}

const ANALYTICS_TABLE_HOOK_PHASE = {
RESOURCE_TABLE_POPULATED: i18n.t('Resource tables'),
ANALYTICS_TABLE_POPULATED: i18n.t('Analytics tables'),
}

const ANALYTICS_TABLE_TYPE = {
DATA_VALUE: i18n.t('Data value'),
COMPLETENESS: i18n.t('Completeness'),
COMPLETENESS_TARGET: i18n.t('Completeness target'),
ORG_UNIT_TARGET: i18n.t('Organisation unit target'),
VALIDATION_RESULT: i18n.t('Validation result'),
OWNERSHIP: i18n.t('Ownership'),
TRACKED_ENTITY_INSTANCE_EVENTS: i18n.t('Tracked entity instance events'),
TRACKED_ENTITY_INSTANCE_ENROLLMENTS: i18n.t(
'Tracked entity instance enrollments'
),
TRACKED_ENTITY_INSTANCE: i18n.t('Tracked entity instance'),
}

const RESOURCE_TABLE_TYPE = {
ORG_UNIT_STRUCTURE: i18n.t('Organisation unit structure'),
DATA_SET_ORG_UNIT_CATEGORY: i18n.t('Data set organisation unit category'),
CATEGORY_OPTION_COMBO_NAME: i18n.t('Category option combo name'),
DATA_ELEMENT_GROUP_SET_STRUCTURE: i18n.t(
'Data element group set structure'
),
INDICATOR_GROUP_SET_STRUCTURE: i18n.t('Indicator group set structure'),
ORG_UNIT_GROUP_SET_STRUCTURE: i18n.t(
'Organisation unit group set structure'
),
CATEGORY_STRUCTURE: i18n.t('Category structure'),
DATA_ELEMENT_STRUCTURE: i18n.t('Data element structure'),
DATA_SET: i18n.t('Data set'),
PERIOD_STRUCTURE: i18n.t('Period structure'),
DATE_PERIOD_STRUCTURE: i18n.t('Date period structure'),
DATA_ELEMENT_CATEGORY_OPTION_COMBO: i18n.t(
'Data element category option combo'
),
DATA_APPROVAL_REMAP_LEVEL: i18n.t('Data approval remap level'),
DATA_APPROVAL_MIN_LEVEL: i18n.t('Data approval min level'),
TEI_RELATIONSHIP_COUNT: i18n.t(
'Tracked entity instance relationship count'
),
}

const PROGRAM_RULE_VARIABLE_SOURCE_TYPE = {
DATAELEMENT_NEWEST_EVENT_PROGRAM_STAGE: i18n.t(
'Data element in newest event in program stage'
Expand Down Expand Up @@ -246,6 +291,9 @@ const allConstantTranslations: Record<string, string> = {
...MISSING_VALUE_STRATEGY,
...VALIDATION_STRATEGY,
...PROGRAM_RULE_VARIABLE_SOURCE_TYPE,
...ANALYTICS_TABLE_HOOK_PHASE,
...ANALYTICS_TABLE_TYPE,
...RESOURCE_TABLE_TYPE,
}

export const getConstantTranslation = (constant: string): string => {
Expand Down
45 changes: 45 additions & 0 deletions src/pages/analyticsTableHooks/Edit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useQuery } from '@tanstack/react-query'
import React from 'react'
import { useParams } from 'react-router-dom'
import { DefaultEditFormContents, FormBase } from '../../components'
import { SECTIONS_MAP, useOnSubmitEdit } from '../../lib'
import { useBoundResourceQueryFn } from '../../lib/query/useBoundQueryFn'
import { AnalyticsTableHookFormFields } from './form/AnalyticsTableHookFormFields'
import {
AnalyticsTableHookFormValues,
validate,
} from './form/analyticsTableHookSchema'
import { fieldFilters } from './form/fieldFilters'

export const Component = () => {
const modelId = useParams().id as string
const section = SECTIONS_MAP.analyticsTableHook
const queryFn = useBoundResourceQueryFn()

const query = {
resource: 'analyticsTableHooks',
id: modelId,
params: {
fields: fieldFilters.concat(),
},
}

const analyticsTableHookQuery = useQuery({
queryKey: [query],
queryFn: queryFn<AnalyticsTableHookFormValues>,
})
const initialValues = analyticsTableHookQuery.data

return (
<FormBase
onSubmit={useOnSubmitEdit({ section, modelId })}
initialValues={initialValues}
validate={validate}
includeAttributes={false}
>
<DefaultEditFormContents section={section}>
<AnalyticsTableHookFormFields />
</DefaultEditFormContents>
</FormBase>
)
}
Loading
Loading