Commit f7ccb7c6 authored by Maxime Chaillet's avatar Maxime Chaillet

clean the code. It fixes icat/E-DataPortal#160.

parent 9dcc76dd
...@@ -26,6 +26,7 @@ class NewOrEditEventPanel extends React.Component { ...@@ -26,6 +26,7 @@ class NewOrEditEventPanel extends React.Component {
} }
render() { render() {
let { event, user, context, investigationId, setEditEventVisibility } = this.props; let { event, user, context, investigationId, setEditEventVisibility } = this.props;
debugger;
return ( return (
<Panel bsStyle='primary' style={{ marginBottom: '0px', height: '100%', position: 'relative' }}> <Panel bsStyle='primary' style={{ marginBottom: '0px', height: '100%', position: 'relative' }}>
<EventHeader context={context} /> <EventHeader context={context} />
......
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Grid, Row, Col } from 'react-bootstrap'; import { Grid, Row, Col } from 'react-bootstrap';
import { TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, DETAILED_EVENT_CONTEXT, INFO_MESSAGE_TYPE } from '../../../constants/EventTypes'; import { TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, EDIT_EVENT_CONTEXT, INFO_MESSAGE_TYPE } from '../../../constants/EventTypes';
import TagViewer from './TagViewer'; import TagViewer from './TagViewer';
import CreatableSelect from 'react-select/lib/Creatable'; import CreatableSelect from 'react-select/lib/Creatable';
import _ from 'lodash'; import _ from 'lodash';
...@@ -25,7 +25,7 @@ class TagList extends React.Component { ...@@ -25,7 +25,7 @@ class TagList extends React.Component {
let { availableTags, context } = this.props; let { availableTags, context } = this.props;
if (context === DETAILED_EVENT_CONTEXT) { if (context === EDIT_EVENT_CONTEXT) {
// show tags inside a detailed event // show tags inside a detailed event
const customStyles = { const customStyles = {
dropdownIndicator: () => ({ dropdownIndicator: () => ({
...@@ -63,7 +63,7 @@ class TagList extends React.Component { ...@@ -63,7 +63,7 @@ class TagList extends React.Component {
}; };
let selectedTags = this.props.selectedTags ? let selectedTags = this.props.selectedTags ?
this.props.selectedTags.map((tag) => { return (<TagViewer key={tag._id} context={DETAILED_EVENT_CONTEXT} tag={tag} removeTag={this.props.removeTagFromSelection} />); }) this.props.selectedTags.map((tag) => { return (<TagViewer key={tag._id} context={EDIT_EVENT_CONTEXT} tag={tag} removeTag={this.props.removeTagFromSelection} />); })
: null; : null;
let availableTagsForSelect = availableTags ? let availableTagsForSelect = availableTags ?
availableTags.map((tag) => ({ value: tag._id, label: tag.name })) availableTags.map((tag) => ({ value: tag._id, label: tag.name }))
......
...@@ -3,13 +3,13 @@ import PropTypes from 'prop-types'; ...@@ -3,13 +3,13 @@ import PropTypes from 'prop-types';
import { Label, Glyphicon } from 'react-bootstrap'; import { Label, Glyphicon } from 'react-bootstrap';
import { Row, Col, Button } from "react-bootstrap" import { Row, Col, Button } from "react-bootstrap"
import { TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, DETAILED_EVENT_CONTEXT } from '../../../constants/EventTypes'; import { TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, EDIT_EVENT_CONTEXT } from '../../../constants/EventTypes';
class TagViewer extends React.Component { class TagViewer extends React.Component {
render() { render() {
let { context, tag } = this.props; let { context, tag } = this.props;
if (context === DETAILED_EVENT_CONTEXT) { if (context === EDIT_EVENT_CONTEXT) {
return (<div style={{ display: 'inline-block', marginRight: '4px' }}> return (<div style={{ display: 'inline-block', marginRight: '4px' }}>
<Label <Label
style={{ style={{
......
...@@ -23,7 +23,7 @@ export const READ_MODE = 'event in basic read mode'; ...@@ -23,7 +23,7 @@ export const READ_MODE = 'event in basic read mode';
export const EDIT_MODE = 'event in edition mode'; export const EDIT_MODE = 'event in edition mode';
export const BASIC_EVENT_CONTEXT = 'basicEventContext'; export const BASIC_EVENT_CONTEXT = 'basicEventContext';
export const DETAILED_EVENT_CONTEXT = 'detailedEventContext'; //export const DETAILED_EVENT_CONTEXT = 'detailedEventContext';
export const NEW_EVENT_CONTEXT = 'newEventContext'; export const NEW_EVENT_CONTEXT = 'newEventContext';
export const EDIT_EVENT_CONTEXT = 'editEventContext'; export const EDIT_EVENT_CONTEXT = 'editEventContext';
export const EVENT_HISTORY_ORIGINAL_VERSION_CONTEXT = 'eventHistoryOriginalVersionContext'; export const EVENT_HISTORY_ORIGINAL_VERSION_CONTEXT = 'eventHistoryOriginalVersionContext';
......
...@@ -6,7 +6,7 @@ import TagList from '../components/Event/Tag/TagList'; ...@@ -6,7 +6,7 @@ import TagList from '../components/Event/Tag/TagList';
import TagEditor from '../components/Event/Tag/TagEditor'; import TagEditor from '../components/Event/Tag/TagEditor';
import { getTagsByInvestigationId, createTagsByInvestigationId, updateTagsByInvestigationId } from '../api/icat/icatPlus'; import { getTagsByInvestigationId, createTagsByInvestigationId, updateTagsByInvestigationId } from '../api/icat/icatPlus';
import _ from 'lodash'; import _ from 'lodash';
import { INFO_MESSAGE_TYPE, ERROR_MESSAGE_TYPE, TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, TAG_EDITOR_CONTEXT, TAG_CREATOR_CONTEXT, NEW_EVENT_CONTEXT, EDIT_EVENT_CONTEXT, DETAILED_EVENT_CONTEXT, FETCHED_STATUS, FETCHING_STATUS } from '../constants/EventTypes'; import { INFO_MESSAGE_TYPE, ERROR_MESSAGE_TYPE, TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, TAG_EDITOR_CONTEXT, TAG_CREATOR_CONTEXT, NEW_EVENT_CONTEXT, EDIT_EVENT_CONTEXT, FETCHED_STATUS, FETCHING_STATUS } from '../constants/EventTypes';
import TagActionBar from '../components/Event/Tag/TagActionBar'; import TagActionBar from '../components/Event/Tag/TagActionBar';
import UserMessage from '../components/UserMessage'; import UserMessage from '../components/UserMessage';
import { SUCCESS_MESSAGE_TYPE } from '../constants/UserMessages'; import { SUCCESS_MESSAGE_TYPE } from '../constants/UserMessages';
...@@ -67,7 +67,7 @@ class TagContainer extends React.Component { ...@@ -67,7 +67,7 @@ class TagContainer extends React.Component {
<TagList <TagList
availableTags={this.props.availableTags} availableTags={this.props.availableTags}
addTagToSelection={this.addTagToSelection} addTagToSelection={this.addTagToSelection}
context={DETAILED_EVENT_CONTEXT} context={EDIT_EVENT_CONTEXT}
createNewTag={this.createNewTag} createNewTag={this.createNewTag}
investigationId={investigationId} investigationId={investigationId}
removeTagFromSelection={this.removeTagFromSelection} removeTagFromSelection={this.removeTagFromSelection}
...@@ -134,7 +134,7 @@ class TagContainer extends React.Component { ...@@ -134,7 +134,7 @@ class TagContainer extends React.Component {
// Checks whether available tags have been fetched already // Checks whether available tags have been fetched already
if (this.props.availableTagsReceptionStatus === FETCHED_STATUS) { if (this.props.availableTagsReceptionStatus === FETCHED_STATUS) {
if (this.props.context === DETAILED_EVENT_CONTEXT || this.props.context === BASIC_EVENT_CONTEXT) { if (this.props.context === EDIT_EVENT_CONTEXT || this.props.context === NEW_EVENT_CONTEXT) {
this.isGettingSelectedTagsFromEventProp = false; this.isGettingSelectedTagsFromEventProp = false;
this.setSelectedTagsFromProps(); this.setSelectedTagsFromProps();
}; };
...@@ -145,7 +145,7 @@ class TagContainer extends React.Component { ...@@ -145,7 +145,7 @@ class TagContainer extends React.Component {
} }
componentDidUpdate() { componentDidUpdate() {
if (this.props.context === DETAILED_EVENT_CONTEXT) { if (this.props.context === EDIT_EVENT_CONTEXT) {
if (this.props.availableTagsReceptionStatus === FETCHED_STATUS) { if (this.props.availableTagsReceptionStatus === FETCHED_STATUS) {
if (this.isGettingSelectedTagsFromEventProp === true) { if (this.isGettingSelectedTagsFromEventProp === true) {
this.isGettingSelectedTagsFromEventProp = false; this.isGettingSelectedTagsFromEventProp = false;
......
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