Prevents users from typing more than 4000 characters into any 'textbox' (posts, comments, and post/comment edits). Also adds new error message for when users hit exactly 4000 characters so they know the limit.
Этот коммит содержится в:
@@ -106,13 +106,21 @@ module.exports = React.createClass({
|
||||
}
|
||||
},
|
||||
handleUserInput: function(messageText) {
|
||||
var newPostError = this.state.postError;
|
||||
|
||||
if (!this.state.postError && messageText.length >= Constants.MAX_POST_LEN) {
|
||||
newPostError = 'Message length cannot exceed 4000 characters';
|
||||
} else if (this.state.postError === 'Message length cannot exceed 4000 characters' && messageText.length < Constants.MAX_POST_LEN) {
|
||||
newPostError = '';
|
||||
}
|
||||
|
||||
var draft = PostStore.getCommentDraft(this.props.rootId);
|
||||
draft.message = messageText;
|
||||
PostStore.storeCommentDraft(this.props.rootId, draft);
|
||||
|
||||
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight);
|
||||
$('.post-right__scroll').perfectScrollbar('update');
|
||||
this.setState({messageText: messageText});
|
||||
this.setState({messageText: messageText, postError: newPostError});
|
||||
},
|
||||
handleUploadStart: function(clientIds, channelId) {
|
||||
var draft = PostStore.getCommentDraft(this.props.rootId);
|
||||
|
||||
@@ -132,8 +132,16 @@ module.exports = React.createClass({
|
||||
}
|
||||
},
|
||||
handleUserInput: function(messageText) {
|
||||
var newPostError = this.state.postError;
|
||||
|
||||
if (!this.state.postError && messageText.length >= Constants.MAX_POST_LEN) {
|
||||
newPostError = 'Message length cannot exceed 4000 characters';
|
||||
} else if (this.state.postError === 'Message length cannot exceed 4000 characters' && messageText.length < Constants.MAX_POST_LEN) {
|
||||
newPostError = '';
|
||||
}
|
||||
|
||||
this.resizePostHolder();
|
||||
this.setState({messageText: messageText});
|
||||
this.setState({messageText: messageText, postError: newPostError});
|
||||
|
||||
var draft = PostStore.getCurrentDraft();
|
||||
draft['message'] = messageText;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
var Client = require('../utils/client.jsx');
|
||||
var AsyncClient = require('../utils/async_client.jsx');
|
||||
var Constants = require('../utils/constants.jsx');
|
||||
var Textbox = require('./textbox.jsx');
|
||||
var BrowserStore = require('../stores/browser_store.jsx');
|
||||
|
||||
@@ -37,7 +38,15 @@ module.exports = React.createClass({
|
||||
$(this.state.refocusId).focus();
|
||||
},
|
||||
handleEditInput: function(editText) {
|
||||
this.setState({ editText: editText });
|
||||
var newError = this.state.error;
|
||||
|
||||
if (!this.state.error && editText.length >= Constants.MAX_POST_LEN) {
|
||||
newError = 'Message length cannot exceed 4000 characters';
|
||||
} else if (this.state.error === 'Message length cannot exceed 4000 characters' && editText.length < Constants.MAX_POST_LEN) {
|
||||
newError = '';
|
||||
}
|
||||
|
||||
this.setState({editText: editText, error: newError});
|
||||
},
|
||||
handleEditKeyPress: function(e) {
|
||||
if (e.which == 13 && !e.shiftKey && !e.altKey) {
|
||||
@@ -53,7 +62,7 @@ module.exports = React.createClass({
|
||||
var self = this;
|
||||
|
||||
$(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) {
|
||||
self.setState({ editText: "", title: "", channel_id: "", post_id: "", comments: 0, refocusId: "" });
|
||||
self.setState({editText: "", title: "", channel_id: "", post_id: "", comments: 0, refocusId: "", error: ''});
|
||||
});
|
||||
|
||||
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
|
||||
@@ -69,7 +78,7 @@ module.exports = React.createClass({
|
||||
return { editText: "", title: "", post_id: "", channel_id: "", comments: 0, refocusId: "" };
|
||||
},
|
||||
render: function() {
|
||||
var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null;
|
||||
var error = this.state.error ? <div className='form-group has-error'><br /><label className='control-label'>{ this.state.error }</label></div> : <div className='form-group'><br /></div>;
|
||||
|
||||
return (
|
||||
<div className="modal fade edit-modal" ref="modal" id="edit_post" role="dialog" tabIndex="-1" aria-hidden="true">
|
||||
|
||||
@@ -257,7 +257,7 @@ module.exports = React.createClass({
|
||||
return (
|
||||
<div ref='wrapper' className='textarea-wrapper'>
|
||||
<CommandList ref='commands' addCommand={this.addCommand} channelId={this.props.channelId} />
|
||||
<textarea id={this.props.id} ref='message' className={'form-control custom-textarea ' + this.state.connection} spellCheck='true' autoComplete='off' autoCorrect='off' rows='1' placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
|
||||
<textarea id={this.props.id} ref='message' className={'form-control custom-textarea ' + this.state.connection} spellCheck='true' autoComplete='off' autoCorrect='off' rows='1' maxLength={Constants.MAX_POST_LEN} placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user