Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add review page accordions #244

Merged
merged 23 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bfa07b7
Add review page accordions
jasalisbury Dec 21, 2020
78702c1
Fix test, reset config options
jasalisbury Dec 21, 2020
5ccfee3
Fix the other failing frontend test
jasalisbury Dec 21, 2020
7a890a2
Merge branch 'main' into js-135-review-page-no-saving
jasalisbury Dec 23, 2020
63dfca3
Set sandbox branch
jasalisbury Dec 23, 2020
7e0b114
Merge branch 'main' into js-135-review-page-no-saving
jasalisbury Dec 23, 2020
fafe806
Add margin between multiselect box and label
jasalisbury Dec 23, 2020
d474c5d
Merge branch 'main' into js-135-review-page-no-saving
jasalisbury Jan 4, 2021
f6ea443
Rename title to role in approvers seeder
jasalisbury Jan 4, 2021
c3c48be
Remove duplicated user seeder
jasalisbury Jan 4, 2021
7a17a64
Merge branch 'main' into js-135-review-page-no-saving
jasalisbury Jan 5, 2021
233a3d2
Merge pull request #96 from adhocteam/js-135-review-page-no-saving
jasalisbury Jan 5, 2021
acfe889
Rename `admin/user` route to `admin/users`
jasalisbury Jan 5, 2021
b43b73c
Merge pull request #105 from adhocteam/js-fix-routes
jasalisbury Jan 5, 2021
9d88528
Update user auto inc in seeder
jasalisbury Jan 5, 2021
4640415
Set sandbox branch
jasalisbury Jan 5, 2021
df23f39
Update cucumber id
jasalisbury Jan 5, 2021
e4e9ab5
Set accessibility ci user as an admin
jasalisbury Jan 5, 2021
307ed4b
Review page fixes
jasalisbury Jan 5, 2021
8630fcd
Merge pull request #106 from adhocteam/js-fix-user-autoinc
jasalisbury Jan 6, 2021
a9e64c9
Remove empty approvingManagers and additionalNotes
jasalisbury Jan 6, 2021
b477bd3
Merge branch 'main' into js-review-page-feedback
jasalisbury Jan 6, 2021
91ce814
Merge pull request #107 from adhocteam/js-review-page-feedback
jasalisbury Jan 6, 2021
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ parameters:
description: "Name of github branch that will deploy to dev"
default: "main"
type: string
sandbox_git_branch: # change to feature branch to deploy to sandbox
default: "js-52-assign-permissions-backend"
sandbox_git_branch: # change to feature branch to test deployment
default: "js-fix-user-autoinc"
type: string
jobs:
build_and_lint:
Expand Down
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TTA_SMART_HUB_URI=http://localhost:3000
AUTH_BASE=https://uat.hsesinfo.org
# This env variable should go away soon in favor of TTA_SMART_HUB_URI
REDIRECT_URI_HOST=http://localhost:8080
CUCUMBER_USER_ID=999999;
CUCUMBER_USER_ID=1;
# NEW_RELIC_LICENSE_KEY can be omitted in local development
NEW_RELIC_LICENSE_KEY=secret_key
# Set to false to require user to go through auth flow, never true in production envs
Expand Down
39 changes: 38 additions & 1 deletion docs/openapi/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,41 @@ servers:
paths:
$ref: "./paths/index.yaml"
components:
schemas: {}
schemas:
approvingUser:
type: object
properties:
id:
type: number
name:
type: string
user:
type: object
properties:
id:
type: number
name:
type: string
hsesUserId:
type: number
email:
type: string
phoneNumber:
type: string
homeRegionId:
type: number
title:
type: string
permissions:
type: array
items:
$ref: '#/components/schemas/permission'
permission:
type: object
properties:
userId:
type: number
scopeId:
type: number
regionId:
type: number
14 changes: 14 additions & 0 deletions docs/openapi/paths/activity-reports/approvers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
get:
tags:
- activity-reports
operationId: getApproves
description: Gets all approvers for any region the current user has write permissions
responses:
200:
description: All approvers for any region the user has write permissions
content:
application/json:
schema:
type: array
items:
$ref: '../../index.yaml#/components/schemas/approvingUser'
12 changes: 6 additions & 6 deletions docs/openapi/paths/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ get:
application/json:
schema:
type: object
$ref: '#/definitions/user'
$ref: '../index.yaml#/components/schemas/user'
post:
tags:
- admin
Expand All @@ -29,15 +29,15 @@ post:
content:
application/json:
schema:
$ref: '#/definitions/user'
$ref: '../index.yaml#/components/schemas/user'
responses:
200:
description: User successfully created
content:
application/json:
schema:
type: object
$ref: '#/definitions/user'
$ref: '../index.yaml#/components/schemas/user'
put:
tags:
- admin
Expand All @@ -56,15 +56,15 @@ put:
content:
application/json:
schema:
$ref: '#/definitions/user'
$ref: '../index.yaml#/components/schemas/user'
responses:
200:
description: User successfully updated
content:
application/json:
schema:
type: object
$ref: '#/definitions/user'
$ref: '../index.yaml#/components/schemas/user'
delete:
tags:
- admin
Expand Down Expand Up @@ -105,7 +105,7 @@ definitions:
permissions:
type: array
items:
$ref: '#/definitions/permission'
$ref: '../index.yaml#/components/schemas/permission'
permission:
type: object
properties:
Expand Down
33 changes: 1 addition & 32 deletions docs/openapi/paths/adminAllUsers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,4 @@ get:
schema:
type: array
items:
$ref: '#/definitions/user'
definitions:
user:
type: object
properties:
id:
type: number
name:
type: string
hsesUserId:
type: number
email:
type: string
phoneNumber:
type: string
homeRegionId:
type: number
title:
type: string
permissions:
type: array
items:
$ref: '#/definitions/permission'
permission:
type: object
properties:
userId:
type: number
scopeId:
type: number
regionId:
type: number
$ref: '../index.yaml#/components/schemas/user'
2 changes: 2 additions & 0 deletions docs/openapi/paths/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
$ref: './admin.yaml'
'/admin/users':
$ref: './adminAllUsers.yaml'
'/activity-reports/approvers':
$ref: './activity-reports/approvers.yaml'
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"react-responsive": "^8.1.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-router-hash-link": "^2.3.1",
"react-router-prop-types": "^1.0.5",
"react-scripts": "^3.4.4",
"react-select": "^3.1.0",
Expand Down
47 changes: 26 additions & 21 deletions frontend/src/components/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import moment from 'moment';

