Skip to content

Commit

Permalink
refactor: button for adding reporting requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
pbastia authored and BCerki committed May 13, 2022
1 parent fb1da5a commit 34e04af
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 36 deletions.
48 changes: 15 additions & 33 deletions app/components/Form/ProjectQuarterlyReportsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ import { useUpdateProjectContactFormChange } from "mutations/ProjectContact/upda
import useDiscardFormChange from "hooks/useDiscardFormChange";
import FormBase from "./FormBase";
import EmptyObjectFieldTemplate from "lib/theme/EmptyObjectFieldTemplate";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPlusCircle } from "@fortawesome/free-solid-svg-icons";

interface Props {
// query: ProjectQuarterlyReportsForm_query$key;
query: any;
onSubmit: () => void;
projectRevision: ProjectQuarterlyReportsForm_projectRevision$key;
}

const uiSchema = {
const quarterlyReportUiSchema = {
dueDate: {
"ui:col-md": 12,
"bcgov:size": "small",
},

submittedDate: {
"ui:col-md": 12,
"bcgov:size": "small",
Expand All @@ -47,8 +46,8 @@ const ProjectQuarterlyReportsForm: React.FC<Props> = (props) => {
fragment ProjectQuarterlyReportsForm_projectRevision on ProjectRevision {
id
rowId
quarterlyReportFormChanges(first: 500)
@connection(key: "connection_quarterlyReportFormChanges") {
projectQuarterlyReportFormChanges(first: 500)
@connection(key: "connection_projectQuarterlyReportFormChanges") {
__id
edges {
node {
Expand All @@ -67,31 +66,6 @@ const ProjectQuarterlyReportsForm: React.FC<Props> = (props) => {
`,
props.projectRevision
);
//brianna -- may need more/less in this query, TBD. Or do I need it all since the schema is so simple?
const { allQuarterlyReports } = useFragment(
graphql`
fragment ProjectQuarterlyReportsForm_query on Query {
allReportingRequirements(
filter: { reportType: { equalTo: "Quarterly" } }
) {
edges {
node {
id
submittedDate
comments
reportDueDate
reportTypeByReportType {
name
}
}
}
}
}
`,
props.query
);

console.log("projectRevision", projectRevision);

//brianna --do we need an all forms like ProjectContactForm? That one uses primary/secondary

Expand All @@ -117,11 +91,18 @@ const ProjectQuarterlyReportsForm: React.FC<Props> = (props) => {
</header>

<Grid cols={10} align="center">
<Grid.Row>Quarterly reports status here</Grid.Row>
<Grid.Row>
<Grid.Col span={10}>
<FormBorder>
<Grid.Row>
<Button variant="secondary">
<FontAwesomeIcon icon={faPlusCircle} /> Add another quarterly
report
</Button>
</Grid.Row>
<label>Quarterly Reports</label>
{projectRevision.quarterlyReportFormChanges.edges.map(
{projectRevision.projectQuarterlyReportFormChanges.edges.map(
({ node }) => {
console.log("node is", node);
return (
Expand All @@ -133,13 +114,14 @@ const ProjectQuarterlyReportsForm: React.FC<Props> = (props) => {
ref={(el) => (formRefs.current[node.id] = el)}
formData={node.newFormData}
onChange={(change) => {
console.log("change is", change);
// updateFormChange(
// { ...form, changeStatus: "pending" },
// change.formData
// );
}}
schema={quarterlyReportSchema as JSONSchema7}
uiSchema={uiSchema}
uiSchema={quarterlyReportUiSchema}
ObjectFieldTemplate={EmptyObjectFieldTemplate}
/>
</Grid.Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useRouter } from "next/router";
import { getProjectRevisionPageRoute } from "pageRoutes";
import TaskList from "components/TaskList";
import useRedirectTo404IfFalsy from "hooks/useRedirectTo404IfFalsy";
import { quarterlyReportsFormQuery } from "__generated__/quarterlyReportsFormQuery.graphql";

import ProjectQuarterlyReportsForm from "components/Form/ProjectQuarterlyReportsForm";

const pageQuery = graphql`
Expand All @@ -20,7 +20,6 @@ const pageQuery = graphql`
...ProjectQuarterlyReportsForm_projectRevision
...TaskList_projectRevision
}
...ProjectQuarterlyReportsForm_query
}
}
`;
Expand All @@ -43,7 +42,6 @@ export function ProjectQuarterlyReportsPage({
return (
<DefaultLayout session={query.session} leftSideNav={taskList}>
<ProjectQuarterlyReportsForm
query={query}
projectRevision={query.projectRevision}
onSubmit={handleSubmit}
/>
Expand Down
29 changes: 29 additions & 0 deletions app/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39713,6 +39713,7 @@ type ProjectRevision implements Node {
): ManagerFormChangesByLabelCompositeReturnsConnection!

"""
<<<<<<< HEAD
Computed column to return a project managers status for a project revision
"""
projectManagersStatus: String
Expand All @@ -39721,6 +39722,34 @@ type ProjectRevision implements Node {
Computed column to return a project overview status for a project revision
"""
projectOverviewStatus: String
=======
Computed column for graphql to retrieve the changes related to the quarterly reporting requirement records, within a project revision
"""
projectQuarterlyReportFormChanges(
"""Read all values in the set after (below) this cursor."""
after: Cursor

"""Read all values in the set before (above) this cursor."""
before: Cursor

"""
A filter to be used in determining which values should be returned by the collection.
"""
filter: FormChangeFilter

"""Only read the first `n` values of the set."""
first: Int

"""Only read the last `n` values of the set."""
last: Int

"""
Skip the first `n` values from our `after` cursor, an alternative to cursor
based pagination. May not be used with `last`.
"""
offset: Int
): FormChangesConnection!
>>>>>>> 8de1623 (refactor: button for adding reporting requirements)

"""Unique ID for the project revision"""
rowId: Int!
Expand Down
75 changes: 75 additions & 0 deletions app/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -135880,6 +135880,7 @@
"deprecationReason": null
},
{
<<<<<<< HEAD
"name": "projectManagersStatus",
"description": "Computed column to return a project managers status for a project revision",
"args": [],
Expand All @@ -135899,6 +135900,80 @@
"kind": "SCALAR",
"name": "String",
"ofType": null
=======
"name": "projectQuarterlyReportFormChanges",
"description": "Computed column for graphql to retrieve the changes related to the quarterly reporting requirement records, within a project revision",
"args": [
{
"name": "after",
"description": "Read all values in the set after (below) this cursor.",
"type": {
"kind": "SCALAR",
"name": "Cursor",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Read all values in the set before (above) this cursor.",
"type": {
"kind": "SCALAR",
"name": "Cursor",
"ofType": null
},
"defaultValue": null
},
{
"name": "filter",
"description": "A filter to be used in determining which values should be returned by the collection.",
"type": {
"kind": "INPUT_OBJECT",
"name": "FormChangeFilter",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Only read the first `n` values of the set.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Only read the last `n` values of the set.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "offset",
"description": "Skip the first `n` values from our `after` cursor, an alternative to cursor\nbased pagination. May not be used with `last`.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "FormChangesConnection",
"ofType": null
}
>>>>>>> 8de1623 (refactor: button for adding reporting requirements)
},
"isDeprecated": false,
"deprecationReason": null
Expand Down

0 comments on commit 34e04af

Please sign in to comment.