Commit 1fc2a1f6 authored by Maxime Chaillet's avatar Maxime Chaillet

it fixes #166

parent f8084ff3
......@@ -6,46 +6,31 @@ import EventListMenuButton from '../EventListMenuButton';
/**
* The menu displayed above the tag list
*/
class TagActionBar extends React.Component {
constructor(props) {
super(props);
this.showTagEditor = this.showTagEditor.bind(this);
}
class TagListMenu extends React.Component {
render() {
return (
<Grid fluid={true} style={{ marginTop: '10px' }}>
<Row>
<Col xs={2}>
<ButtonToolbar>
<div onClick={this.props.onNewTagButtonClicked}>
<EventListMenuButton
isNewComponentVisible={false}
onClick={this.showTagEditor}
/>
text='New'
tooltipText='Create a new tag'
glyph='plus'
isEnabled={true} />
</div>
</ButtonToolbar>
</Col>
</Row>
</Grid >
);
}
/** Callback triggered when the user click to create a new tag */
showTagEditor() {
this.props.showNewTag();
}
}
TagActionBar.propTypes = {
TagListMenu.propTypes = {
/** Callback function used to display new tag form */
showNewTag: PropTypes.func
onNewTagClicked: PropTypes.func
};
export default TagActionBar;
\ No newline at end of file
export default TagListMenu;
\ No newline at end of file
......@@ -31,7 +31,7 @@ export const EVENT_HISTORY_LATEST_VERSION_CONTEXT = 'eventHistoryLatestVersionCo
export const EVENT_HISTORY_MIDDLE_VERSION_CONTEXT = 'eventHistoryNotOriginalAndNotLatestVersionContext';
export const TAG_MANAGER_CONTEXT = 'tagManagerContext';
export const TAG_EDITOR_CONTEXT = 'tagEditorContext';
export const TAG_CREATOR_CONTEXT = 'tagCreatorContext';
export const NEW_TAG_CONTEXT = 'newTagContext';
export const INFO_MESSAGE_TYPE = 'info';
export const ERROR_MESSAGE_TYPE = 'error';
......
......@@ -6,8 +6,8 @@ import TagList from '../components/Event/Tag/TagList';
import TagEditor from '../components/Event/Tag/TagEditor';
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, TAG_CREATOR_CONTEXT, NEW_EVENT_CONTEXT, EDIT_EVENT_CONTEXT, FETCHED_STATUS, FETCHING_STATUS } from '../constants/EventTypes';
import TagActionBar from '../components/Event/Tag/TagActionBar';
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 TagListMenu from '../components/Event/Tag/TagListMenu';
import UserMessage from '../components/UserMessage';
import { SUCCESS_MESSAGE_TYPE } from '../constants/UserMessages';
import { setAvailableTagAction } from '../actions/logbook';
......@@ -39,7 +39,6 @@ class TagContainer extends React.Component {
this.setMessage = this.setMessage.bind(this);
this.setSelectedTagsFromProps = this.setSelectedTagsFromProps.bind(this);
this.showAvailableTags = this.showAvailableTags.bind(this);
this.showNewTag = this.showNewTag.bind(this);
this.updateTags = this.updateTags.bind(this);
}
......@@ -80,7 +79,7 @@ class TagContainer extends React.Component {
if (this.state.context === TAG_MANAGER_CONTEXT) {
return (<div>
{userMessage}
<TagActionBar showNewTag={this.showNewTag} />
<TagListMenu onNewTagButtonClicked={this.onNewTagButtonClicked} />
<TagList
availableTags={this.props.availableTags}
context={TAG_MANAGER_CONTEXT}
......@@ -91,7 +90,7 @@ class TagContainer extends React.Component {
</div>);
}
if (this.state.context === TAG_EDITOR_CONTEXT || this.state.context === TAG_CREATOR_CONTEXT) {
if (this.state.context === TAG_EDITOR_CONTEXT || this.state.context === NEW_TAG_CONTEXT) {
// if (this.state.selectedTags && this.state.selectedTags.length != 0) {
return (<div>
{userMessage}
......@@ -232,7 +231,7 @@ class TagContainer extends React.Component {
createNewTag(newTag) {
let _this = this;
let nextContext = (this.props.context === TAG_CREATOR_CONTEXT) ? TAG_MANAGER_CONTEXT : this.props.context;
let nextContext = (this.props.context === NEW_TAG_CONTEXT) ? TAG_MANAGER_CONTEXT : this.props.context;
// POST the new tag to the server
if (newTag) {
axios({
......@@ -355,9 +354,9 @@ class TagContainer extends React.Component {
};
}
showNewTag() {
onNewTagButtonClicked = () => {
this.setState({
context: TAG_CREATOR_CONTEXT,
context: NEW_TAG_CONTEXT,
message: null,
});
}
......
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