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

it fixes #166

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