Skip to content

Commit

Permalink
Merge pull request #82 from PLoecker/feature/rfid-input_add_enable-sc…
Browse files Browse the repository at this point in the history
…an_prop

Feature/rfid input add enable scan prop
  • Loading branch information
michael-braun authored Jul 6, 2018
2 parents ec5e2ea + cbde422 commit 3c01aaf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/react-chayns-rfid_input/Example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class Example extends React.Component {
onConfirm={this.onConfirm}
onInput={this.onInput}
value={this.state.rfidInput}
enableScan={chayns.env.isApp && chayns.env.isAndroid}
/>
</ExampleContainer>
);
Expand Down
1 change: 1 addition & 0 deletions src/react-chayns-rfid_input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following properties can be set on the RfidInput-Component
| className | CSS classes for the RfidInput | String | | |
| placeholder | Text that will be shown as placeholder | String | "Kartennummer" | |
| confirmNode | Element that will be load in the button behind the input | React-Elements | "OK" | |
| enableScan | Enable the scan-button fot scan a card | Boolean | false | |
| scanText | Text that will be shown in the button for scan a card | String | "Scannen" | |
| value | Value for the input | String | | true |
| onInput | Event when the input was change | Function | | true |
Expand Down
6 changes: 4 additions & 2 deletions src/react-chayns-rfid_input/component/RfidInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default class RfidInput extends React.Component {
PropTypes.node,
PropTypes.arrayOf(PropTypes.node)
]),
enableScan: PropTypes.bool,
scanText: PropTypes.string,
value: PropTypes.string.isRequired,
onInput: PropTypes.func.isRequired,
Expand All @@ -24,6 +25,7 @@ export default class RfidInput extends React.Component {
className: null,
placeholder: 'Kartennummer',
confirmNode: 'OK',
enableScan: false,
scanText: 'Scannen',
};

Expand Down Expand Up @@ -78,11 +80,11 @@ export default class RfidInput extends React.Component {
className,
placeholder,
confirmNode,
enableScan,
scanText,
value,
} = this.props;
const { isScanning } = this.state;
const canScan = chayns.env.isApp;
const classNames = classnames(className, 'cc__rfid-input');
const disabled = !VALID_RFID.test(value);
return(
Expand All @@ -102,7 +104,7 @@ export default class RfidInput extends React.Component {
{confirmNode}
</ChooseButton>
</div>
{canScan &&
{enableScan &&
<div className="cc__rfid-input__control">
<ChooseButton
onClick={isScanning ? this.endScan : this.startScan}
Expand Down

0 comments on commit 3c01aaf

Please sign in to comment.