-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DBX-97082] Add Behavioral Changes Pages for 0781 Paper Sync (#33838)
* [DBX-97082] Add Behavioral Changes Pages for 0781 Paper Sync * general save * general save
- Loading branch information
1 parent
753c78b
commit f71f74b
Showing
11 changed files
with
503 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/applications/disability-benefits/all-claims/content/form0781/behaviorListPages.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
|
||
export const BEHAVIOR_LIST_DESCRIPTION = ( | ||
<p> | ||
Did you experience any of these behavioral changes after your traumatic | ||
experiences? It’s also okay if you don’t report any behavioral changes. You | ||
can skip this question if you don’t feel comfortable answering. | ||
</p> | ||
); | ||
|
||
export const BEHAVIOR_LIST_BEHAVIORS_TITLE = | ||
'Behavioral changes related to work'; | ||
|
||
export const BEHAVIOR_INTRO_COMBAT_DESCRIPTION = ( | ||
<p>Placholder content for combat intro description</p> | ||
); |
27 changes: 27 additions & 0 deletions
27
src/applications/disability-benefits/all-claims/pages/form0781/behaviorIntroCombatPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { | ||
radioUI, | ||
radioSchema, | ||
} from 'platform/forms-system/src/js/web-component-patterns'; | ||
|
||
import { BEHAVIOR_INTRO_COMBAT_DESCRIPTION } from '../../content/form0781/behaviorListPages'; | ||
|
||
export const uiSchema = { | ||
'ui:description': BEHAVIOR_INTRO_COMBAT_DESCRIPTION, | ||
'view:answerCombatBehaviorQuestions': { | ||
...radioUI({ | ||
title: 'Do you want to answer additional questions?', | ||
required: () => true, | ||
labels: { | ||
true: 'true', | ||
false: 'false', | ||
}, | ||
}), | ||
}, | ||
}; | ||
|
||
export const schema = { | ||
type: 'object', | ||
properties: { | ||
'view:answerCombatBehaviorQuestions': radioSchema(['true', 'false']), | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
src/applications/disability-benefits/all-claims/pages/form0781/behaviorIntroPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const uiSchema = { | ||
'ui:description': 'Placeholder Text for Behavior Intro', | ||
}; | ||
|
||
export const schema = { | ||
type: 'object', | ||
properties: {}, | ||
}; |
79 changes: 79 additions & 0 deletions
79
src/applications/disability-benefits/all-claims/pages/form0781/behaviorListPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
checkboxGroupSchema, | ||
checkboxGroupUI, | ||
} from 'platform/forms-system/src/js/web-component-patterns'; | ||
import { | ||
BEHAVIOR_LIST_DESCRIPTION, | ||
BEHAVIOR_LIST_BEHAVIORS_TITLE, | ||
} from '../../content/form0781/behaviorListPages'; | ||
import { | ||
BEHAVIOR_CHANGES_WORK, | ||
BEHAVIOR_CHANGES_HEALTH, | ||
BEHAVIOR_CHANGES_OTHER, | ||
} from '../../constants'; | ||
|
||
const schemaKeys = Object.keys(BEHAVIOR_CHANGES_WORK).concat( | ||
Object.keys(BEHAVIOR_CHANGES_HEALTH), | ||
Object.keys(BEHAVIOR_CHANGES_OTHER), | ||
); | ||
|
||
export const uiSchema = { | ||
'ui:description': BEHAVIOR_LIST_DESCRIPTION, | ||
behaviors: checkboxGroupUI({ | ||
title: BEHAVIOR_LIST_BEHAVIORS_TITLE, | ||
labels: { | ||
...BEHAVIOR_CHANGES_WORK, | ||
...BEHAVIOR_CHANGES_HEALTH, | ||
...BEHAVIOR_CHANGES_OTHER, | ||
}, | ||
required: false, | ||
}), | ||
otherBehaviors: { | ||
'ui:title': 'placeholder title', | ||
'ui:description': 'placeholde description', | ||
}, | ||
'view:optOut': checkboxGroupUI({ | ||
title: 'None', | ||
labels: { | ||
none: 'no selection placeholder', | ||
}, | ||
required: false, | ||
}), | ||
'ui:validations': [ | ||
(errors, field) => { | ||
const behaviorSelected = Object.values(field.behaviors || {}).some( | ||
selected => selected, | ||
); | ||
const otherProvided = Object.values(field.otherBehaviors || {}).some( | ||
entry => !!entry, | ||
); | ||
const optedOut = !!Object.values(field['view:optOut'] || {}).some( | ||
entry => !!entry, | ||
); | ||
|
||
if (!behaviorSelected && !otherProvided && !optedOut) { | ||
// when a user has not selected options nor opted out | ||
errors['view:optOut'].addError( | ||
'selection required Error message placehoder', | ||
); | ||
} else if (optedOut && (behaviorSelected || otherProvided)) { | ||
// when a user has selected options and opted out | ||
errors['view:optOut'].addError( | ||
'conflicting selections Error message placehoder', | ||
); | ||
} | ||
}, | ||
], | ||
}; | ||
|
||
export const schema = { | ||
type: 'object', | ||
properties: { | ||
behaviors: checkboxGroupSchema(schemaKeys), | ||
otherBehaviors: { | ||
type: 'string', | ||
properties: {}, | ||
}, | ||
'view:optOut': checkboxGroupSchema(['none']), | ||
}, | ||
}; |
12 changes: 12 additions & 0 deletions
12
.../disability-benefits/all-claims/tests/pages/form0781/behaviorIntroCombatPage.unit.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expect } from 'chai'; | ||
import * as behaviorIntroCombatPage from '../../../pages/form0781/behaviorIntroCombatPage'; | ||
|
||
describe('Behavior Intro Page when Combat is the only type selected', () => { | ||
it('should define a uiSchema object', () => { | ||
expect(behaviorIntroCombatPage.uiSchema).to.be.an('object'); | ||
}); | ||
|
||
it('should define a schema object', () => { | ||
expect(behaviorIntroCombatPage.schema).to.be.an('object'); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
...ations/disability-benefits/all-claims/tests/pages/form0781/behaviorIntroPage.unit.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expect } from 'chai'; | ||
import * as behaviorIntroPage from '../../../pages/form0781/behaviorIntroPage'; | ||
|
||
describe('Behavior Intro Page', () => { | ||
it('should define a uiSchema object', () => { | ||
expect(behaviorIntroPage.uiSchema).to.be.an('object'); | ||
}); | ||
|
||
it('should define a schema object', () => { | ||
expect(behaviorIntroPage.schema).to.be.an('object'); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
...cations/disability-benefits/all-claims/tests/pages/form0781/behaviorListPage.unit.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expect } from 'chai'; | ||
import * as behaviorListPage from '../../../pages/form0781/behaviorListPage'; | ||
|
||
describe('Behavior List Page', () => { | ||
it('should define a uiSchema object', () => { | ||
expect(behaviorListPage.uiSchema).to.be.an('object'); | ||
}); | ||
|
||
it('should define a schema object', () => { | ||
expect(behaviorListPage.schema).to.be.an('object'); | ||
}); | ||
}); |
Oops, something went wrong.