From 6efdc08044980e4e21dfdbb5e1ef1ebb89540cf2 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 15 Nov 2016 19:08:16 +0100 Subject: [PATCH] Queries display IdentityIcons (#3453) --- js/src/ui/Form/InputAddress/inputAddress.css | 4 ++ js/src/ui/Form/InputAddress/inputAddress.js | 9 +++- js/src/views/Contract/Queries/inputQuery.js | 50 +++++++++++++------- js/src/views/Contract/Queries/queries.css | 8 ---- js/src/views/Contract/Queries/queries.js | 16 +++++-- 5 files changed, 58 insertions(+), 29 deletions(-) diff --git a/js/src/ui/Form/InputAddress/inputAddress.css b/js/src/ui/Form/InputAddress/inputAddress.css index ff44ba99e..cf41ab1f2 100644 --- a/js/src/ui/Form/InputAddress/inputAddress.css +++ b/js/src/ui/Form/InputAddress/inputAddress.css @@ -30,6 +30,10 @@ .iconDisabled { position: absolute; top: 35px; + + &.noLabel { + top: 10px; + } } .icon { diff --git a/js/src/ui/Form/InputAddress/inputAddress.js b/js/src/ui/Form/InputAddress/inputAddress.js index 0b5562b9a..fd205e941 100644 --- a/js/src/ui/Form/InputAddress/inputAddress.js +++ b/js/src/ui/Form/InputAddress/inputAddress.js @@ -69,14 +69,19 @@ class InputAddress extends Component { } renderIcon () { - const { value, disabled } = this.props; + const { value, disabled, label } = this.props; if (!value || !value.length || !util.isAddressValid(value)) { return null; } + const classes = [disabled ? styles.iconDisabled : styles.icon]; + if (!label) { + classes.push(styles.noLabel); + } + return ( -
+
diff --git a/js/src/views/Contract/Queries/inputQuery.js b/js/src/views/Contract/Queries/inputQuery.js index 6c4e22039..708f4a652 100644 --- a/js/src/views/Contract/Queries/inputQuery.js +++ b/js/src/views/Contract/Queries/inputQuery.js @@ -19,7 +19,7 @@ import React, { Component, PropTypes } from 'react'; import LinearProgress from 'material-ui/LinearProgress'; import { Card, CardActions, CardTitle, CardText } from 'material-ui/Card'; -import { Button, Input, InputAddressSelect } from '../../../ui'; +import { Button, Input, InputAddress, InputAddressSelect } from '../../../ui'; import styles from './queries.css'; @@ -96,32 +96,48 @@ export default class InputQuery extends Component { } if (!results || results.length < 1) return null; - return outputs .map((out, index) => ({ name: out.name, + type: out.type, value: results[index], display: this.renderValue(results[index]) })) .sort((outA, outB) => outA.display.length - outB.display.length) - .map((out, index) => ( -
-
- { out.name } -
+ .map((out, index) => { + let input = null; + if (out.type === 'address') { + input = ( + + ); + } else { + input = ( + + ); + } - -
-
- )); + return ( +
+
+ { out.name } +
+ { input } +
+ ); + }); } renderInput (input) { + const { values } = this.state; const { name, type } = input; const label = `${name ? `${name}: ` : ''}${type}`; @@ -143,6 +159,7 @@ export default class InputQuery extends Component { @@ -155,6 +172,7 @@ export default class InputQuery extends Component { diff --git a/js/src/views/Contract/Queries/queries.css b/js/src/views/Contract/Queries/queries.css index 9a47511b4..41bf00265 100644 --- a/js/src/views/Contract/Queries/queries.css +++ b/js/src/views/Contract/Queries/queries.css @@ -56,18 +56,10 @@ } .methodResults { - display: flex; - flex-wrap: wrap; - max-width: 24rem; - justify-content: space-around; } .methodResults > div { padding: 0.25rem 0.5rem; - display: flex; - flex-direction: column; - align-items: center; - flex: 1 1 50%; box-sizing: border-box; & > div { diff --git a/js/src/views/Contract/Queries/queries.js b/js/src/views/Contract/Queries/queries.js index 47af3d45f..99fe9ff2a 100644 --- a/js/src/views/Contract/Queries/queries.js +++ b/js/src/views/Contract/Queries/queries.js @@ -19,7 +19,7 @@ import React, { Component, PropTypes } from 'react'; import { Card, CardTitle, CardText } from 'material-ui/Card'; import InputQuery from './inputQuery'; -import { Container, ContainerTitle, Input } from '../../../ui'; +import { Container, ContainerTitle, Input, InputAddress } from '../../../ui'; import styles from './queries.css'; @@ -100,14 +100,14 @@ export default class Queries extends Component { - { this.renderValue(values[fn.name]) } + { this.renderValue(values[fn.name], fn.outputs[0].kind.type) }
); } - renderValue (value) { + renderValue (value, type) { if (typeof value === 'undefined') { return null; } @@ -125,6 +125,16 @@ export default class Queries extends Component { valueToDisplay = value.toString(); } + if (type === 'address') { + return ( + + ); + } + return (