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
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ interface PrintButtonProps {
const addedButtonLabel = { id: 'buttons.print', defaultMessage: 'Print' }

/**
* Indicates that declaration action changed declaration content. Satisfies V1 spec.
* Specialized print declaration action used only on the client side.
*
* DECLARE has been used here so that in offline mode
* getCurrentEventState can be tricked to include both
* metadata and declaration data not really persisted
* on the record’s history
*
*/
export const DECLARATION_ACTION_UPDATE = 'UPDATE' as const
type DECLARATION_ACTION_UPDATE = typeof DECLARATION_ACTION_UPDATE
const PRINT_DECLARATION_ACTION = 'DECLARE' as const
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In getCurrentEventState:
Declarations are aggregated for all actions except:

// Action types that are not taken into the aggregate values
const EXCLUDED_ACTIONS = [
  ActionType.REQUEST_CORRECTION,
  ActionType.PRINT_CERTIFICATE,
  ActionType.REJECT_CORRECTION
]

And metadata for the following actions:

const updateActions = ActionTypes.extract([
  ActionType.CREATE,
  ActionType.NOTIFY,
  ActionType.DECLARE,
  ActionType.VALIDATE,
  ActionType.REGISTER,
  ActionType.REJECT,
  ActionType.ARCHIVE,
  ActionType.PRINT_CERTIFICATE,
  ActionType.REQUEST_CORRECTION
])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using existing ActionDocument such as DECLARE also allows to resolve the optimistic action sent by the alpha print button, and helps with parsing location names in the certificates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes required in certs.
Can access metadata like this: $lookup $metadata 'updatedAtLocation.province'
and declarations like: $lookup $declaration 'mother.occupation'

type PRINT_DECLARATION_ACTION = typeof PRINT_DECLARATION_ACTION

export const AlphaPrintButton = {
Input: ({
Expand All @@ -62,7 +68,7 @@ export const AlphaPrintButton = {
const intl = useIntl()
const location = useLocation()
const parts = location.pathname.split('/')
const eventId = UUID.parse(parts[3])
const eventId = parts[3] as UUID
const { getEvent } = useEvents()
const { certificateTemplates, language } = useAppConfig()
const { getUser } = useUsers()
Expand All @@ -89,7 +95,7 @@ export const AlphaPrintButton = {
const actionsWithAnOptimisticPrintAction = [
...actions,
{
type: DECLARATION_ACTION_UPDATE,
type: PRINT_DECLARATION_ACTION,
id: getUUID(),
transactionId: getUUID(),
createdByUserType: 'user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import {
generateTrackingId
} from '@opencrvs/commons/client'
import { getTestValidatorContext } from '../../../../../../../../.storybook/decorators'
import { expandWithClientSpecificActions } from '../../../../../events/actions/correct/useActionForHistory'
import { DECLARATION_ACTION_UPDATE } from '../../../../../events/registered-fields'
import {
expandWithClientSpecificActions,
DECLARATION_ACTION_UPDATE
} from '../../../../../events/actions/correct/useActionForHistory'
import { testDataGenerator } from '../../../../../../../tests/test-data-generators'
import { EventHistoryDialog } from './EventHistoryDialog'

Expand Down
Loading