From 5da287a0d9f91757c83012d2d833859c473d53f9 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Wed, 15 Feb 2017 16:52:56 -0500 Subject: [PATCH 01/10] Remove old actions from Building container --- src/containers/Building/actions.js | 134 ----------------------------- 1 file changed, 134 deletions(-) diff --git a/src/containers/Building/actions.js b/src/containers/Building/actions.js index 28840a22..7dfe412e 100644 --- a/src/containers/Building/actions.js +++ b/src/containers/Building/actions.js @@ -3,15 +3,6 @@ import { LOAD_BUILDING_DETAIL, LOAD_BUILDING_DETAIL_SUCCEES, LOAD_BUILDING_DETAIL_ERROR, - LOAD_HIT, - LOAD_HIT_SUCCESS, - LOAD_HIT_ERROR, - CREATE_HIT, - CREATE_HIT_SUCCESS, - CREATE_HIT_ERROR, - DECIDE_HIT, - DECIDE_HIT_SUCCESS, - DECIDE_HIT_ERROR, } from './constants'; /** @@ -55,128 +46,3 @@ export function buildingDetailLoadingError(error) { error, }; } - -/** - * Load status of HIT - * TODO The HIT status should be loaded from the building detail route - * - * @param {string} buildingId The current buildingID - * @returns {object} An action object with a type of - * LOAD_HIT passing the building_id - */ -export function loadHit(buildingId) { - return { - type: LOAD_HIT, - payload: buildingId, - }; -} - -/** - * Dispatched when the hit status was successfully loaded - * - * @param {string} hitStatus The HIT status - * @returns {object} An action object with a type of - * LOAD_HIT_SUCCESS passing the hit status - */ -export function hitLoaded(hitStatus) { - return { - type: LOAD_HIT_SUCCESS, - payload: hitStatus, - }; -} - -/** - * Dispatched when loading the hit status fails - * - * @param {object} error The error - * @returns {object} An action object with a type of - * LOAD_HIT passing the hit status - */ -export function hitLoadingError(error) { - return { - type: LOAD_HIT_ERROR, - error, - }; -} - -/** - * Create mturk HIT, this action starts the request saga - * - * @param {object} formData The mturk form data - * @returns {object} An action object with a type of CREATE_HIT - */ -export function createHit(formData) { - return { - type: CREATE_HIT, - payload: formData, - }; -} - -/** - * Dispatched when the mturk HIT was successfully created - * - * @param {object} hitData The created hit data - * @returns {object} An action object with a type of CREATE_HIT_SUCCESS - */ -export function createHitSuccess(hitData) { - return { - type: CREATE_HIT_SUCCESS, - payload: hitData, - }; -} - -/** - * Dispatched when creating the mturk HIT fails - * - * @param {object} error The error - * @return {object} An action object with a type of CREATE_HIT_ERROR - * passing the error - */ -export function createHitError(error) { - return { - type: CREATE_HIT_ERROR, - error, - }; -} - -/** - * Dispatched when user selects approve or reject HIT - * - * @param {int} buildingId Id of building - * @param {int} decision 1 or 0 representing approve or reject - * @returns {object} An action object with a type of DECIDE_HIT - * passing the decision of the user - */ -export function hitDecision(buildingId, decision) { - return { - type: DECIDE_HIT, - buildingId, - decision, - }; -} - -/** - * Dispatched when the hit was successfully approved or disapproved - * - * @returns {object} - */ -export function hitDecisionSuccess(data) { - return { - type: DECIDE_HIT_SUCCESS, - payload: data, - }; -} - -/** - * Dispatched when there is a error approving or rejecting a HIT - * - * @param error The error - * @returns {object} An action object with a type of DECIDE_HIT_ERROR - * passing the error - */ -export function hitDecisionError(error) { - return { - type: DECIDE_HIT_ERROR, - error, - }; -} -- GitLab From b4c0708c15ff2e3e09b336c6a65f71f58c17cef0 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Thu, 16 Feb 2017 16:32:35 -0500 Subject: [PATCH 02/10] Add projects actions and reducer to building container --- src/containers/Building/actions.js | 28 ++++++++++++++-- src/containers/Building/constants.js | 3 ++ src/containers/Building/index.js | 27 +++++++++++---- src/containers/Building/propTypes.js | 50 ++++++++++++++++++++-------- src/containers/Building/reducer.js | 36 ++++++++++++++++++++ src/sagas.js | 2 +- 6 files changed, 122 insertions(+), 24 deletions(-) diff --git a/src/containers/Building/actions.js b/src/containers/Building/actions.js index 7dfe412e..6b239eea 100644 --- a/src/containers/Building/actions.js +++ b/src/containers/Building/actions.js @@ -3,6 +3,9 @@ import { LOAD_BUILDING_DETAIL, LOAD_BUILDING_DETAIL_SUCCEES, LOAD_BUILDING_DETAIL_ERROR, + LOAD_PROJECTS, + LOAD_PROJECTS_SUCCESS, + LOAD_PROJECTS_ERROR, } from './constants'; /** @@ -12,10 +15,10 @@ import { * @returns {object} An action object with a type of LOAD_BUILDING_DETAIL * passing the building detail */ -export function loadBuildingDetail(buildingID) { +export function loadBuildingDetail(buildingId) { return { type: LOAD_BUILDING_DETAIL, - payload: buildingID, + payload: buildingId, }; } @@ -46,3 +49,24 @@ export function buildingDetailLoadingError(error) { error, }; } + +export function loadProjects(buildingId) { + return { + type: LOAD_PROJECTS, + buildingId, + }; +} + +export function projectsLoaded(projects) { + return { + type: LOAD_PROJECTS_SUCCESS, + payload: projects.data, + }; +} + +export function projectsLoadingError(error) { + return { + type: LOAD_PROJECTS_ERROR, + error, + }; +} diff --git a/src/containers/Building/constants.js b/src/containers/Building/constants.js index 25650cab..9ec88499 100644 --- a/src/containers/Building/constants.js +++ b/src/containers/Building/constants.js @@ -1,3 +1,6 @@ export const LOAD_BUILDING_DETAIL = 'LOAD_BUILDING_DETAIL'; export const LOAD_BUILDING_DETAIL_SUCCEES = 'LOAD_BUILDING_DETAIL_SUCCEES'; export const LOAD_BUILDING_DETAIL_ERROR = 'LOAD_BUILDING_DETAIL_ERROR'; +export const LOAD_PROJECTS = 'LOAD_PROJECTS'; +export const LOAD_PROJECTS_SUCCESS = 'LOAD_PROJECTS_SUCCESS'; +export const LOAD_PROJECTS_ERROR = 'LOAD_PROJECTS_ERROR'; diff --git a/src/containers/Building/index.js b/src/containers/Building/index.js index 63b5d823..cb907095 100644 --- a/src/containers/Building/index.js +++ b/src/containers/Building/index.js @@ -2,8 +2,8 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import buildingDetailPropTypes from './propTypes'; -import { loadBuildingDetail } from './actions'; +import { overviewPropTypes, projectPropTypes, loadErrorPropTypes } from './propTypes'; +import { loadBuildingDetail, loadProjects } from './actions'; import documentsPropType from '../Documents/propTypes'; import { loadDocuments, uploadDocument } from '../Documents/actions'; @@ -15,15 +15,17 @@ import './styles.css'; class Building extends Component { componentDidMount() { this.props.loadBuildingDetail(this.props.buildingId); + this.props.loadProjects(this.props.buildingId); } render() { - const { error, loading, address } = this.props.buildingDetail.overview; + const { error, loading, address } = this.props.overview; let mainContent =
; if (this.props.children && !error && !loading && address !== undefined) { mainContent = React.cloneElement(this.props.children, { buildingId: this.props.buildingId, - building: this.props.buildingDetail.overview, + building: this.props.overview, + projects: this.props.projects, documents: this.props.documents, getDocuments: this.props.loadDocuments, uploadDocument: this.props.uploadDocument, @@ -33,7 +35,7 @@ class Building extends Component { return (
- +
Date: Thu, 16 Feb 2017 18:25:32 -0500 Subject: [PATCH 03/10] Add ProjectCard --- src/components/BuildingOverview/index.js | 79 ++++++++++++-------- src/components/BuildingOverview/styles.css | 3 + src/components/DocumentCardViewer/index.js | 2 +- src/components/DocumentCardViewer/styles.css | 3 +- src/components/ProjectCard/index.js | 25 +++++++ src/components/ProjectCard/styles.css | 0 src/containers/Building/index.js | 6 +- src/containers/Building/propTypes.js | 22 ++++-- src/containers/Building/sagas.js | 52 +++++++++++-- src/containers/Documents/reducer.js | 1 + 10 files changed, 142 insertions(+), 51 deletions(-) create mode 100644 src/components/ProjectCard/index.js create mode 100644 src/components/ProjectCard/styles.css diff --git a/src/components/BuildingOverview/index.js b/src/components/BuildingOverview/index.js index df9a359b..7db868e6 100644 --- a/src/components/BuildingOverview/index.js +++ b/src/components/BuildingOverview/index.js @@ -1,6 +1,11 @@ import React, { Component, PropTypes } from 'react'; import documentsPropType from '../../containers/Documents/propTypes'; import DocumentCardViewer from '../../components/DocumentCardViewer'; +import ProjectCard from '../ProjectCard'; +import { + completeProjectPropTypes, + completeOverviewPropTypes, +} from '../../containers/Building/propTypes'; import './styles.css'; @@ -15,31 +20,51 @@ export default class BuildingOverview extends Component { }; } - render() { - const { building } = this.props; + /* eslint-disable jsx-a11y/anchor-has-content */ + /* eslint-disable jsx-a11y/href-no-hash */ + renderProjects = () => { + const projectList = this.props.projects.list; + if (projectList.length <= 0) { + return ( +
+ +
+ ); + } + + return projectList.map(project => ( + + )); + } + render() { return ( -
-
-

- {building.address} -

-
    -
  • Zipcode: {building.zipcode}
  • -
  • BBL: {building.bbl}
  • -
  • Building ID: {building.building_id}
  • -
  • Lot ID: {building.lot_id}
  • -
  • Borough: {building.borough}
  • -
+
+
+
+
+
Projects
+ {this.renderProjects()} +
+
+ +
+ +
+
+
+
-
); } @@ -47,14 +72,8 @@ export default class BuildingOverview extends Component { BuildingOverview.propTypes = { buildingId: PropTypes.string, - building: PropTypes.shape({ - address: PropTypes.string, - bbl: PropTypes.number, - building_id: PropTypes.number, - lot_id: PropTypes.number, - borough: PropTypes.string, - zipcode: PropTypes.number, - }), + building: completeOverviewPropTypes, + projects: completeProjectPropTypes, documents: documentsPropType, getDocuments: PropTypes.func, uploadDocument: PropTypes.func, diff --git a/src/components/BuildingOverview/styles.css b/src/components/BuildingOverview/styles.css index e69de29b..eb9fe827 100644 --- a/src/components/BuildingOverview/styles.css +++ b/src/components/BuildingOverview/styles.css @@ -0,0 +1,3 @@ +.column { + flex: 0.33; +} diff --git a/src/components/DocumentCardViewer/index.js b/src/components/DocumentCardViewer/index.js index a17ec11a..73a605e5 100644 --- a/src/components/DocumentCardViewer/index.js +++ b/src/components/DocumentCardViewer/index.js @@ -87,7 +87,7 @@ export default class DocumentCardViewer extends Component { render() { const { error, uploadError } = this.props.documents; return ( -
+
{ + const { project } = props; + + return ( + + ); +}; + +ProjectCard.propTypes = { + project: PropTypes.shape(projectPropTypes), +}; + +export default ProjectCard; diff --git a/src/components/ProjectCard/styles.css b/src/components/ProjectCard/styles.css new file mode 100644 index 00000000..e69de29b diff --git a/src/containers/Building/index.js b/src/containers/Building/index.js index cb907095..0eb1f9a9 100644 --- a/src/containers/Building/index.js +++ b/src/containers/Building/index.js @@ -33,11 +33,11 @@ class Building extends Component { } return ( -
-
+
+
-
+
Date: Thu, 16 Feb 2017 18:33:53 -0500 Subject: [PATCH 04/10] Display date in ProjectCard --- src/components/ProjectCard/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/ProjectCard/index.js b/src/components/ProjectCard/index.js index f9d3a73f..c42798a8 100644 --- a/src/components/ProjectCard/index.js +++ b/src/components/ProjectCard/index.js @@ -4,6 +4,12 @@ import { projectPropTypes } from '../../containers/Building/propTypes'; /* eslint-disable jsx-a11y/href-no-hash */ const ProjectCard = (props) => { const { project } = props; + let date = ''; + if (project.updated !== null) { + date = `Last modified on ${new Date(project.updated)}`; + } else { + date = `Created on ${new Date(project.created)}`; + } return (
@@ -12,7 +18,7 @@ const ProjectCard = (props) => { { project.name } { project.program_type } - Last modified on 1/1/17 + {date}
); -- GitLab From e2583e35531ff1d1f2a4dffc92d662b3885ce2f6 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Fri, 17 Feb 2017 09:10:50 -0500 Subject: [PATCH 05/10] Remove eslint disable comment --- src/components/DocumentCardViewer/styles.css | 6 ++---- src/components/SideBarDetail/index.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/DocumentCardViewer/styles.css b/src/components/DocumentCardViewer/styles.css index a79b582d..f96f4692 100644 --- a/src/components/DocumentCardViewer/styles.css +++ b/src/components/DocumentCardViewer/styles.css @@ -1,14 +1,12 @@ .documentCardViewer { - /* TODO: Fix max height, 68px is height of navbar, 27px is the padding */ - max-height: calc(97vh - 68px); + /* TODO: Fix max height */ + max-height: 93vh; display: flex; flex-direction: column; } .scrollBox { overflow: auto; - flex: 1; width: 95%; margin: 0 auto; } - diff --git a/src/components/SideBarDetail/index.js b/src/components/SideBarDetail/index.js index bbe99903..1cd5eef4 100644 --- a/src/components/SideBarDetail/index.js +++ b/src/components/SideBarDetail/index.js @@ -10,7 +10,6 @@ const isActive = (url) => { return ''; }; -/* eslint-disable */ export default function SideBarDetail({ building, children }) { const rootURL = `/buildings/${building.building_id}`; return ( @@ -52,7 +51,8 @@ export default function SideBarDetail({ building, children }) {