Skip to content

Commit

Permalink
Changed validationStatus to submissionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
zachsa committed Jul 23, 2021
1 parent 031ba69 commit 86236e7
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ begin
create table Submissions (
_id int not null unique identity,
id uniqueidentifier not null primary key default (newsequentialid()),
validationStatus nvarchar(4000),
validationComments nvarchar(max),
submissionStatus nvarchar(4000),
submissionComments nvarchar(max),
submissionType nvarchar(255),
project nvarchar(max),
mitigation nvarchar(max),
Expand All @@ -244,7 +244,7 @@ create table Submissions (
index ix_submissions nonclustered (id),
index ix_submissions_id nonclustered (id),
constraint json_research check( isjson(research) = 1),
constraint json_validationStatus check( isjson(validationStatus) = 1),
constraint json_submissionStatus check( isjson(submissionStatus) = 1),
constraint json_project check( isjson(project) = 1),
constraint json_mitigation check( isjson(mitigation) = 1),
constraint json_Adaptation check( isjson(adaptation) = 1)
Expand Down
22 changes: 11 additions & 11 deletions src/api/src/graphql/resolvers/mutations/save-submission/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default async (
mitigation = {},
adaptation = {},
isSubmitted = false,
validationStatus = undefined,
validationComments = '',
submissionStatus = undefined,
submissionComments = '',
},
ctx
) => {
Expand All @@ -26,11 +26,11 @@ export default async (
'${sanitizeSqlValue(JSON.stringify(adaptation))}' adaptation,
${isSubmitted ? 1 : 0} isSubmitted,
${
validationStatus
? `'${sanitizeSqlValue(JSON.stringify(validationStatus))}' validationStatus,`
submissionStatus
? `'${sanitizeSqlValue(JSON.stringify(submissionStatus))}' submissionStatus,`
: ''
}
'${sanitizeSqlValue(validationComments)}' validationComments,
'${sanitizeSqlValue(submissionComments)}' submissionComments,
${userId} createdBy,
'${new Date().toISOString()}' createdAt
) s on t.id = '${sanitizeSqlValue(submissionId)}'
Expand All @@ -39,8 +39,8 @@ export default async (
mitigation,
adaptation,
isSubmitted,
${validationStatus ? 'validationStatus,' : ''}
validationComments,
${submissionStatus ? 'submissionStatus,' : ''}
submissionComments,
createdBy,
createdAt
)
Expand All @@ -49,8 +49,8 @@ export default async (
s.mitigation,
s.adaptation,
s.isSubmitted,
${validationStatus ? 's.validationStatus,' : ''}
validationComments,
${submissionStatus ? 's.submissionStatus,' : ''}
submissionComments,
s.createdBy,
s.createdAt
)
Expand All @@ -59,8 +59,8 @@ export default async (
t.mitigation = s.mitigation,
t.adaptation = s.adaptation,
t.isSubmitted = s.isSubmitted,
${validationStatus ? 't.validationStatus = s.validationStatus,' : ''}
t.validationComments = s.validationComments
${submissionStatus ? 't.submissionStatus = s.submissionStatus,' : ''}
t.submissionComments = s.submissionComments
output
$action,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default async ctx => {

for (const {
_id,
validationStatus,
validationComments,
submissionStatus,
submissionComments,
submissionType,
project,
mitigation,
Expand Down Expand Up @@ -75,8 +75,8 @@ export default async ctx => {
using (
select
${_id} _id,
'${sanitizeSqlValue(makeValidationStatus(validationStatus))}' validationStatus,
'${sanitizeSqlValue(validationComments)}' validationComments,
'${sanitizeSqlValue(makeValidationStatus(submissionStatus))}' submissionStatus,
'${sanitizeSqlValue(submissionComments)}' submissionComments,
'${sanitizeSqlValue(submissionType)}' submissionType,
'${sanitizeSqlValue(makeProjectJson(project))}' project,
'${sanitizeSqlValue(makeMitigationJson(mitigation))}' mitigation,
Expand All @@ -93,8 +93,8 @@ export default async ctx => {
) s on s._id = t._id
when not matched then insert (
_id,
validationStatus,
validationComments,
submissionStatus,
submissionComments,
submissionType,
project,
mitigation,
Expand All @@ -107,8 +107,8 @@ export default async ctx => {
)
values (
s._id,
s.validationStatus,
s.validationComments,
s.submissionStatus,
s.submissionComments,
s.submissionType,
s.project,
s.mitigation,
Expand All @@ -120,8 +120,8 @@ export default async ctx => {
s.createdAt
)
when matched then update set
t.validationStatus = s.validationStatus,
t.validationComments = s.validationComments,
t.submissionStatus = s.submissionStatus,
t.submissionComments = s.submissionComments,
t.submissionType = s.submissionType,
t.project = s.project,
t.mitigation = s.mitigation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
when 1 then 'project'
when 2 then 'research'
end submissionType,
p.VALIDATIONCOMMENTS validationComments,
(select ItemDisplay from tb_erm_picklist l join tb_erm_picklist_value v on v.ListId = l.ListId where l.ListName = 'DEAT Validation Status' and ItemNum = p.ValidationStatus) validationStatus,
p.VALIDATIONCOMMENTS submissionComments,
(select ItemDisplay from tb_erm_picklist l join tb_erm_picklist_value v on v.ListId = l.ListId where l.ListName = 'DEAT Validation Status' and ItemNum = p.ValidationStatus) submissionStatus,
(select * from projectDetails _p where _p.ProjectDetailsId = p.ProjectDetailsId for json path, without_array_wrapper) project,
(select * from mitigationDetails _m where _m.ProjectDetailsId = p.ProjectDetailsId for json path, without_array_wrapper) mitigation,
(select * from adaptationDetails _a where _a.ProjectDetailsId = p.ProjectDetailsId for json path, without_array_wrapper) adaptation,
Expand Down
14 changes: 7 additions & 7 deletions src/api/src/graphql/resolvers/queries/submissions/_base-query.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default ({
isSubmitted = true,
validationStatus = undefined,
submissionStatus = undefined,
projectFilters: {
title: { value: titleFilter = undefined } = {},
province: { value: provinceFilter = undefined } = {},
validationStatus: { value: validationStatusFilter = undefined } = {},
submissionStatus: { value: submissionStatusFilter = undefined } = {},
...projectVocabularyFilters
} = {},
mitigationFilters: { ...mitigationVocabularyFilters } = {},
Expand All @@ -16,8 +16,8 @@ export default ({
deletedAt is null
and isSubmitted = ${isSubmitted ? 1 : 0}
${
validationStatus
? `and json_value(validationStatus, '$.term') = '${sanitizeSqlValue(validationStatus)}'`
submissionStatus
? `and json_value(submissionStatus, '$.term') = '${sanitizeSqlValue(submissionStatus)}'`
: ''
}
${titleFilter ? `and _projectTitle like '%${sanitizeSqlValue(titleFilter)}%'` : ''}
Expand All @@ -36,9 +36,9 @@ export default ({
: ''
}
${
validationStatusFilter
? `and json_value(validationStatus, '$.term') = '${sanitizeSqlValue(
validationStatusFilter
submissionStatusFilter
? `and json_value(submissionStatus, '$.term') = '${sanitizeSqlValue(
submissionStatusFilter
)}'`
: ''
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/src/graphql/resolvers/types/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
project: async ({ project = {} }) => JSON.parse(project),
mitigation: async ({ mitigation = {} }) => JSON.parse(mitigation),
adaptation: async ({ adaptation = {} }) => JSON.parse(adaptation),
validationStatus: async ({ validationStatus = {} }) => JSON.parse(validationStatus),
submissionStatus: async ({ submissionStatus = {} }) => JSON.parse(submissionStatus),

/**
* I think I only ever care about the userId
Expand Down
12 changes: 6 additions & 6 deletions src/api/src/graphql/schema/type-defs/main.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ type Submission {
id: ID!
_id: Int
isSubmitted: Boolean
validationStatus: JSON
validationComments: String
submissionStatus: JSON
submissionComments: String
project: JSON
mitigation: JSON
adaptation: JSON
Expand All @@ -90,7 +90,7 @@ type Query {
submission(id: ID!, isSubmitted: Boolean): Submission!
# Page info (pagination) for a particular search
pageInfo(
validationStatus: String
submissionStatus: String
projectFilters: JSON
mitigationFilters: JSON
adaptationFilters: JSON
Expand All @@ -100,7 +100,7 @@ type Query {
): PageInfo!
# Search submissions
submissions(
validationStatus: String
submissionStatus: String
projectFilters: JSON
mitigationFilters: JSON
adaptationFilters: JSON
Expand All @@ -127,8 +127,8 @@ type Mutation {
mitigation: JSON
adaptation: JSON
isSubmitted: Boolean
validationStatus: JSON
validationComments: String
submissionStatus: JSON
submissionComments: String
): Submission
killServer: Void
migrateDatabase(dropSchema: Boolean): JSON!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async (userId, { project, mitigation = {}, adaptation = {} }) =>
'${sanitizeSqlValue(JSON.stringify(mitigation))}' mitigation,
'${sanitizeSqlValue(JSON.stringify(adaptation))}' adaptation,
1 isSubmitted,
'${sanitizeSqlValue(JSON.stringify({ term: 'Pending' }))}' validationStatus,
'${sanitizeSqlValue(JSON.stringify({ term: 'Pending' }))}' submissionStatus,
${userId} createdBy,
'${new Date().toISOString()}' createdAt
) s on t.id = null
Expand All @@ -19,7 +19,7 @@ export default async (userId, { project, mitigation = {}, adaptation = {} }) =>
mitigation,
adaptation,
isSubmitted,
validationStatus,
submissionStatus,
createdBy,
createdAt
)
Expand All @@ -28,7 +28,7 @@ export default async (userId, { project, mitigation = {}, adaptation = {} }) =>
s.mitigation,
s.adaptation,
s.isSubmitted,
s.validationStatus,
s.submissionStatus,
s.createdBy,
s.createdAt
)
Expand Down
18 changes: 9 additions & 9 deletions src/client/src/components/project-form/context/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default ({
debounce(async ({ project, mitigation, adaptation }) => {
setSyncing(true)

const { __validationStatus: validationStatus, __validationComments: validationComments } =
const { __submissionStatus: submissionStatus, __submissionComments: submissionComments } =
project

const {
Expand All @@ -181,26 +181,26 @@ export default ({
$project: JSON
$mitigation: JSON
$adaptation: JSON
$validationStatus: JSON
$validationComments: String
$submissionStatus: JSON
$submissionComments: String
$isSubmitted: Boolean
) {
saveSubmission(
submissionId: $submissionId
project: $project
mitigation: $mitigation
adaptation: $adaptation
validationStatus: $validationStatus
validationComments: $validationComments
submissionStatus: $submissionStatus
submissionComments: $submissionComments
isSubmitted: $isSubmitted
) {
id
isSubmitted
project
mitigation
adaptation
validationStatus
validationComments
submissionStatus
submissionComments
}
}
`,
Expand All @@ -209,8 +209,8 @@ export default ({
project: convertFormToGqlInput(project),
mitigation: convertFormToGqlInput(mitigation),
adaptation: convertFormToGqlInput(adaptation),
validationStatus,
validationComments,
submissionStatus,
submissionComments,
isSubmitted,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const LocationsPicker = lazy(() => import('../../form/components/locations-picke

const multilineFields = [
'description',
'__validationComments',
'__submissionComments',
'projectManagerPhysicalAddress',
'projectManagerPostalAddress',
]
Expand Down Expand Up @@ -111,40 +111,40 @@ export default ({ field }) => {
/**
* Controlled vocabulary
*/
if (fieldName === '__validationStatus') {
if (!form.__validationStatus) {
setImmediate(() => updateForm({ __validationStatus: { term: 'Pending' } }))
if (fieldName === '__submissionStatus') {
if (!form.__submissionStatus) {
setImmediate(() => updateForm({ __submissionStatus: { term: 'Pending' } }))
return null
}
return (
<ControlledVocabularySelect
key={fieldName}
tree={'projectValidationStatus'}
root="Validation Status"
name={'Validation status'}
name={'Submission status'}
disabled={!hasPermission('validate-submission')}
value={value}
error={isRequired && !value}
onChange={val => updateForm({ [fieldName]: val })}
placeholder={'Validation status '}
helperText={'Has this project been validated?'}
placeholder={'Submission status '}
helperText={'Has this submission been validated?'}
/>
)
}

/**
* Validation comments (limited user access)
*/
if (fieldName === '__validationComments') {
if (fieldName === '__submissionComments') {
return (
<StringField
disabled={!hasPermission('validate-submission')}
error={isRequired && !value}
multiline={multilineFields.includes(fieldName)}
rows={4}
placeholder={'Validation comments'}
helperText={'Please leave comments RE. the validation status'}
name={'Validation comments'}
placeholder={'Submission comments'}
helperText={'Please leave comments RE. the submission status'}
name={'Submission comments'}
key={fieldName}
value={value}
setValue={val => updateForm({ [fieldName]: val })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Compose = memo(({ fields }) => (
'projectManagerTelephone',
'projectManagerMobile',
],
'Validation status': ['__validationStatus', '__validationComments'],
'Validation status': ['__submissionStatus', '__submissionComments'],
}}
/>
))
Expand Down
Loading

0 comments on commit 86236e7

Please sign in to comment.