Commit 50d384b2 authored by Maxime Chaillet's avatar Maxime Chaillet

Rename constant and methods such that it is homogenious with the rest of the...

Rename constant and methods such that it is homogenious with the rest of the app. It fixes #166.
'
parent 1fc2a1f6
......@@ -9,7 +9,7 @@ import _ from 'lodash';
/**
* React component used to edit or create a tag
*/
class TagEditor extends React.Component {
class NewOrEditTagPanel extends React.Component {
constructor(props) {
super(props);
this.state = {
......@@ -27,11 +27,8 @@ class TagEditor extends React.Component {
<Row className='show-grid'>
<Col xs={0} md={1}> </Col>
<Col xs={12} md={10}>
<h3> Editing Tag </h3>
<Panel bsStyle='primary'>
<Panel.Heading>
<strong>Please update tag details </strong>
</Panel.Heading>
<Panel.Heading> <strong> {this.props.panelHeaderText} </strong> </Panel.Heading>
<Panel.Body>
<FormGroup controlId='formControlTagLabel'>
<ControlLabel>Label <Mandatory></Mandatory></ControlLabel>
......@@ -139,7 +136,7 @@ class TagEditor extends React.Component {
class Mandatory extends React.Component {
render() {
return ( <span style={{ color: 'red' }}>*</span> );
return (<span style={{ color: 'red' }}>*</span>);
}
};
......@@ -150,11 +147,13 @@ const PopoverColorPickerBottom = (callback) => {
);
};
TagEditor.propTypes = {
NewOrEditTagPanel.propTypes = {
/** Text display in the panel header */
panelHeaderText: PropTypes.string,
/** callback function used to show the tag list */
showAvailableTags: PropTypes.func,
/* if present, it corresponds to the tag to edit. If absent, it indcates that a tag is being created*/
tag: PropTypes.object
};
export default TagEditor;
\ No newline at end of file
export default NewOrEditTagPanel;
\ No newline at end of file
......@@ -30,7 +30,7 @@ export const EVENT_HISTORY_ORIGINAL_VERSION_CONTEXT = 'eventHistoryOriginalVersi
export const EVENT_HISTORY_LATEST_VERSION_CONTEXT = 'eventHistoryLatestVersionContext';
export const EVENT_HISTORY_MIDDLE_VERSION_CONTEXT = 'eventHistoryNotOriginalAndNotLatestVersionContext';
export const TAG_MANAGER_CONTEXT = 'tagManagerContext';
export const TAG_EDITOR_CONTEXT = 'tagEditorContext';
export const EDIT_TAG_CONTEXT = 'editTagContext';
export const NEW_TAG_CONTEXT = 'newTagContext';
export const INFO_MESSAGE_TYPE = 'info';
......
......@@ -3,10 +3,10 @@ import PropTypes from 'prop-types';
import axios from 'axios';
import { connect } from 'react-redux';
import TagList from '../components/Event/Tag/TagList';
import TagEditor from '../components/Event/Tag/TagEditor';
import NewOrEditTagPanel from '../components/Event/Tag/NewOrEditTagPanel';
import { getTagsByInvestigationId, createTagsByInvestigationId, updateTagsByInvestigationId } from '../api/icat/icatPlus';
import _ from 'lodash';
import { INFO_MESSAGE_TYPE, ERROR_MESSAGE_TYPE, TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, TAG_EDITOR_CONTEXT, NEW_TAG_CONTEXT, NEW_EVENT_CONTEXT, EDIT_EVENT_CONTEXT, FETCHED_STATUS, FETCHING_STATUS } from '../constants/EventTypes';
import { INFO_MESSAGE_TYPE, ERROR_MESSAGE_TYPE, TAG_MANAGER_CONTEXT, BASIC_EVENT_CONTEXT, EDIT_TAG_CONTEXT, NEW_TAG_CONTEXT, NEW_EVENT_CONTEXT, EDIT_EVENT_CONTEXT, FETCHED_STATUS, FETCHING_STATUS } from '../constants/EventTypes';
import TagListMenu from '../components/Event/Tag/TagListMenu';
import UserMessage from '../components/UserMessage';
import { SUCCESS_MESSAGE_TYPE } from '../constants/UserMessages';
......@@ -33,7 +33,6 @@ class TagContainer extends React.Component {
this.addTagToSelection = this.addTagToSelection.bind(this);
this.createNewTag = this.createNewTag.bind(this);
this.editTag = this.editTag.bind(this);
this.getTagsByInvestigationId = this.getTagsByInvestigationId.bind(this);
this.removeTagFromSelection = this.removeTagFromSelection.bind(this);
this.setMessage = this.setMessage.bind(this);
......@@ -83,21 +82,22 @@ class TagContainer extends React.Component {
<TagList
availableTags={this.props.availableTags}
context={TAG_MANAGER_CONTEXT}
editTag={this.editTag}
editTag={this.onEditTagButtonClicked}
investigationId={investigationId}
updateTags={this.updateTags}
/>
</div>);
}
if (this.state.context === TAG_EDITOR_CONTEXT || this.state.context === NEW_TAG_CONTEXT) {
if (this.state.context === EDIT_TAG_CONTEXT || this.state.context === NEW_TAG_CONTEXT) {
// if (this.state.selectedTags && this.state.selectedTags.length != 0) {
return (<div>
{userMessage}
<TagEditor
<NewOrEditTagPanel
createNewTag={this.createNewTag}
panelHeaderText={this.state.context === NEW_TAG_CONTEXT ? 'New tag' : 'Editing tag'}
showAvailableTags={this.showAvailableTags}
tag={this.state.selectedTags.length !== 0 ? this.state.selectedTags[0] : null}
createNewTag={this.createNewTag}
updateTags={this.updateTags}
/>
</div>);
......@@ -344,10 +344,10 @@ class TagContainer extends React.Component {
* Edit a given tag
* @param {*} tag the tag to be edited
*/
editTag(tag) {
onEditTagButtonClicked = (tag) => {
if (tag) {
this.setState({
context: TAG_EDITOR_CONTEXT,
context: EDIT_TAG_CONTEXT,
message: null,
selectedTags: [tag],
});
......
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