Skip to content

Commit

Permalink
added v and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
rinrub authored and ruberino committed Feb 19, 2024
1 parent aaf909e commit a460af1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 14.0.8

---

- Bugfix: When Confirmation is repeatable, the added items now have a initial value of false

## 14.0.7

---
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helsenorge/refero",
"version": "14.0.7",
"version": "14.0.8",
"engines": {
"node": "^18.0.0",
"npm": ">=9.0.0"
Expand Down
16 changes: 9 additions & 7 deletions src/reducers/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
REMOVE_ATTACHMENT_VALUE,
} from '../actions/newValue';
import { syncQuestionnaireResponse } from '../actions/syncQuestionnaireResponse';
import itemType from '../constants/itemType';
import { GlobalState } from '../reducers/index';
import { createQuestionnaireResponseAnswer } from '../util/createQuestionnaireResponseAnswer';
import { getMinOccursExtensionValue } from '../util/extension';
Expand Down Expand Up @@ -124,38 +125,39 @@ function getArrayToAddGroupTo(itemToAddTo: QuestionnaireResponseItem | undefined
}

function processAddRepeatItemAction(action: NewValueAction, state: Form): Form {
const { parentPath, responseItems, item } = action;
return produce(state, draft => {
if (!action.parentPath) {
if (!parentPath) {
return state;
}

let arrayToAddItemTo: Array<QuestionnaireResponseItem> | undefined = [];
if (action.parentPath.length === 0 && draft.FormData.Content) {
if (parentPath.length === 0 && draft.FormData.Content) {
arrayToAddItemTo = draft.FormData.Content.item;
} else if (action.parentPath.length > 0) {
} else if (parentPath.length > 0) {
// length >1 means group wrapped in group
const itemToAddTo = getResponseItemWithPath(action.parentPath, draft.FormData);
const itemToAddTo = getResponseItemWithPath(parentPath, draft.FormData);
arrayToAddItemTo = getArrayToAddGroupTo(itemToAddTo);
}

if (!arrayToAddItemTo || arrayToAddItemTo.length === 0) {
return;
}

if (!action.responseItems || action.responseItems.length === 0) {
if (!responseItems || responseItems.length === 0) {
return;
}

const newItem = copyItem(
action.responseItems[0],
responseItems[0],
undefined,
draft.FormDefinition.Content as Questionnaire,
state.FormDefinition.Content as Questionnaire
);
if (!newItem) {
return;
}
if (item?.type === ItemType.BOOLEAN) {
if (item?.type === itemType.BOOLEAN) {
if (item.initial && item.initial.length > 0 && item.initial[0].valueBoolean !== undefined) {
newItem.answer = [{ valueBoolean: item.initial[0]?.valueBoolean }];
} else {
Expand Down

0 comments on commit a460af1

Please sign in to comment.