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

Demo fixes #136

Merged
merged 24 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2b274f9
WIP
gardenFiend138 Sep 13, 2020
f0f4d04
RESET ME and clean up history
gardenFiend138 Sep 13, 2020
08596b2
Merges master into measure-index_85
alessandro-pianetta Sep 17, 2020
d1ecb24
Makes max inner element width 1440px
alessandro-pianetta Sep 19, 2020
081f795
Makes images at bottom of index smaller
alessandro-pianetta Sep 19, 2020
f895502
Changes referendum.js location to templates
alessandro-pianetta Sep 19, 2020
53a027a
Initial adaptation of referendum page and cleanup
alessandro-pianetta Sep 19, 2020
4be79b7
Merge branch 'master' of github.com:codeforsanjose/open-disclosure in…
alessandro-pianetta Sep 19, 2020
49e6c43
Merge branch 'measure-node' of github.com:codeforsanjose/open-disclos…
alessandro-pianetta Sep 19, 2020
553811e
Updates sidenav for referendums
alessandro-pianetta Sep 19, 2020
cf8c74f
Adds missing UI elements to referendum page
alessandro-pianetta Sep 20, 2020
14cd302
Merge branch 'master' of github.com:codeforsanjose/open-disclosure in…
alessandro-pianetta Sep 20, 2020
01c0b7f
Merges master into measure-index_85
alessandro-pianetta Sep 20, 2020
2214561
Merges measure-index_85 changes into demo-fixes
alessandro-pianetta Sep 20, 2020
3b9f6ce
Refactors Menu
alessandro-pianetta Sep 21, 2020
cc03d98
Adjusts findYourBallot padding
alessandro-pianetta Sep 21, 2020
64c3c80
Adjusts CandidateListItem padding and margins
alessandro-pianetta Sep 21, 2020
9c265a3
Removes menu on Candidate template and fixes ballotDesignation styling
alessandro-pianetta Sep 21, 2020
3a50923
Adjusts element padding on Candidate template and fixes discrepancies
alessandro-pianetta Sep 21, 2020
4158c72
Merges master into demo-fixes
alessandro-pianetta Sep 21, 2020
6d5ae70
Updates padding on landingPageHero
alessandro-pianetta Sep 21, 2020
e53768f
Creates Referendum nodes and updates Referendum page links
alessandro-pianetta Sep 21, 2020
5c88f1d
Addresses comments in PR
alessandro-pianetta Sep 22, 2020
bbd5892
Merge branch 'master' of github.com:codeforsanjose/open-disclosure in…
alessandro-pianetta Sep 22, 2020
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 gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ module.exports = {
{
resolve: "gatsby-plugin-slug-field",
options: {
filter: { internal: { type: "MeasuresJson" } },
source: "name",
filter: { internal: { type: "Referendum" } },
source: "Title",
fieldName: "slug",
},
},
Expand Down
76 changes: 49 additions & 27 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const CANDIDATE_NODE_TYPE = `Candidate`
const ELECTION_NODE_TYPE = `Election`
const METADATA_NODE_TYPE = `Metadata`
const OFFICE_ELECTION_NODE_TYPE = `OfficeElection`
const REFERENDUM_NODE_TYPE = `Referendum`

const DUMMY_DATA = {
candidates: {
Expand Down Expand Up @@ -93,6 +94,8 @@ async function fetchEndpoint(endpoint) {
`http://${HOSTNAME}/open-disclosure/api/v1.0/${endpoint}`
)
if (response.ok) {
// NOTE: If `gatsby develop` gives errors related to errors like `Cannot query field "fields" on type "OfficeElection"`, comment return DUMMY_DATA[endpoints] back in
// return DUMMY_DATA[endpoint]
return await response.json()
}
} catch (networkError) {
Expand Down Expand Up @@ -153,6 +156,22 @@ exports.sourceNodes = async ({
})
return id
}),
Referendums: election.Referendums.map(referendum => {
const id = createNodeId(`${REFERENDUM_NODE_TYPE}-${election.Date}`)

createNode({
...referendum,
id,
parent: null,
children: [],
internal: {
type: REFERENDUM_NODE_TYPE,
content: JSON.stringify(referendum),
contentDigest: createContentDigest(referendum),
},
})
return id
}),
id: createNodeId(`${ELECTION_NODE_TYPE}-${election.Date}`),
parent: null,
children: [],
Expand Down Expand Up @@ -199,17 +218,13 @@ exports.createPages = async ({ graphql, actions }) => {
}
}
}
}
}
}
allMeasuresJson {
edges {
node {
id
electionDate
name
fields {
slug
Referendums {
Title
Description
TotalContributions
fields {
slug
}
}
}
}
Expand All @@ -236,15 +251,15 @@ exports.createPages = async ({ graphql, actions }) => {
})
})
})
})
result.data.allMeasuresJson.edges.forEach(({ node }) => {
createPage({
path: `/${node.electionDate}/referendum/${node.fields.slug}`,
component: path.resolve("src/templates/measure.js"),
context: {
id: node.id,
slug: node.fields.slug,
},
node.Referendums.forEach(referendum => {
createPage({
path: `/${node.Date}/referendums/${referendum.fields.slug}`,
component: path.resolve("src/templates/referendum.js"),
context: {
slug: referendum.fields.slug,
id: referendum.ID,
},
})
})
})
}
Expand Down Expand Up @@ -275,18 +290,12 @@ exports.createSchemaCustomization = ({ actions }) => {
apiNode: Candidate @link(by: "ID" from: "id")
}

type MeasuresJson implements Node {
electionDate: String!
title: String!
description: String!
ballotLanguage: String!
}

Comment on lines -278 to -284
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to delete the JSON files entirely? That's fine if we're going to get all the data we need from the API, but I was under the impression we'd need to have some client-side data for the measure description, etc. If we no longer need that, let's also delete the json files under /src/data

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that was for the JSON; I'll put it back in.

type Election implements Node {
Title: String!
Date: String
TotalContributions: String
OfficeElections: [OfficeElection] @link
Referendums: [Referendum] @link
}

type OfficeElection implements Node {
Expand All @@ -295,6 +304,19 @@ exports.createSchemaCustomization = ({ actions }) => {
TotalContributions: String
}

type Referendum implements Node {
Title: String!
Description: String
Total_Contributions: String
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what the API returns? Can we ask to remove the underscore for consistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the API returns a "Total Contributions" key, I wasn't sure how to put that in since it threw an error when I used quotes, and I think it threw an error when I put it in two words too? I couldn't find how to define a string like that but I saw the _ being used elsewhere and it worked on the Referendums, so I left it in. Maybe we should get @geleazar1000111 to change the field to TotalContributions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sounds like we should get rid of the space on the backend if we can

}

type MeasuresJson implements Node {
electionDate: String!
title: String!
description: String!
ballotLanguage: String!
}

type Metadata implements Node{
DateProcessed: String!
}
Expand Down
28 changes: 0 additions & 28 deletions src/components/balanceDetails.js

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/balanceDetails.module.css

This file was deleted.

83 changes: 0 additions & 83 deletions src/components/ballotInfo.js

This file was deleted.

74 changes: 0 additions & 74 deletions src/components/ballotInfo.module.css

This file was deleted.

Loading