import './DatePicker.css';

const dateFmt = 'MM/DD/YYYY';

const DateInput = ({
control, label, minDate, name, disabled, maxDate, openUp, required,
}) => {
Expand All @@ -30,8 +32,8 @@ const DateInput = ({
const openDirection = openUp ? OPEN_UP : OPEN_DOWN;

const isOutsideRange = (date) => {
const isBefore = minDate && date.isBefore(minDate);
const isAfter = maxDate && date.isAfter(maxDate);
const isBefore = minDate && date.isBefore(moment(minDate, dateFmt));
const isAfter = maxDate && date.isAfter(moment(maxDate, dateFmt));

return isBefore || isAfter;
};
Expand All @@ -41,23 +43,26 @@ const DateInput = ({
<Label id={labelId} htmlFor={name}>{label}</Label>
<div className="usa-hint" id={hintId}>mm/dd/yyyy</div>
<Controller
render={({ onChange, value, ref }) => (
<div className="display-flex smart-hub--date-picker-input">
<button onClick={() => { updateFocus(true); }} disabled={disabled} tabIndex={-1} aria-label="open calendar" type="button" className="usa-date-picker__button margin-top-0" />
<SingleDatePicker
id={name}
focused={isFocused}
date={value}
ref={ref}
isOutsideRange={isOutsideRange}
numberOfMonths={1}
openDirection={openDirection}
disabled={disabled}
onDateChange={onChange}
onFocusChange={({ focused }) => updateFocus(focused)}
/>
</div>
)}
render={({ onChange, value, ref }) => {
const date = value ? moment(value, dateFmt) : null;
return (
<div className="display-flex smart-hub--date-picker-input">
<button onClick={() => { updateFocus(true); }} disabled={disabled} tabIndex={-1} aria-label="open calendar" type="button" className="usa-date-picker__button margin-top-0" />
<SingleDatePicker
id={name}
focused={isFocused}
date={date}
ref={ref}
isOutsideRange={isOutsideRange}
numberOfMonths={1}
openDirection={openDirection}
disabled={disabled}
onDateChange={(d) => { onChange(d.format(dateFmt)); }}
onFocusChange={({ focused }) => updateFocus(focused)}
/>
</div>
);
}}
control={control}
name={name}
disabled={disabled}
Expand All @@ -76,8 +81,8 @@ DateInput.propTypes = {
control: PropTypes.object.isRequired,
name: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
minDate: PropTypes.instanceOf(moment),
maxDate: PropTypes.instanceOf(moment),
minDate: PropTypes.string,
maxDate: PropTypes.string,
openUp: PropTypes.bool,
disabled: PropTypes.bool,
required: PropTypes.bool,
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function MultiSelect({
}
return (
<Select
className="margin-top-1"
id={name}
value={values}
onChange={(e) => {
Expand Down Expand Up @@ -96,7 +97,10 @@ MultiSelect.propTypes = {
name: PropTypes.string.isRequired,
options: PropTypes.arrayOf(
PropTypes.shape({
value: PropTypes.string.isRequired,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]).isRequired,
label: PropTypes.string.isRequired,
}),
).isRequired,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Navigator/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const pages = [
path: 'review',
label: 'review page',
review: true,
render: (allComplete, onSubmit) => (
render: (allComplete, formData, submitted, onSubmit) => (
<div>
<button type="button" data-testid="review" onClick={onSubmit}>Continue</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Navigator/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Form({
return (
<UswdsForm onSubmit={handleSubmit(onContinue)} className="smart-hub--form-large">
{renderForm(hookForm)}
<Button className="stepper-button" type="submit" disabled={!formState.isValid}>Continue</Button>
<Button type="submit" disabled={!formState.isValid}>Continue</Button>
</UswdsForm>
);
}
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/Navigator/components/SideNav.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,11 @@
top: -2.5rem;
transition: 0.2s ease-in-out;
}

.smart-hub--navigator-item:first-child .smart-hub--navigator-link-active {
border-top-right-radius: 4px;
}

.smart-hub--navigator-item:last-child .smart-hub--navigator-link-active {
border-bottom-right-radius: 4px;
}
25 changes: 10 additions & 15 deletions frontend/src/components/Navigator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
The navigator is a component used to show multiple form pages. It displays a stickied nav window
on the left hand side with each page of the form listed. Clicking on an item in the nav list will
display that item in the content section. The navigator keeps track of the "state" of each page.
In the future logic will be added to the navigator to prevent the complete form from being
submitted until every page is completed.
*/
import React, { useState, useCallback } from 'react';
import PropTypes from 'prop-types';
Expand All @@ -19,10 +17,6 @@ import SideNav from './components/SideNav';
import Form from './components/Form';
import IndicatorHeader from './components/IndicatorHeader';

/*
Get the current state of navigator items. Sets the currently selected item as "In Progress" and
sets a "current" flag which the side nav uses to style the selected component as selected.
*/
function Navigator({
defaultValues,
pages,
Expand All @@ -31,6 +25,7 @@ function Navigator({
submitted,
currentPage,
updatePage,
additionalData,
}) {
const [formData, updateFormData] = useState(defaultValues);
const [pageState, updatePageState] = useState(initialPageState);
Expand Down Expand Up @@ -80,13 +75,12 @@ function Navigator({
/>
</Grid>
<Grid col={12} tablet={{ col: 6 }} desktop={{ col: 8 }}>
<Container skipTopPadding>
<div id="navigator-form">
{page.review
&& page.render(allComplete, onSubmit)}
{!page.review
<div id="navigator-form">
{page.review
&& page.render(allComplete, formData, submitted, onSubmit, additionalData)}
{!page.review
&& (
<>
<Container skipTopPadding>
<IndicatorHeader
currentStep={page.position}
totalSteps={pages.filter((p) => !p.review).length}
Expand All @@ -100,10 +94,9 @@ function Navigator({
saveForm={onSaveForm}
renderForm={page.render}
/>
</>
</Container>
)}
</div>
</Container>
</div>
</Grid>
</Grid>
);
Expand All @@ -122,10 +115,12 @@ Navigator.propTypes = {
).isRequired,
currentPage: PropTypes.string.isRequired,
updatePage: PropTypes.func.isRequired,
additionalData: PropTypes.shape({}),
};

Navigator.defaultProps = {
defaultValues: {},
additionalData: {},
};

export default Navigator;
Loading