Skip to content

Commit

Permalink
feat: create admin-2020 form schema
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-foucault committed Apr 30, 2021
1 parent 2406f9a commit 12854a0
Show file tree
Hide file tree
Showing 28 changed files with 873 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('When logged in as a reporter', () => {
it('The application admin tab has no detectable ally violations on load', () => {
cy.sqlFixture('fixtures/set-legal-disclaimer-true');
const applicationId = window.btoa('["applications",2]');
const formId = window.btoa('["form_jsons",1]');
const formId = window.btoa('["form_jsons",5]');
cy.visit(`/reporter/application/${applicationId}?formId=${formId}`);
cy.get('#page-content');
cy.contains('Administration');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('When viewing an application in draft as a reporter', () => {
)}`;

const adminFormUrl = `${applicationUrl}?formId=${window.btoa(
'["form_jsons",1]'
'["form_jsons",5]'
)}`;
const emissionFormUrl = `${applicationUrl}?formId=${window.btoa(
'["form_jsons",2]'
Expand Down
46 changes: 46 additions & 0 deletions app/server/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23609,6 +23609,18 @@ input DeleteFormJsonByRowIdInput {
rowId: Int!
}

"""All input for the `deleteFormJsonBySlug` mutation."""
input DeleteFormJsonBySlugInput {
"""
An arbitrary string value with no semantic meaning. Will be included in the
payload verbatim. May be used to track mutations by the client.
"""
clientMutationId: String

"""slug for the use as classname"""
slug: String!
}

"""All input for the `deleteFormJson` mutation."""
input DeleteFormJsonInput {
"""
Expand Down Expand Up @@ -29406,6 +29418,14 @@ type Mutation {
input: DeleteFormJsonByRowIdInput!
): DeleteFormJsonPayload

"""Deletes a single `FormJson` using a unique key."""
deleteFormJsonBySlug(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: DeleteFormJsonBySlugInput!
): DeleteFormJsonPayload

"""Deletes a single `FormResult` using its globally unique id."""
deleteFormResult(
"""
Expand Down Expand Up @@ -29824,6 +29844,14 @@ type Mutation {
input: UpdateFormJsonByRowIdInput!
): UpdateFormJsonPayload

"""Updates a single `FormJson` using a unique key and a patch."""
updateFormJsonBySlug(
"""
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.
"""
input: UpdateFormJsonBySlugInput!
): UpdateFormJsonPayload

"""
Updates a single `FormResult` using its globally unique id and a patch.
"""
Expand Down Expand Up @@ -35098,6 +35126,7 @@ type Query implements Node {
id: ID!
): FormJson
formJsonByRowId(rowId: Int!): FormJson
formJsonBySlug(slug: String!): FormJson

"""Reads a single `FormResult` using its globally unique `ID`."""
formResult(
Expand Down Expand Up @@ -38411,6 +38440,23 @@ input UpdateFormJsonByRowIdInput {
rowId: Int!
}

"""All input for the `updateFormJsonBySlug` mutation."""
input UpdateFormJsonBySlugInput {
"""
An arbitrary string value with no semantic meaning. Will be included in the
payload verbatim. May be used to track mutations by the client.
"""
clientMutationId: String

"""
An object where the defined keys will be set on the `FormJson` being updated.
"""
formJsonPatch: FormJsonPatch!

"""slug for the use as classname"""
slug: String!
}

"""All input for the `updateFormJson` mutation."""
input UpdateFormJsonInput {
"""
Expand Down
165 changes: 165 additions & 0 deletions app/server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -80782,6 +80782,41 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "DeleteFormJsonBySlugInput",
"description": "All input for the `deleteFormJsonBySlug` mutation.",
"fields": null,
"inputFields": [
{
"name": "clientMutationId",
"description": "An arbitrary string value with no semantic meaning. Will be included in the\npayload verbatim. May be used to track mutations by the client.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "slug",
"description": "slug for the use as classname",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "DeleteFormJsonInput",
Expand Down Expand Up @@ -102406,6 +102441,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "deleteFormJsonBySlug",
"description": "Deletes a single `FormJson` using a unique key.",
"args": [
{
"name": "input",
"description": "The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "DeleteFormJsonBySlugInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "DeleteFormJsonPayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "deleteFormResult",
"description": "Deletes a single `FormResult` using its globally unique id.",
Expand Down Expand Up @@ -103756,6 +103818,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateFormJsonBySlug",
"description": "Updates a single `FormJson` using a unique key and a patch.",
"args": [
{
"name": "input",
"description": "The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "UpdateFormJsonBySlugInput",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "UpdateFormJsonPayload",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updateFormResult",
"description": "Updates a single `FormResult` using its globally unique id and a patch.",
Expand Down Expand Up @@ -122319,6 +122408,33 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "formJsonBySlug",
"description": null,
"args": [
{
"name": "slug",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "FormJson",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "formResult",
"description": "Reads a single `FormResult` using its globally unique `ID`.",
Expand Down Expand Up @@ -133898,6 +134014,55 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "UpdateFormJsonBySlugInput",
"description": "All input for the `updateFormJsonBySlug` mutation.",
"fields": null,
"inputFields": [
{
"name": "clientMutationId",
"description": "An arbitrary string value with no semantic meaning. Will be included in the\npayload verbatim. May be used to track mutations by the client.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "formJsonPatch",
"description": "An object where the defined keys will be set on the `FormJson` being updated.",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "FormJsonPatch",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "slug",
"description": "slug for the use as classname",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "UpdateFormJsonInput",
Expand Down
13 changes: 6 additions & 7 deletions schema/data/prod/ciip_application_wizard.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
begin;

truncate table ggircs_portal.ciip_application_wizard;

with rows as (
insert into ggircs_portal.ciip_application_wizard
(form_id, form_position)
values
(1, 0),
(2, 1),
(3, 2),
(4, 3)
on conflict(form_id) do update
set
form_position=excluded.form_position
((select id from ggircs_portal.form_json where slug='admin-2020'), 0),
((select id from ggircs_portal.form_json where slug='emission'), 1),
((select id from ggircs_portal.form_json where slug='fuel'), 2),
((select id from ggircs_portal.form_json where slug='production'), 3)
returning 1
) select 'Inserted ' || count(*) || ' rows into ggircs_portal.ciip_application_wizard' from rows;

Expand Down
31 changes: 18 additions & 13 deletions schema/data/prod/form_json.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,32 @@ create temporary table fuel (json_data jsonb);
create temporary table production (json_data jsonb);
\copy production(json_data) from program 'sed ''s/\\/\\\\/g'' < prod/form_json/production.json | tr -d ''\n''';

create temporary table administration_2020 (json_data jsonb);
\copy administration_2020(json_data) from program 'sed ''s/\\/\\\\/g'' < prod/form_json/administration-2020.json | tr -d ''\n''';


with rows as (
insert into ggircs_portal.form_json
(id, name, slug, short_name, description, form_json, prepopulate_from_swrs, prepopulate_from_ciip, form_result_init_function, default_form_result)
overriding system value
(name, slug, short_name, description, form_json, prepopulate_from_swrs, prepopulate_from_ciip, form_result_init_function, default_form_result)
values
(1,
'Administration Data', 'admin', 'Admin data', 'Admin description',
('Administration Data', 'admin', 'Admin data', 'Admin description',
(select json_data from administration), true, true, 'init_application_administration_form_result', '{}'),
(2, 'Emission', 'emission', 'Emission', 'Emission description',
('Emission', 'emission', 'Emission', 'Emission description',
(select json_data from emission), true, false, 'init_application_emission_form_result', '{}'),
(3, 'Fuel','fuel', 'Fuel', 'Fuel description',
('Fuel','fuel', 'Fuel', 'Fuel description',
(select json_data from fuel), true, false, 'init_application_fuel_form_result', '[]'),
(4, 'Production', 'production', 'Production', 'Production description',
(select json_data from production), false, false, null, '[]')
on conflict(id) do update
set name=excluded.name, form_json=excluded.form_json,
prepopulate_from_ciip=excluded.prepopulate_from_ciip,
prepopulate_from_swrs=excluded.prepopulate_from_swrs,
slug=excluded.slug,
('Production', 'production', 'Production', 'Production description',
(select json_data from production), false, false, null, '[]'),
('Administration Data', 'admin-2020', 'Admin data', 'Admin description',
(select json_data from administration_2020), true, true, 'init_application_administration_form_result', '{}')
on conflict(slug) do update
set name=excluded.name,
short_name=excluded.short_name,
form_json=excluded.form_json,
description=excluded.description,
prepopulate_from_swrs=excluded.prepopulate_from_swrs,
prepopulate_from_ciip=excluded.prepopulate_from_ciip,
form_result_init_function=excluded.form_result_init_function,
default_form_result=excluded.default_form_result
returning 1
) select 'Inserted ' || count(*) || ' rows into ggircs_portal.form_json' from rows;
Expand Down
Loading

0 comments on commit 12854a0

Please sign in to comment.