Skip to content

Commit

Permalink
FIO-8730: Fix submission has hidden fields when 'Clear value when hid…
Browse files Browse the repository at this point in the history
…den' is checked (#123)

* FIO-8730: Fix submission has hidden fields when 'Clear value when hidden' is checked

* FIO-8730: Fix clearHidden process logic has unset extra values

* FIO-8730: Add test and refactor some already existing for similar cases

* FIO-8730: Add vs code tests debug config and watch script for typescript compilation

* FIO-8730: Add clearOnHide true to test components

* added check for component.input

---------

Co-authored-by: John Teague <[email protected]>
  • Loading branch information
mikekotikov and johnformio authored Jul 29, 2024
1 parent 7cf9884 commit 7b6e28b
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 376 deletions.
50 changes: 50 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha: current file",
"program": "${workspaceFolder}/node_modules/.bin/mocha",
"args": [
"-r",
"ts-node/register",
"-b",
"-t",
"0",
"-r",
"tsconfig-paths/register",
"-r",
"jsdom-global/register",
"-r",
"mock-local-storage",
"'${file}'"
],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/.bin/mocha",
"args": [
"-r",
"ts-node/register",
"-b",
"-t",
"0",
"-r",
"tsconfig-paths/register",
"-r",
"mock-local-storage",
"-r",
"jsdom-global/register",
"'src/**/__tests__/*.test.ts'"
],
"console": "integratedTerminal"
}
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"scripts": {
"test": "TEST=1 nyc --reporter=lcov --reporter=text --reporter=text-summary mocha -r ts-node/register -r tsconfig-paths/register -r mock-local-storage -r jsdom-global/register -t 0 'src/**/__tests__/*.test.ts'",
"lib": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
"lib:watch": "tsc -w & tsc-alias -w",
"replace": "node -r tsconfig-paths/register -r ts-node/register ./lib/base/array/ArrayComponent.js",
"test:debug": "mocha -r ts-node/register -r tsconfig-paths/register -r mock-local-storage -r jsdom-global/register --debug-brk --inspect '**/*.spec.ts'",
"docs": "./node_modules/typedoc/bin/typedoc --exclude '*.spec.ts' src/*.ts src/**/*.ts src/**/**/*.ts",
Expand Down
156 changes: 156 additions & 0 deletions src/process/__tests__/fixtures/clearOnHideWithCustomCondition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"form": {
"display": "form",
"components": [
{
"title": "__information_on_the_appointee",
"theme": "primary",
"collapsible": false,
"key": "HeadingNestedFormCandidates",
"type": "panel",
"label": "Appointees",
"input": false,
"tableView": false,
"components": [
{
"label": "Appointees",
"hideLabel": true,
"tableView": false,

"addAnother": "__add_appointee",
"modal": true,
"saveRow": "Close",
"rowDrafts": true,
"key": "candidates",
"type": "editgrid",
"displayAsTable": false,
"input": true,
"components": [
{
"label": "Appointee",
"tableView": false,
"key": "candidate",
"type": "container",
"input": true,
"components": [
{
"label": "Data",
"tableView": false,
"key": "data",
"type": "container",
"input": true,
"components": [
{
"label": "Tabs",
"components": [
{
"label": "__6_time_commitment",
"key": "section6tab",
"components": [
{
"label": "Section 6",
"tableView": false,
"clearOnHide": true,
"validateWhenHidden": false,
"key": "section6",
"properties": {
"clearHiddenOnSave": "true"
},
"customConditional": "show = false;",
"type": "container",
"input": true,
"components": [
{
"title": "__6_dash_time_commitment",
"theme": "primary",
"collapsible": false,
"key": "heading6",
"type": "panel",
"label": "Time Commitment",
"input": false,
"tableView": false,
"components": [
{
"label": "__a_information_to_be_provided_by_the_supervised_entity_the",
"description": "__ul_li_see_the_report_on_declared_time_commitment_of",
"autoExpand": false,
"tableView": true,
"validate": {
"required": true
},
"key": "entityExpectedTimeCommit",
"type": "textarea",
"input": true
},
{
"label": "c",
"tableView": false,
"key": "c",
"type": "container",
"input": true,
"components": []
},
{
"label": "__d_list_of_executive_and_non_executive_directorships_and_other",
"description": "__for_each_directorship_or_other_activity_a_separate_row_needs",
"tableView": false,
"addAnother": "__add_another",
"validate": {
"required": true
},
"rowDrafts": false,
"key": "d",
"type": "editgrid",
"input": true,
"components": []
}
]
}
]
}
]
}
],
"key": "tabs1",
"type": "tabs",
"input": false,
"tableView": false
}
]
}
]
}
]
}
]
},
{
"label": "Submit",
"action": "saveState",
"showValidations": false,
"tableView": false,
"key": "submit",
"type": "button",
"input": true,
"state": "draft"
}
]
},
"submission": {
"data": {
"candidates": [
{
"candidate": {
"data": {
"section6": {
"c": {},
"d": []
}
}
}
}
],
"submit": true
}
}
}
158 changes: 158 additions & 0 deletions src/process/__tests__/fixtures/clearOnHideWithHiddenParent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"form": {
"display": "form",
"components": [
{
"title": "__information_on_the_appointee",
"theme": "primary",
"collapsible": false,
"key": "HeadingNestedFormCandidates",
"type": "panel",
"label": "Appointees",
"input": false,
"tableView": false,
"components": [
{
"label": "Appointees",
"hideLabel": true,
"tableView": false,

"addAnother": "__add_appointee",
"modal": true,
"saveRow": "Close",
"rowDrafts": true,
"key": "candidates",
"type": "editgrid",
"displayAsTable": false,
"input": true,
"components": [
{
"label": "Appointee",
"tableView": false,
"key": "candidate",
"type": "container",
"input": true,
"components": [
{
"label": "Data",
"tableView": false,
"key": "data",
"type": "container",
"input": true,
"components": [
{
"label": "Tabs",
"components": [
{
"label": "__6_time_commitment",
"key": "section6tab",
"components": [
{
"label": "Section 6",
"tableView": false,
"clearOnHide": false,
"validateWhenHidden": false,
"key": "section6",
"properties": {
"clearHiddenOnSave": "true"
},
"hidden": true,
"type": "container",
"input": true,
"components": [
{
"title": "__6_dash_time_commitment",
"theme": "primary",
"collapsible": false,
"key": "heading6",
"type": "panel",
"label": "Time Commitment",
"input": false,
"tableView": false,
"components": [
{
"label": "__a_information_to_be_provided_by_the_supervised_entity_the",
"description": "__ul_li_see_the_report_on_declared_time_commitment_of",
"autoExpand": false,
"tableView": true,
"validate": {
"required": true
},
"key": "entityExpectedTimeCommit",
"type": "textarea",
"input": true
},
{
"label": "c",
"tableView": false,
"key": "c",
"type": "container",
"input": true,
"components": [],
"clearOnHide": true
},
{
"label": "__d_list_of_executive_and_non_executive_directorships_and_other",
"description": "__for_each_directorship_or_other_activity_a_separate_row_needs",
"tableView": false,
"addAnother": "__add_another",
"validate": {
"required": true
},
"rowDrafts": false,
"key": "d",
"type": "editgrid",
"input": true,
"components": [],
"clearOnHide": true
}
]
}
]
}
]
}
],
"key": "tabs1",
"type": "tabs",
"input": false,
"tableView": false
}
]
}
]
}
]
}
]
},
{
"label": "Submit",
"action": "saveState",
"showValidations": false,
"tableView": false,
"key": "submit",
"type": "button",
"input": true,
"state": "draft"
}
]
},
"submission": {
"data": {
"candidates": [
{
"candidate": {
"data": {
"section6": {
"c": {},
"d": []
}
}
}
}
],
"submit": true
}
}
}
7 changes: 7 additions & 0 deletions src/process/__tests__/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import clearOnHideWithCustomCondition from './clearOnHideWithCustomCondition.json';
import clearOnHideWithHiddenParent from './clearOnHideWithHiddenParent.json';
import data1a from './data1a.json';
import form1 from './form1.json';
import subs from './subs.json';

export { clearOnHideWithCustomCondition, clearOnHideWithHiddenParent, data1a, form1, subs };
Loading

0 comments on commit 7b6e28b

Please sign in to comment.