Skip to content

Commit

Permalink
CARDS-2556: Allow "Information" form entries to be displayed in view …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
marta- committed Jul 25, 2024
1 parent 915c9d1 commit e0449ff
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions Utilities/FormImport/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ def range_value_handler(self, questionnaire, row, datetime_limit):
DefaultHeaders["REGIONS"] = HeaderColumn("regions", "regions")
DefaultHeaders["SEARCH_PLACES_AROUND"] = HeaderColumn("searchPlacesAround", "searchPlacesAround")
DefaultHeaders["TYPE_PROPERTY"] = HeaderColumn("type", "type")
DefaultHeaders["FORM_MODE_PROPERTY"] = HeaderColumn("formMode", "formMode")
DefaultHeaders["VALIDATION_ERROR_TEXT"] = HeaderColumn("validationErrorText", "validationErrorText")
DefaultHeaders["IS_RANGE"] = HeaderColumn("isRange", "isRange", boolean_handler)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ let displaySection = (sectionDefinition, path, depth, existingAnswer, key, onCha
}

let displayInformation = (infoDefinition, key, classes, pageActive, isEdit, gridProps) => {
let isVisible = (
(!infoDefinition.formMode || infoDefinition.formMode == "edit") && isEdit
|| infoDefinition.formMode == "view" && !isEdit
|| infoDefinition.formMode == "any"
);
return (
isEdit && pageActive && infoDefinition.text &&
isVisible && pageActive && infoDefinition.text &&
<Grid item key={key} {...gridProps}>
<Information infoDefinition={infoDefinition} />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"type": "Enables rendering the information card with a different styling depending on the nature and purpose of the info displayed:\n* **plain** is a card with no distinct background,\n* **info** sets a blue background,\n* **warning** sets an orange background,\n* **error** sets a red background,\n* **success** sets a green background."
"type": "Enables rendering the information card with a different styling depending on the nature and purpose of the info displayed:\n* **plain** is a card with no distinct background,\n* **info** sets a blue background,\n* **warning** sets an orange background,\n* **error** sets a red background,\n* **success** sets a green background.",
"formMode": "Whether the inforrmation box gets displayed when the form is in **edit** mode (default), in **view** mode, or in **any** mode."
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"error": {},
"success" : {}
},
"formMode" : {
"edit": {},
"view": {},
"any" : {}
},
"text": "markdown"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@
+ * (cards:ExternalLink) = cards:ExternalLink

//-----------------------------------------------------------------------------
// An informative formatted text (markdown) displayed in edit mode to guide
// the user through filling out a form.
// An informative formatted text (markdown). Can be displayed in edit mode to guide
// the user through filling out a form, or in view mode to explain the data.
[cards:Information] > sling:Folder, mix:referenceable
// Attributes

Expand All @@ -277,6 +277,10 @@
// success (green). Optional, defaults to plain styling when absent.
- type (string)

// The form mode specifies when the Information is displayed: in "edit" mode, in "view" mode
// mode, or in "any" mode. Defaults to "edit" when absent.
- formMode (string)

//-----------------------------------------------------------------------------
// A section is a collection of questions.
[cards:Section] > sling:Folder, mix:referenceable
Expand Down

0 comments on commit e0449ff

Please sign in to comment.