2015-08-21 15:04:38 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import Form from './../ascribe_forms/form';
|
|
|
|
import Property from './../ascribe_forms/property';
|
|
|
|
import InputTextAreaToggable from './../ascribe_forms/input_textarea_toggable';
|
|
|
|
|
|
|
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
|
|
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
|
|
|
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
|
|
|
|
|
|
|
let Note = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
url: React.PropTypes.string,
|
|
|
|
id: React.PropTypes.func,
|
|
|
|
label: React.PropTypes.string,
|
|
|
|
currentUser: React.PropTypes.object,
|
|
|
|
defaultValue: React.PropTypes.string,
|
|
|
|
editable: React.PropTypes.bool,
|
|
|
|
show: React.PropTypes.bool,
|
|
|
|
placeholder: React.PropTypes.string,
|
|
|
|
successMessage: React.PropTypes.string
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps() {
|
|
|
|
return {
|
|
|
|
editable: true,
|
|
|
|
show: true,
|
2015-08-21 16:38:18 +02:00
|
|
|
placeholder: getLangText('Enter a note'),
|
|
|
|
successMessage: getLangText('Note saved')
|
2015-08-21 15:04:38 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
showNotification(){
|
|
|
|
let notification = new GlobalNotificationModel(this.props.successMessage, 'success');
|
|
|
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
2015-08-21 16:39:06 +02:00
|
|
|
if (!!this.props.currentUser.username && this.props.show) {
|
2015-08-21 15:04:38 +02:00
|
|
|
return (
|
|
|
|
<Form
|
|
|
|
url={this.props.url}
|
|
|
|
getFormData={this.props.id}
|
|
|
|
handleSuccess={this.showNotification}>
|
|
|
|
<Property
|
|
|
|
name='note'
|
|
|
|
label={this.props.label}
|
|
|
|
editable={this.props.editable}>
|
|
|
|
<InputTextAreaToggable
|
|
|
|
rows={1}
|
|
|
|
editable={this.props.editable}
|
|
|
|
defaultValue={this.props.defaultValue}
|
|
|
|
placeholder={this.props.placeholder}/>
|
|
|
|
</Property>
|
|
|
|
<hr />
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Note
|