diff --git a/socketTest/index.js b/socketTest/index.js index 18bc0b8..917daeb 100644 --- a/socketTest/index.js +++ b/socketTest/index.js @@ -17,9 +17,9 @@ io.on('connection', function(socket){ console.log(msg) console.log(Object.prototype.toString.apply(msg).slice(8, -1)) }) - socket.on('chat message', function(msg){ - console.log('message: ' + msg); - io.emit('chat message', msg); + socket.on('chat message', function(){ + console.log('message:', ...[].slice.call(arguments)); + io.emit('chat message', ...[].slice.call(arguments)); }); }); diff --git a/src/app/css/components/_column.scss b/src/app/css/components/_column.scss index 92bb51c..248c84a 100644 --- a/src/app/css/components/_column.scss +++ b/src/app/css/components/_column.scss @@ -85,7 +85,6 @@ background-color: #7a54a8; font-size: 18px; display: flex; - // align-items: center; border: none; outline: none; cursor: pointer; @@ -98,6 +97,28 @@ } } +.column-button-row { + margin-bottom: 7px; + .column-button-row-button { + margin-top: 1px; + margin-right: 5px; + min-width: 20px; + height: 20px; + color: white; + background-color: #7a54a8; + font-size: 12px; + border: none; + outline: none; + cursor: pointer; + &.active { + background-color: #a088bd; + } + &:hover { + background-color: #7046a3; + } + } +} + .column-form-button { width: 100%; } diff --git a/src/app/css/components/_messages.scss b/src/app/css/components/_messages.scss index 1f66619..2589a69 100644 --- a/src/app/css/components/_messages.scss +++ b/src/app/css/components/_messages.scss @@ -44,6 +44,10 @@ } .message-preview { + .message-preview-title { + margin-top: 10px; + font-weight: bold; + } .message-text { margin-bottom: 10px; } diff --git a/src/app/js/components/column/messageSender/MessageSenderView.js b/src/app/js/components/column/messageSender/MessageSenderView.js index b93c873..3f88fa3 100644 --- a/src/app/js/components/column/messageSender/MessageSenderView.js +++ b/src/app/js/components/column/messageSender/MessageSenderView.js @@ -18,18 +18,22 @@ class MessageSender extends Component { this.state = { tab: this.getThisTab(props), eventName: '', - message: '', + messageCollection: [''], + messageInEditor: 0, + // message: '', messageIsJson: false, autosuggestResults: [] } - this.handleFormSubmit = this.handleFormSubmit.bind(this) + this.handleMessageSend = this.handleMessageSend.bind(this) this.handleEventNameChange = this.handleEventNameChange.bind(this) this.handleMessageChange = this.handleMessageChange.bind(this) this.handleClearClick = this.handleClearClick.bind(this) this.onSuggestionsFetchRequested = this.onSuggestionsFetchRequested.bind(this) this.onSuggestionsClearRequested = this.onSuggestionsClearRequested.bind(this) this.getSuggestionValue = this.getSuggestionValue.bind(this) + this.addMessageArgument = this.addMessageArgument.bind(this) + this.removeMessageArgument = this.removeMessageArgument.bind(this) } componentWillReceiveProps(nextProps) { @@ -60,8 +64,12 @@ class MessageSender extends Component { } handleMessageChange (newValue) { + const state = this.state + const messageCollection = state.messageCollection.slice() + messageCollection[state.messageInEditor] = newValue this.setState({ - message: newValue, + messageCollection, + // message: newValue, messageIsJson: this.jsonOrText(newValue) }) } @@ -88,24 +96,23 @@ class MessageSender extends Component { /** * Saves new message in redux store if name and message are valid */ - handleFormSubmit (e) { - e.preventDefault() - + handleMessageSend () { if ( !this.state.tab.connected ) return - if ( this.state.eventName && this.state.message ) - this.props.sendMessage(this.props.activeTab, this.state.eventName, this.state.message) + if ( this.state.eventName && this.state.messageCollection.length ) + this.props.sendMessage(this.props.activeTab, this.state.eventName, this.state.messageCollection) } /** * Clears message */ - handleClearClick (e) { - e.preventDefault() - + handleClearClick () { + const state = this.state + const messageCollection = state.messageCollection.slice() + messageCollection[state.messageInEditor] = '' this.setState({ - message: '' + messageCollection }) } @@ -151,13 +158,36 @@ class MessageSender extends Component { return true } + addMessageArgument () { + const messageCollection = this.state.messageCollection + this.setState({ + messageCollection: messageCollection.concat(''), + messageInEditor: messageCollection.length + }) + } + + removeMessageArgument () { + const editing = this.state.messageInEditor + const messageCollection = this.state.messageCollection + + if ( messageCollection.length <= 1 ) return // don't remove the last item in the array + + const newMessageCollection = [].concat(messageCollection.slice(0, editing), messageCollection.slice(editing+1)) + const newMessageInEditor = editing - 1 + this.setState({ + messageCollection: newMessageCollection, + messageInEditor: ~newMessageInEditor ? newMessageInEditor : 0 + }) + } + render () { const state = this.state const connected = state.tab.connected + const messageInEditor = state.messageInEditor const autosuggestInputProps = { placeholder: 'Event name', - value: this.state.eventName, + value: state.eventName, onChange: this.handleEventNameChange }; @@ -193,7 +223,30 @@ class MessageSender extends Component { /> - +