From dd9b2c007e690e3249719df574b6c79b4c29a7e9 Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Thu, 31 Aug 2023 15:26:07 -0700 Subject: [PATCH] Revert "chore: spec work" This reverts commit 7e35583d1077ede3d88b4e8c8c5d5bdf1eaa41c6. --- .../jsonSchemaForm/projectRevisionSchema.ts | 6 +- .../[projectRevision]/create.tsx | 169 +++--------------- 2 files changed, 24 insertions(+), 151 deletions(-) diff --git a/app/data/jsonSchemaForm/projectRevisionSchema.ts b/app/data/jsonSchemaForm/projectRevisionSchema.ts index f53e48c452..187674cfba 100644 --- a/app/data/jsonSchemaForm/projectRevisionSchema.ts +++ b/app/data/jsonSchemaForm/projectRevisionSchema.ts @@ -7,10 +7,8 @@ export const createProjectRevisionSchema = { type: "string", title: "Revision Type", default: undefined, - // anyOf: undefined, + anyOf: undefined, enum: undefined, - enumNames: undefined, - required: true, }, }, dependencies: { @@ -20,7 +18,6 @@ export const createProjectRevisionSchema = { properties: { revisionType: { const: !"Amendment", - title: "brianna", }, }, }, @@ -28,7 +25,6 @@ export const createProjectRevisionSchema = { properties: { revisionType: { const: "Amendment", - title: "brianna", }, amendmentTypes: { type: "array", diff --git a/app/pages/cif/project-revision/[projectRevision]/create.tsx b/app/pages/cif/project-revision/[projectRevision]/create.tsx index 8b5d00b5a3..a54f2467bb 100644 --- a/app/pages/cif/project-revision/[projectRevision]/create.tsx +++ b/app/pages/cif/project-revision/[projectRevision]/create.tsx @@ -15,7 +15,6 @@ import { useRouter } from "next/router"; import { getProjectRevisionFormPageRoute } from "routes/pageRoutes"; import { useCreateProjectRevision } from "mutations/ProjectRevision/createProjectRevision"; import EmptyObjectFieldTemplate from "lib/theme/EmptyObjectFieldTemplate"; -import ContextualHelp from "lib/theme/widgets/ContextualHelp"; const pageQuery = graphql` query createProjectRevisionQuery($projectRevision: ID!) { @@ -83,6 +82,16 @@ export function ProjectRevisionCreate({ }, }); }; + + const revisionEnum = allRevisionTypes.edges.map((e) => e.node.type); + createProjectRevisionSchema.properties.revisionType.enum = revisionEnum; + + const amendmentTypeEnum = allAmendmentTypes.edges.map((e) => e.node.name); + + const localSchema = JSON.parse(JSON.stringify(createProjectRevisionSchema)); + localSchema.dependencies.revisionType.oneOf[1].properties.amendmentTypes.items.enum = + amendmentTypeEnum; + const existingRevisionType = existingAmendment ? "Amendment" : existingGeneralRevision @@ -90,148 +99,20 @@ export function ProjectRevisionCreate({ : null; const disabledEnums = existingRevisionType ? [existingRevisionType] : []; - // ( - // <> - // {e.node.type} - // {disabledEnums.includes(e.node.type) && ( - // - // )} - // - // ); - - const revisionAnyOf = allRevisionTypes.edges.map((e) => { - return { - type: "string", - // title: ( - // <> - // {e.node.type} - // {disabledEnums.includes(e.node.type) && ( - // - // )} - // - // ), - title: "brai", - enum: [e.node.type], - }; - }); - - const revisionEnum = allRevisionTypes.edges.map((e) => e.node.type); - const revisionEnumNames = allRevisionTypes.edges.map((e) => { - return ( - <> - {e.node.type} - {disabledEnums.includes(e.node.type) && ( - - )} - - ); - }); - - // console.log("createProjectRevisionSchema", createProjectRevisionSchema); - // const amendmentTypeEnum = allAmendmentTypes.edges.map((e) => e.node.name); - - // const localSchema = JSON.parse(JSON.stringify(createProjectRevisionSchema)); - // localSchema.dependencies.revisionType.oneOf[1].properties.amendmentTypes.items.enum = - // amendmentTypeEnum; - createProjectRevisionSchema.properties.revisionType.enum = revisionEnum; - createProjectRevisionSchema.properties.revisionType.enumNames = - revisionEnumNames; - // console.log("createProjectRevisionSchema", createProjectRevisionSchema); - - // console.log("localSchema", localSchema); - - const schema = { - properties: { - field: { - type: "number", - anyOf: [ - { - type: "number", - title:
djd
, - enum: [1], - }, - { - type: "number", - title: "two", - enum: [2], - }, - { - type: "number", - title: "three", - enum: [3], - }, - ], - }, - }, - }; - // localSchema.properties.revisionType.anyOf = allRevisionTypes.edges.map( - // (e) => { - // const tooltipText = `
  • You cannot create a new ${ - // e.node.type - // } before the in-progress ${e.node.type} is ${ - // e.node.type === "Amendment" ? "approved" : "applied" - // }.
`; - // return { - // title: ( - // <> - // {e.node.type} - // {disabledEnums.includes(e.node.type) && ( - // - // )} - // - // ), - // const: e.node.type, - // }; - // } - // ); - - // createProjectRevisionSchema.properties.revisionType.anyOf = [ - // { - // type: "string", - // enum: [1], - // title:
djd
, - // }, - // { - // type: "string", - // title: "two", - // enum: [2], - // }, - // { - // type: "string", - // title: "three", - // enum: [3], - // }, - // ]; const modifiedUiSchema = { ...projectRevisionUISchema, - // revisionType: { - // ...projectRevisionUISchema.revisionType, - // "ui:enumDisabled": disabledEnums, - // ...(existingRevisionType && { - // "ui:tooltip": { - // text: `
  • You cannot create a new ${existingRevisionType} before the in-progress ${existingRevisionType} is ${ - // existingRevisionType === "Amendment" ? "approved" : "applied" - // }.
`, - // }, - // }), - // }, + revisionType: { + ...projectRevisionUISchema.revisionType, + "ui:enumDisabled": disabledEnums, + ...(existingRevisionType && { + "ui:tooltip": { + text: `
  • You cannot create a new ${existingRevisionType} before the in-progress ${existingRevisionType} is ${ + existingRevisionType === "Amendment" ? "approved" : "applied" + }.
`, + }, + }), + }, }; return ( @@ -243,12 +124,8 @@ export function ProjectRevisionCreate({ ) : (