From 3f95c1a58863db42da71633a0c27036bab6b9326 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Wed, 1 Mar 2017 10:08:17 -0500 Subject: [PATCH 01/13] Commit changes before pull from master --- src/components/TurkHit/defaultForm.js | 1 + src/components/TurkHit/index.js | 79 +++++++++++++++----------- src/components/TurkHit/turkStatus.js | 22 ++++--- src/containers/Dimensions/actions.js | 12 ++-- src/containers/Dimensions/index.js | 23 +++++++- src/containers/Dimensions/propTypes.js | 10 ++++ src/containers/Dimensions/reducer.js | 13 ++++- src/containers/Dimensions/sagas.js | 11 ++-- src/containers/Documents/actions.js | 5 +- src/containers/Documents/sagas.js | 11 +++- 10 files changed, 128 insertions(+), 59 deletions(-) diff --git a/src/components/TurkHit/defaultForm.js b/src/components/TurkHit/defaultForm.js index 782777cb..8a74eecf 100644 --- a/src/components/TurkHit/defaultForm.js +++ b/src/components/TurkHit/defaultForm.js @@ -11,6 +11,7 @@ const defaultTurkHit = { reward: '5', min_file_bytes: 1, max_file_bytes: 50000000, + requester_name: 'no name', }; export default defaultTurkHit; diff --git a/src/components/TurkHit/index.js b/src/components/TurkHit/index.js index bdd13b87..fad6a903 100644 --- a/src/components/TurkHit/index.js +++ b/src/components/TurkHit/index.js @@ -2,6 +2,7 @@ import React, { PropTypes, Component } from 'react'; import defaultForm from './defaultForm'; import './styles.css'; import turkHitPropTypes from '../../containers/Dimensions/propTypes'; +/* eslint-disable import/no-named-as-default-member */ import turkStatus from './turkStatus'; @@ -15,6 +16,18 @@ class TurkHit extends Component { }; } + handleHitDecision = (approve) => { + const { hitDecision, building_id } = this.props; + let responseMessage = ''; + if (!approve) { + responseMessage = prompt('You must enter an explanation for the rejection'); + if (!responseMessage) { + return; + } + } + hitDecision(building_id, approve, responseMessage); + } + renderDefinitions = () => (

Mechanical Turk

@@ -31,15 +44,18 @@ class TurkHit extends Component { renderDownloadLink = () => { const buildings = this.props.hit.boxBuildingList; - /* eslint-disable jsx-a11y/href-no-hash */ - return ( - 0 ? buildings.slice(-1)[0].url_download : '#'} - > - Download - - ); + if (buildings) { + /* eslint-disable jsx-a11y/href-no-hash */ + return ( + 0 ? buildings.slice(-1)[0].url_download : '#'} + > + Download + + ); + } + return (
); } renderCreateHitButton = () => { @@ -54,31 +70,30 @@ class TurkHit extends Component { ); } - renderHitActions = () => { - const { hitDecision, building_id } = this.props; - return ( -
- - -
- ); - } + renderHitActions = () => ( +
+ + +
+ ) render() { const { hit } = this.props; - const { status } = this.props.hit; - let mainContent =
; + const { hitData } = this.props.hit; + const status = hitData.status_id; + // status = 'Reviewable'; + let mainContent =
; if (hit.loading) { return (
@@ -94,11 +109,11 @@ class TurkHit extends Component { ); } - if (status !== '') { + if (status !== null) { const currStatus = turkStatus[status]; mainContent = (
- {turkStatus[status].message} + {currStatus.message} {currStatus.createBtn && this.renderCreateHitButton()}
{currStatus.downloadLink && this.renderDownloadLink()} diff --git a/src/components/TurkHit/turkStatus.js b/src/components/TurkHit/turkStatus.js index 5b9478b4..d6f6e1eb 100644 --- a/src/components/TurkHit/turkStatus.js +++ b/src/components/TurkHit/turkStatus.js @@ -1,41 +1,47 @@ export default { - Assignable: { - message: 'HIT has been submitted to mechanical turk and is waiting for worker.', + 1: { + statusText: 'Assignable', createBtn: false, fileActions: false, downloadLink: false, }, - Unassignable: { + 2: { + statusText: 'Unassignable', message: 'Worker is finding the measurements of the building.', createBtn: false, fileActions: false, downloadLink: false, }, - Reviewable: { + 3: { + statusText: 'Reviewable', message: 'Measurements have been submitted. Check if the file is correct and either approve or reject.', createBtn: false, fileActions: true, downloadLink: true, }, - Accepted: { + 4: { + statusText: 'Accepted', message: 'HIT is completed and has been accepted.', createBtn: false, fileActions: false, downloadLink: true, }, - Rejected: { + 5: { + statusText: 'Rejected', message: 'The HIT has been rejected.', createBtn: true, fileActions: false, downloadLink: true, }, - Disposed: { + 6: { + statusText: 'Disposed', message: 'The HIT has been deleted from mechanical turk. Create a new HIT.', createBtn: true, fileActions: false, downloadLink: false, }, - Expired: { + 7: { + statusText: 'Expired', message: 'The HIT has been expired and must be recreated.', createBtn: true, fileActions: false, diff --git a/src/containers/Dimensions/actions.js b/src/containers/Dimensions/actions.js index 0600cfea..1ef6d47b 100644 --- a/src/containers/Dimensions/actions.js +++ b/src/containers/Dimensions/actions.js @@ -19,10 +19,11 @@ import { * @returns {object} An action object with a type of * LOAD_HIT passing the building_id */ -export function loadHit(buildingId) { +export function loadHit(buildingId, address) { return { type: LOAD_HIT, - payload: buildingId, + buildingId, + address, }; } @@ -33,10 +34,10 @@ export function loadHit(buildingId) { * @returns {object} An action object with a type of * LOAD_HIT_SUCCESS passing the hit status */ -export function hitLoaded(hitStatus) { +export function hitLoaded(hitData) { return { type: LOAD_HIT_SUCCESS, - payload: hitStatus, + payload: hitData, }; } @@ -102,11 +103,12 @@ export function createHitError(error) { * @returns {object} An action object with a type of DECIDE_HIT * passing the decision of the user */ -export function hitDecision(buildingId, decision) { +export function hitDecision(buildingId, decision, message) { return { type: DECIDE_HIT, buildingId, decision, + message, }; } diff --git a/src/containers/Dimensions/index.js b/src/containers/Dimensions/index.js index 137e56eb..670de3b8 100644 --- a/src/containers/Dimensions/index.js +++ b/src/containers/Dimensions/index.js @@ -1,6 +1,7 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import { completeOverviewPropTypes, buildingDetailPropTypes } from '../../containers/Building/propTypes'; import { loadHit, @@ -8,7 +9,10 @@ import { hitDecision, } from './actions'; -import buildingDetailPropTypes from '../Building/propTypes'; +import { + loadDocuments, +} from '../Documents/actions'; + import turkHitPropTypes from './propTypes'; import './styles.css'; @@ -17,7 +21,19 @@ import TurkHit from '../../components/TurkHit'; class Dimensions extends Component { componentDidMount() { - this.props.loadHit(this.props.buildingId); + this.props.loadHit(this.props.buildingId, this.props.building.address); + } + + componentDidUpdate(prevProps) { + const curHitData = this.props.dimensions.hit.hitData; + const prevHitData = prevProps.dimensions.hit.hitData; + if (curHitData !== prevHitData) { + const docKey = curHitData.csv_document_key; + if (docKey) { + console.log(`Calling load docments with key ${docKey}`); + this.props.loadDocuments([], [docKey], 'buildingDimensions'); + } + } } createHitConfirmation = (form) => { @@ -45,6 +61,7 @@ class Dimensions extends Component { Dimensions.propTypes = { buildingId: PropTypes.string, + building: completeOverviewPropTypes, buildingDetail: buildingDetailPropTypes, dimensions: PropTypes.shape({ hit: turkHitPropTypes, @@ -52,6 +69,7 @@ Dimensions.propTypes = { loadHit: PropTypes.func, createHit: PropTypes.func, hitDecision: PropTypes.func, + loadDocuments: PropTypes.func, }; function mapDispatchToProps(dispatch) { @@ -59,6 +77,7 @@ function mapDispatchToProps(dispatch) { loadHit, createHit, hitDecision, + loadDocuments, }, dispatch); } diff --git a/src/containers/Dimensions/propTypes.js b/src/containers/Dimensions/propTypes.js index 8ca01f54..2af1654d 100644 --- a/src/containers/Dimensions/propTypes.js +++ b/src/containers/Dimensions/propTypes.js @@ -2,6 +2,16 @@ import { PropTypes } from 'react'; export default PropTypes.shape({ id: PropTypes.string, + hitData: PropTypes.shape({ + status_id: PropTypes.number, + amazon_hit_id: PropTypes.string, + building_id: PropTypes.number, + csv_document_key: PropTypes.string, + db_id: PropTypes.number, + hit_date: PropTypes.string, + requester_name: PropTypes.string, + shapefile_document_key: PropTypes.string, + }), status: PropTypes.string, loading: PropTypes.boolean, error: PropTypes.boolean, diff --git a/src/containers/Dimensions/reducer.js b/src/containers/Dimensions/reducer.js index 11911747..c5ad1fe0 100644 --- a/src/containers/Dimensions/reducer.js +++ b/src/containers/Dimensions/reducer.js @@ -13,7 +13,16 @@ import { const initState = { hit: { id: '', - status: '', + hitData: { + status_id: null, + amazon_hit_id: '', + building_id: null, + csv_document_key: '', + db_id: null, + hit_date: '', + requester_name: '', + shapefile_document_key: '', + }, loading: false, error: false, boxBuildingList: [], @@ -44,7 +53,7 @@ export default function (state = initState, action) { return { hit: { ...state.hit, - status: action.payload.status, + hitData: action.payload, boxBuildingList: action.payload.box_building_list, loading: false, error: false, diff --git a/src/containers/Dimensions/sagas.js b/src/containers/Dimensions/sagas.js index 509d411d..2c2cc5e3 100644 --- a/src/containers/Dimensions/sagas.js +++ b/src/containers/Dimensions/sagas.js @@ -23,14 +23,14 @@ import { * @param {object} action Payload attribute with buildingId */ function* loadHit(action) { - const buildingId = action.payload; - const data = yield call(request, `${turkURL}${buildingId}`, { + const buildingId = action.buildingId; + const address = action.address; + const data = yield call(request, `${turkURL}${buildingId}?address=${address}`, { method: 'GET', headers: getHeaders(), }); - if (!data.err) { - yield put(hitLoaded(data)); + yield put(hitLoaded(data.data[0])); } else { yield put(hitLoadingError(data.err)); } @@ -65,7 +65,8 @@ function* approveHit(action) { const data = yield call(request, `${turkURL}${action.buildingId}`, { method: 'PUT', headers: getHeaders(), - body: JSON.stringify({ accept: action.decision }), + body: JSON.stringify({ approve: action.decision, + response_message: action.message }), }); if (!data.err) { diff --git a/src/containers/Documents/actions.js b/src/containers/Documents/actions.js index 1048416b..0c391643 100644 --- a/src/containers/Documents/actions.js +++ b/src/containers/Documents/actions.js @@ -9,10 +9,11 @@ import { LOAD_FOLDER_URL_SUCCESS, } from './constants'; -export function loadDocuments(documentPath, fileKey) { +export function loadDocuments(documentPaths, documentKeys, fileKey) { return { type: LOAD_DOCUMENTS, - documentPath, + documentPaths, + documentKeys, fileKey, }; } diff --git a/src/containers/Documents/sagas.js b/src/containers/Documents/sagas.js index 8234b189..5e51ea0c 100644 --- a/src/containers/Documents/sagas.js +++ b/src/containers/Documents/sagas.js @@ -16,13 +16,18 @@ import { folderUrlLoaded, } from './actions'; - function* getDocuments(action) { - const { documentPath, fileKey } = action; + const { documentPaths, documentKeys, fileKey } = action; + const pathsString = documentPaths.reduce((acc, val) => ( + `${acc}paths[]=${val}&` + ), ''); + const keysString = documentKeys.reduce((acc, val) => ( + `${acc}keys[]=${val}&` + ), ''); const res = yield call( request, - `${documentURL}?paths[]=${documentPath}`, { + `${documentURL}?${pathsString}${keysString}`, { method: 'GET', headers: getHeaders(), } -- GitLab From 1f3ee7034d6597fdf349e96306423ffa445b33c3 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Thu, 2 Mar 2017 10:36:11 -0500 Subject: [PATCH 02/13] Integrate with new turk hit service layer --- src/components/TurkHit/index.js | 79 ++++++++++++++++++++------ src/components/TurkHit/turkStatus.js | 1 + src/containers/Dimensions/actions.js | 4 +- src/containers/Dimensions/index.js | 24 +++++--- src/containers/Dimensions/propTypes.js | 46 +++++++-------- src/containers/Dimensions/reducer.js | 27 ++++----- src/containers/Dimensions/sagas.js | 8 ++- 7 files changed, 121 insertions(+), 68 deletions(-) diff --git a/src/components/TurkHit/index.js b/src/components/TurkHit/index.js index fad6a903..f47b5088 100644 --- a/src/components/TurkHit/index.js +++ b/src/components/TurkHit/index.js @@ -2,7 +2,7 @@ import React, { PropTypes, Component } from 'react'; import defaultForm from './defaultForm'; import './styles.css'; import turkHitPropTypes from '../../containers/Dimensions/propTypes'; -/* eslint-disable import/no-named-as-default-member */ +import documentsPropType from '../../containers/Documents/propTypes'; import turkStatus from './turkStatus'; @@ -16,16 +16,17 @@ class TurkHit extends Component { }; } - handleHitDecision = (approve) => { - const { hitDecision, building_id } = this.props; - let responseMessage = ''; + handleHitDecision = (hit, approve) => { + const { hitDecision } = this.props; + let responseMessage = null; if (!approve) { + /* eslint-disable no-alert */ responseMessage = prompt('You must enter an explanation for the rejection'); if (!responseMessage) { return; } } - hitDecision(building_id, approve, responseMessage); + hitDecision(hit, approve, responseMessage); } renderDefinitions = () => ( @@ -42,14 +43,25 @@ class TurkHit extends Component {
); - renderDownloadLink = () => { - const buildings = this.props.hit.boxBuildingList; - if (buildings) { + renderDownloadLink = (documentKey) => { + const dimensions = this.props.documents.files.buildingDimensions; + const document = dimensions.reduce((acc, val) => { + if (!acc) { + if (val.key === documentKey) { + return val; + } + } + return acc; + }, null); + if (this.props.documents.loading) { + return 'Loading documents...'; + } + if (document) { /* eslint-disable jsx-a11y/href-no-hash */ return ( 0 ? buildings.slice(-1)[0].url_download : '#'} + href={document.url_download} > Download @@ -70,28 +82,40 @@ class TurkHit extends Component { ); } - renderHitActions = () => ( + renderHitActions = hit => (
) + renderOldHits = oldHitList => ( + oldHitList.map((val) => { + const currStatus = turkStatus[val.status_id]; + return ( +
+
Status: {currStatus.message} +
Message: {val.response_message} +
{this.renderDownloadLink(val.csv_document_key)} +
+
+ ); + }) + ) + render() { const { hit } = this.props; - const { hitData } = this.props.hit; - const status = hitData.status_id; - // status = 'Reviewable'; + const status = hit.status; let mainContent =
; if (hit.loading) { @@ -109,16 +133,34 @@ class TurkHit extends Component { ); } - if (status !== null) { + if (hit.hitData.length > 0 && status !== null) { + const curHit = hit.hitData[0]; const currStatus = turkStatus[status]; + let oldHits = (
); + if (hit.hitData.length > 1) { + oldHits = ( +
+

Previously created hits

+ {this.renderOldHits(hit.hitData.slice(1))} +
+ ); + } + console.log(curHit); mainContent = (
{currStatus.message} + {curHit.response_message ? ( +
+
{`Message: ${curHit.response_message}`} +
) : ''} +
{currStatus.createBtn && this.renderCreateHitButton()}
- {currStatus.downloadLink && this.renderDownloadLink()} - {currStatus.fileActions && this.renderHitActions()} + {currStatus.downloadLink && this.renderDownloadLink(curHit.csv_document_key)} + {currStatus.fileActions && this.renderHitActions(curHit)}
+
+ {oldHits}
); } else { @@ -153,6 +195,7 @@ TurkHit.propTypes = { address: PropTypes.string, building_id: PropTypes.number, hit: turkHitPropTypes, + documents: documentsPropType, }; export default TurkHit; diff --git a/src/components/TurkHit/turkStatus.js b/src/components/TurkHit/turkStatus.js index d6f6e1eb..447a4f70 100644 --- a/src/components/TurkHit/turkStatus.js +++ b/src/components/TurkHit/turkStatus.js @@ -1,5 +1,6 @@ export default { 1: { + message: 'HIT has been submitted to mechanical turk and is waiting for worker.', statusText: 'Assignable', createBtn: false, fileActions: false, diff --git a/src/containers/Dimensions/actions.js b/src/containers/Dimensions/actions.js index 1ef6d47b..c3ef2062 100644 --- a/src/containers/Dimensions/actions.js +++ b/src/containers/Dimensions/actions.js @@ -103,10 +103,10 @@ export function createHitError(error) { * @returns {object} An action object with a type of DECIDE_HIT * passing the decision of the user */ -export function hitDecision(buildingId, decision, message) { +export function hitDecision(hit, decision, message) { return { type: DECIDE_HIT, - buildingId, + hit, decision, message, }; diff --git a/src/containers/Dimensions/index.js b/src/containers/Dimensions/index.js index 670de3b8..225ff607 100644 --- a/src/containers/Dimensions/index.js +++ b/src/containers/Dimensions/index.js @@ -1,7 +1,8 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; -import { completeOverviewPropTypes, buildingDetailPropTypes } from '../../containers/Building/propTypes'; +import buildingDetailPropTypes, { completeOverviewPropTypes } from '../../containers/Building/propTypes'; +import documentsPropType from '../Documents/propTypes'; import { loadHit, @@ -28,10 +29,17 @@ class Dimensions extends Component { const curHitData = this.props.dimensions.hit.hitData; const prevHitData = prevProps.dimensions.hit.hitData; if (curHitData !== prevHitData) { - const docKey = curHitData.csv_document_key; - if (docKey) { - console.log(`Calling load docments with key ${docKey}`); - this.props.loadDocuments([], [docKey], 'buildingDimensions'); + let docKeys = curHitData.map(val => (val.csv_document_key)); + // Reduce docKeys to remove null entries + docKeys = docKeys.reduce((acc, val) => { + if (val) { + acc.push(val); + } + return acc; + }, []); + if (docKeys.length > 0) { + console.log(`Calling load docments with keys ${docKeys}`); + this.props.loadDocuments([], docKeys, 'buildingDimensions'); } } } @@ -53,6 +61,7 @@ class Dimensions extends Component { address={`${this.props.buildingDetail.overview.address} ${this.props.buildingDetail.overview.zipcode}`} building_id={parseInt(this.props.buildingId, 10)} hit={this.props.dimensions.hit} + documents={this.props.documents} />
); @@ -69,6 +78,7 @@ Dimensions.propTypes = { loadHit: PropTypes.func, createHit: PropTypes.func, hitDecision: PropTypes.func, + documents: documentsPropType, loadDocuments: PropTypes.func, }; @@ -81,8 +91,8 @@ function mapDispatchToProps(dispatch) { }, dispatch); } -function mapStateToProps({ dimensions, buildingDetail }) { - return { dimensions, buildingDetail }; +function mapStateToProps({ dimensions, buildingDetail, documents }) { + return { dimensions, buildingDetail, documents }; } export default connect(mapStateToProps, mapDispatchToProps)(Dimensions); diff --git a/src/containers/Dimensions/propTypes.js b/src/containers/Dimensions/propTypes.js index 2af1654d..e5ac2199 100644 --- a/src/containers/Dimensions/propTypes.js +++ b/src/containers/Dimensions/propTypes.js @@ -1,27 +1,27 @@ import { PropTypes } from 'react'; -export default PropTypes.shape({ - id: PropTypes.string, - hitData: PropTypes.shape({ - status_id: PropTypes.number, - amazon_hit_id: PropTypes.string, - building_id: PropTypes.number, - csv_document_key: PropTypes.string, - db_id: PropTypes.number, - hit_date: PropTypes.string, - requester_name: PropTypes.string, - shapefile_document_key: PropTypes.string, - }), - status: PropTypes.string, - loading: PropTypes.boolean, - error: PropTypes.boolean, - boxBuildingList: PropTypes.arrayOf( - PropTypes.shape({ - url_download: PropTypes.string, - }) - ), - create: PropTypes.shape({ - loading: PropTypes.boolean, - error: PropTypes.boolean, +const { shape, arrayOf, string, number, bool } = PropTypes; + +export const hitDataProps = shape({ + status_id: number, + amazon_hit_id: string, + building_id: number, + csv_document_key: string, + db_id: number, + hit_date: string, + requester_name: string, + shapefile_document_key: string, + response_message: string, +}); + +export default shape({ + id: string, + hitData: arrayOf(hitDataProps), + status: string, + loading: bool, + error: bool, + create: shape({ + loading: bool, + error: bool, }), }); diff --git a/src/containers/Dimensions/reducer.js b/src/containers/Dimensions/reducer.js index c5ad1fe0..b81c5ee2 100644 --- a/src/containers/Dimensions/reducer.js +++ b/src/containers/Dimensions/reducer.js @@ -13,19 +13,10 @@ import { const initState = { hit: { id: '', - hitData: { - status_id: null, - amazon_hit_id: '', - building_id: null, - csv_document_key: '', - db_id: null, - hit_date: '', - requester_name: '', - shapefile_document_key: '', - }, + status: null, + hitData: [], loading: false, error: false, - boxBuildingList: [], create: { loading: false, error: false, @@ -54,7 +45,8 @@ export default function (state = initState, action) { hit: { ...state.hit, hitData: action.payload, - boxBuildingList: action.payload.box_building_list, + id: action.payload[0].amazon_hit_id, + status: action.payload[0].status_id, loading: false, error: false, }, @@ -83,8 +75,9 @@ export default function (state = initState, action) { case CREATE_HIT_SUCCESS: return { hit: { - id: action.payload.hit_id, - status: action.payload.status, + hitData: [action.payload, ...state.hit.hitData], + id: action.payload.amazon_hit_id, + status: action.payload.status_id, loading: false, error: false, create: { @@ -120,7 +113,11 @@ export default function (state = initState, action) { return { hit: { ...state.hit, - status: action.payload.hit_status, + hitData: [ + action.payload, + ...state.hit.hitData.slice(1), + ], + status: action.payload.status_id, approval: { loading: false, error: false, diff --git a/src/containers/Dimensions/sagas.js b/src/containers/Dimensions/sagas.js index 2c2cc5e3..3da1ac75 100644 --- a/src/containers/Dimensions/sagas.js +++ b/src/containers/Dimensions/sagas.js @@ -30,7 +30,7 @@ function* loadHit(action) { headers: getHeaders(), }); if (!data.err) { - yield put(hitLoaded(data.data[0])); + yield put(hitLoaded(data.data)); } else { yield put(hitLoadingError(data.err)); } @@ -62,10 +62,12 @@ function* createHit(action) { * @param {number} action 1 or 0 representing approve or reject */ function* approveHit(action) { - const data = yield call(request, `${turkURL}${action.buildingId}`, { + const data = yield call(request, `${turkURL}${action.hit.db_id}`, { method: 'PUT', headers: getHeaders(), - body: JSON.stringify({ approve: action.decision, + body: JSON.stringify({ + ...action.hit, + approve: action.decision, response_message: action.message }), }); -- GitLab From 8353ba894ef3e6dda804bee24be027f4942bf329 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Thu, 2 Mar 2017 10:49:13 -0500 Subject: [PATCH 03/13] Remove console log statements --- src/components/TurkHit/index.js | 1 - src/containers/Dimensions/index.js | 1 - src/containers/Dimensions/propTypes.js | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/TurkHit/index.js b/src/components/TurkHit/index.js index f47b5088..3c86d46f 100644 --- a/src/components/TurkHit/index.js +++ b/src/components/TurkHit/index.js @@ -145,7 +145,6 @@ class TurkHit extends Component {
); } - console.log(curHit); mainContent = (
{currStatus.message} diff --git a/src/containers/Dimensions/index.js b/src/containers/Dimensions/index.js index 225ff607..7fdb834b 100644 --- a/src/containers/Dimensions/index.js +++ b/src/containers/Dimensions/index.js @@ -38,7 +38,6 @@ class Dimensions extends Component { return acc; }, []); if (docKeys.length > 0) { - console.log(`Calling load docments with keys ${docKeys}`); this.props.loadDocuments([], docKeys, 'buildingDimensions'); } } diff --git a/src/containers/Dimensions/propTypes.js b/src/containers/Dimensions/propTypes.js index e5ac2199..00fe12b1 100644 --- a/src/containers/Dimensions/propTypes.js +++ b/src/containers/Dimensions/propTypes.js @@ -17,7 +17,7 @@ export const hitDataProps = shape({ export default shape({ id: string, hitData: arrayOf(hitDataProps), - status: string, + status: number, loading: bool, error: bool, create: shape({ -- GitLab From 91711562fd6a22ae177122139d5a391d1880af55 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Thu, 2 Mar 2017 11:10:41 -0500 Subject: [PATCH 04/13] Add username from google login --- src/components/TurkHit/defaultForm.js | 1 - src/components/TurkHit/index.js | 5 ++++- src/containers/GoogleLogin/index.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/TurkHit/defaultForm.js b/src/components/TurkHit/defaultForm.js index 8a74eecf..782777cb 100644 --- a/src/components/TurkHit/defaultForm.js +++ b/src/components/TurkHit/defaultForm.js @@ -11,7 +11,6 @@ const defaultTurkHit = { reward: '5', min_file_bytes: 1, max_file_bytes: 50000000, - requester_name: 'no name', }; export default defaultTurkHit; diff --git a/src/components/TurkHit/index.js b/src/components/TurkHit/index.js index 3c86d46f..0e59aca7 100644 --- a/src/components/TurkHit/index.js +++ b/src/components/TurkHit/index.js @@ -74,7 +74,10 @@ class TurkHit extends Component { const { createHitConfirmation, address, building_id } = this.props; return ( +
+ +
); } @@ -106,12 +110,18 @@ class TurkHit extends Component { oldHitList.map((val) => { const currStatus = turkStatus[val.status_id]; return ( -
-
Status: {currStatus.message} -
Message: {val.response_message} -
Created on {val.hit_date} by {val.requester_name} -
{this.renderDownloadLink(val.csv_document_key)} -
+
+ + + + + + + +
Status {currStatus.message}
Message {val.response_message}
Creation Date {val.hit_date}
Creator {val.requester_name}
+

+ {this.renderDownloadLink(val.csv_document_key)} +

); }) @@ -137,34 +147,39 @@ class TurkHit extends Component { ); } + + let oldHits = (
); if (hit.hitData.length > 0 && status !== null) { const curHit = hit.hitData[0]; const currStatus = turkStatus[status]; - let oldHits = (
); if (hit.hitData.length > 1) { oldHits = ( -
-

Previously created hits

+
+

Previously created hits

+
Definitions
+

+ These are hits that are no longer active. +

{this.renderOldHits(hit.hitData.slice(1))}
); } mainContent = ( -
- Hit created on {curHit.hit_date} by {curHit.requester_name}
- {currStatus.message} - {curHit.response_message ? ( -
-
{`Message: ${curHit.response_message}`} -
) : ''} -
- {currStatus.createBtn && this.renderCreateHitButton()} -
+
+ + + + {curHit.response_message ? + () : (
)} +
+ + +
Status {currStatus.message}
Message {curHit.response_message}
Creation Date {curHit.hit_date}
Creator {curHit.requester_name}
+

+ {currStatus.createBtn && this.renderCreateHitButton()} {currStatus.downloadLink && this.renderDownloadLink(curHit.csv_document_key)} {currStatus.fileActions && this.renderHitActions(curHit)} -

-
- {oldHits} +

); } else { @@ -184,10 +199,9 @@ class TurkHit extends Component { > Failed to create HIT. Response message: {hit.create.error.message}
- {this.renderDefinitions()} {mainContent} - + {oldHits}
); } -- GitLab From 84d951f936cc7fcb23ded9fcb09e73085984c733 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Fri, 3 Mar 2017 09:50:35 -0500 Subject: [PATCH 13/13] Final styling changes --- src/components/TurkHit/index.js | 34 +++++++++++++++++------------- src/containers/Dimensions/index.js | 9 ++++++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/components/TurkHit/index.js b/src/components/TurkHit/index.js index d9ff3f1d..7ce0d776 100644 --- a/src/components/TurkHit/index.js +++ b/src/components/TurkHit/index.js @@ -85,6 +85,8 @@ class TurkHit extends Component { > Create Hit +
+
); } @@ -165,21 +167,23 @@ class TurkHit extends Component { ); } mainContent = ( -
- - - - {curHit.response_message ? - () : (
)} -
- - -
Status {currStatus.message}
Message {curHit.response_message}
Creation Date {curHit.hit_date}
Creator {curHit.requester_name}
-

- {currStatus.createBtn && this.renderCreateHitButton()} - {currStatus.downloadLink && this.renderDownloadLink(curHit.csv_document_key)} - {currStatus.fileActions && this.renderHitActions(curHit)} -

+
+ {currStatus.createBtn && this.renderCreateHitButton()} +
+ + + + {curHit.response_message ? + () : } + + + +
Status{currStatus.message}
Message{curHit.response_message}
Creation Date{curHit.hit_date}
Creator{curHit.requester_name}
+
+ {currStatus.downloadLink && this.renderDownloadLink(curHit.csv_document_key)} + {currStatus.fileActions && this.renderHitActions(curHit)} +
+
); } else { diff --git a/src/containers/Dimensions/index.js b/src/containers/Dimensions/index.js index 9978f9ae..cfb68a6a 100644 --- a/src/containers/Dimensions/index.js +++ b/src/containers/Dimensions/index.js @@ -49,12 +49,17 @@ class Dimensions extends Component { } render() { + // TODO: Hardcoded state and country, need to be stored in database return ( -
+