Commit 0e8a5105 authored by Roman's avatar Roman

BRCD-1705 fix(inputProcessor) - error on adding new receiver to file type inputProcessor

parent 31dc28ff
......@@ -106,7 +106,7 @@ const convert = (settings) => {
filters = []
} = settings;
const connections = receiver ? (receiver.connections ? receiver.connections: {}) : {};
const connections = receiver ? (receiver.connections ? receiver.connections: []) : [];
const field_widths = (parser.type === "fixed" && parser.structure) ? parser.structure.map(struct => struct.width) : [];
const usaget_type = (!_.result(processor, 'usaget_mapping') || processor.usaget_mapping.length < 1) ?
"static" :
......@@ -469,10 +469,9 @@ export function removeRatingField(rateCategory, usaget, priority, index) {
};
}
export function removeReceiver(receiver, index) {
export function removeReceiver(index) {
return {
type: REMOVE_RECEIVER,
receiver,
index,
};
}
......
import React, { Component, PropTypes } from 'react';
import Immutable from 'immutable';
import { connect } from 'react-redux';
import { Form, Tabs, Button } from 'react-bootstrap';
import { Form } from 'react-bootstrap';
import { CreateButton } from '../../Elements';
import Connection from './Connection';
import { addReceiver } from '../../../actions/inputProcessorActions';
......@@ -31,59 +32,38 @@ class Receiver extends Component {
this.props.onSetReceiverCheckboxField(fieldName, checked, index);
}
getAddReceiverButton = () => (
<Button
bsSize="xsmall"
className="btn-primary"
onClick={this.onAddReceiver()}
>
<i className="fa fa-plus" />&nbsp;Add Receiver
</Button>
);
onAddReceiver = () => () => {
onAddReceiver = () => {
this.props.dispatch(addReceiver());
}
renderReceivers = () => {
const { settings, fileType, keyValue, keyLabel } = this.props;
const receivers = settings.get('receiver', Immutable.Map());
return (
<div>
{receivers.map((receiver, key) => (
<div key={key} style={{ minWidth: 150 }}>
<div className="form-group" style={{ marginTop: 20 }}>
<div className="col-lg-10">
<div className="col-lg-11">
<Connection
receiver={receiver}
index={key}
settings={settings}
onSetReceiverField={this.onSetReceiverField}
onSetReceiverCheckboxField={this.onSetReceiverCheckboxField}
onCancelKeyAuth={this.props.onCancelKeyAuth}
fileType={fileType}
OnChangeUploadingFile={this.props.OnChangeUploadingFile}
keyValue={keyValue}
keyLabel={keyLabel}
/>
</div>
</div>
</div>
{ key < receivers.size - 1 ? <div className="separator" /> : null }
</div>
)).toArray()}
</div>
);
const receivers = settings.get('receiver', Immutable.List());
return receivers.map((receiver, key) => (
<Connection
key={`receiver_${key}`}
receiver={receiver}
index={key}
settings={settings}
onSetReceiverField={this.onSetReceiverField}
onSetReceiverCheckboxField={this.onSetReceiverCheckboxField}
onCancelKeyAuth={this.props.onCancelKeyAuth}
fileType={fileType}
OnChangeUploadingFile={this.props.OnChangeUploadingFile}
keyValue={keyValue}
keyLabel={keyLabel}
/>
)).toArray();
}
render() {
return (
<Form horizontal className="Receiver">
<Tabs id="receiver">
{ this.renderReceivers() }
</Tabs>
{ this.getAddReceiverButton() }
{ this.renderReceivers() }
<CreateButton
onClick={this.onAddReceiver}
label="Add Receiver"
/>
</Form>
);
}
......
......@@ -279,13 +279,12 @@ export default function (state = defaultState, action) {
}
case REMOVE_RECEIVER: {
const { index } = action;
return state.update('receiver', list => list.remove(index));
return state.update('receiver', Immutable.List(), list => list.remove(index));
}
case ADD_RECEIVER: {
const newReceiver = Immutable.fromJS({});
return state.update('receiver', list => list.push(newReceiver));
return state.update('receiver', Immutable.List(), list => list.push(newReceiver));
}
case SET_LINE_KEY:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment