Commit 893aa847 authored by Maxime Chaillet's avatar Maxime Chaillet

clean the code

parent 01c66ae2
import React from 'react'
import { Row, Glyphicon, Panel } from 'react-bootstrap'
import { Row, Panel } from 'react-bootstrap'
import PropTypes from 'prop-types'
import { getEventIcon, getEventHistoryCreationDate } from '../../helpers/EventHelpers'
import { NEW_EVENT_CONTEXT, EVENT_HISTORY_ORIGINAL_VERSION_CONTEXT, EVENT_HISTORY_MIDDLE_VERSION_CONTEXT, EVENT_HISTORY_LATEST_VERSION_CONTEXT, EDIT_EVENT_CONTEXT } from '../../constants/EventTypes';
......
//React components
import React from 'react'
import PropTypes from 'prop-types';
import { Grid, Row, Col, FormControl, Panel, Collapse, Label, InputGroup, Glyphicon } from "react-bootstrap"
import TagContainer from '../../containers/TagContainer'
import HTMLEditor from './HTMLEditor'
import EventHeader from './EventHeader'
import EventFooter from './EventFooter'
import { NEW_EVENT_INVISIBLE, ANNOTATION, NEW_EVENT_CONTEXT, EVENT_CATEGORY_COMMENT } from '../../constants/EventTypes';
/* the possible status of the component */
const IDLE_STATUS = "idle";
//const UPLOADING_STATUS = "uploading"; // the data was successfully uploaded to the server
const UPLOADED_STATUS = "uploaded"; // the data is being uploaded
/* The class represents a new event which is being created */
class NewEvent extends React.Component {
constructor(props) {
super(props)
this.state = {
hasText: false,
status: IDLE_STATUS,
}
}
render() {
const { investigationId, user, onNewEventUploaded } = this.props;
// if (this.state.status === UPLOADED_STATUS) {
// this.setState({ status: IDLE_STATUS });
// onNewEventUploaded()
// return null;
// } else {
return (
<Panel bsStyle='primary' style={{ marginBottom: '0px' }}>
{/* <EventHeader context={NEW_EVENT_CONTEXT} /> */}
<div>
<div style={{ padding: '1px' }}>
<HTMLEditor
user={user}
investigationId={investigationId}
isEditionMode={true}
canEnableSaveButton={this.canEnableSaveButton} />
</div>
{/* <div style={{ paddingTop: '8px'}}>
<InputGroup>
<InputGroup.Addon style={{ backgroundColor: 'transparent', border: 'none' }}> <Label> Title </Label> </InputGroup.Addon>
<FormControl
type="text"
value={this.state.inputTitleValue}
onChange={this.onChangeInputValue}
placeholder="Optional title here"
inputRef={(FormControl) => this.inputTitle = FormControl} />
</InputGroup>
</div> */}
<div>
<Label style={{ margin: '6px 6px 6px 12px', paddingRight: '2px' }}> Tags </Label>
<a href={"/investigation/" + this.props.investigationId + "/events/tagManager"} target="_blank" style={{ fontSize: '12px' }}> <Glyphicon glyph='cog' /> </a>
{/* <InputGroup.Addon style={{ backgroundColor: 'transparent', border: 'none' }}> <Label> Tags </Label> </InputGroup.Addon> */}
{/* <div style={{ paddingTop: '5px', marginRight: '10px' }}> */}
<TagContainer
canEnableSaveButton={this.canEnableSaveButton}
context={NEW_EVENT_CONTEXT}
investigationId={this.props.investigationId}
setTagContainer={this.setTagContainer}
/>
{/* </div> */}
</div>
</div>
<EventFooter
isSaveButtonEnabled={this.state.hasText}
onCancelButtonClicked={this.onCancelNewEventClicked}
onSaveButtonClicked={this.createEvent} />
</Panel>
)
// }
}
changeStateToUploaded = () => {
this.setState({ status: UPLOADED_STATUS })
}
// /** Fuction triggered when the user clicks the 'cancel' button */
// onCancelNewEventClicked = () => {
// localStorage.removeItem('plainText');
// localStorage.removeItem('HTMLText');
// this.props.setNewEventVisibility(NEW_EVENT_INVISIBLE);
// }
// /**
// * Callback method called when the editor content changed from empty to not empty and vice versa.
// * @param {*} change the object representing the change
// */
// canEnableSaveButton = (change) => {
// if (change) {
// if ("hasText" in change) {
// this.setState({ hasText: change.hasText })
// }
// }
// }
// /**
// * Create the new event
// */
// createEvent = () => {
// let investigationId = this.props.investigationId;
// let currentTagIds = this.tagContainer.state.selectedTags.map((tag) => tag._id);
// let newEvent = {
// category: EVENT_CATEGORY_COMMENT,
// content: [
// {
// format: "plainText",
// text: localStorage.getItem('plainText')
// },
// {
// format: "html",
// text: localStorage.getItem('HTMLText')
// }
// ],
// creationDate: Date(),
// investigationId: investigationId,
// title: '', //this.inputTitle.value,
// tag: currentTagIds,
// type: ANNOTATION,
// username: this.props.user.username,
// }
// this.props.createEvent(newEvent, this.props.user.sessionId, this.props.investigationId, this.changeStateToUploaded)
// }
setTagContainer = (element) => {
this.tagContainer = element
}
}
NewEvent.propTypes = {
/** the investigationId indicating what investigation the new event will belong to*/
investigationId: PropTypes.string.isRequired,
/** Callback function to reload events from the server */
reloadEvents: PropTypes.func,
// /** the callback function to change the visibility of this component */
setNewEventVisibility: PropTypes.func.isRequired,
/** the user who is currently logged in */
user: PropTypes.object.isRequired,
}
export default NewEvent;
\ No newline at end of file
import React from 'react';
import Modal from 'react-responsive-modal';
import PropTypes from 'prop-types';
import Loading from '../Loading';
import logo from '../../images/loader.gif';
/**
......@@ -32,7 +31,7 @@ class OverlayBox extends React.Component {
/** Callback triggered when the overlay box is opened. */
onEntered = () => {
/** this is a trick to circumvent a bug with tinymce in modals. the modal needs to be displayed first and tinymce shwn afterwards otherwise a bug occurs in tinymce. */
/** this is a trick to circumvent a bug with tinymce in modals. the modal needs to be displayed first and tinymce shown afterwards otherwise a bug occurs in tinymce. */
let timer = setTimeout(() => { this.setState({ isChildComponentVisible: true }) }, 100);
}
......
......@@ -6,7 +6,6 @@ import { getEventsByInvestigationId, getEventCountByInvestigationId, createEvent
import _ from 'lodash';
import EventList from '../../components/Event/EventList';
import EventActionBar from '../../components/Event/EventActionBar.js';
import NewEvent from '../../components/Event/NewEvent.js';
import { NEW_EVENT_INVISIBLE, NEW_EVENT_VISIBLE, DOC_VIEW, LIST_VIEW, ERROR_MESSAGE_TYPE, EDIT_EVENT_CONTEXT, EDIT_EVENT_VISIBLE, EDIT_EVENT_INVISIBLE, NEW_EVENT_CONTEXT, LOCALSTORAGE_NEW_EVENT_CONTENT_IN_PLAINTEXT_FORMAT, LOCALSTORAGE_NEW_EVENT_CONTENT_IN_HTML_FORMAT, LOCALSTORAGE_KEY_NEW_EVENT_CONTENT_IN_PLAINTEXT_FORMAT, LOCALSTORAGE_KEY_NEW_EVENT_CONTENT_IN_HTML_FORMAT } from '../../constants/EventTypes.js';
import EventPager from '../../components/Event/EventPager.js';
import { convertPageToPageEventIndexes, isRangeAvailableOnTheClient } from '../../helpers/PaginationHelper.js';
......
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