diff --git a/client/src/app-components/article-add-modal.js b/client/src/app-components/article-add-modal.js new file mode 100644 index 00000000..613abbc7 --- /dev/null +++ b/client/src/app-components/article-add-modal.js @@ -0,0 +1,56 @@ +import React from 'react'; + +import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; +import ModalContainer from 'app-components/modal-container'; + +import Header from 'core-components/header'; +import Form from 'core-components/form'; +import FormField from 'core-components/form-field'; +import SubmitButton from 'core-components/submit-button'; +import Button from 'core-components/button'; + +class ArticleAddModal extends React.Component { + static propTypes = { + topicId: React.PropTypes.number.isRequired, + topicName: React.PropTypes.string.isRequired, + position: React.PropTypes.number.isRequired + }; + + render() { + return ( +
+
+
+ + + {i18n('ADD_ARTICLE')} + + +
+ ); + } + + onAddNewArticleFormSubmit(form) { + API.call({ + path: '/article/add', + data: { + title: form.title, + content: form.content, + topicId: this.props.topicId, + position: this.props.position + } + }).then(() => { + ModalContainer.closeModal(); + + if(this.props.onChange) { + this.props.onChange(); + } + }); + } +} + +export default ArticleAddModal; \ No newline at end of file diff --git a/client/src/app-components/article-add-modal.scss b/client/src/app-components/article-add-modal.scss new file mode 100644 index 00000000..50ba5b88 --- /dev/null +++ b/client/src/app-components/article-add-modal.scss @@ -0,0 +1,7 @@ +.article-add-article { + + &__cancel-button { + float: right; + margin-top: 15px; + } +} \ No newline at end of file diff --git a/client/src/app-components/modal-container.js b/client/src/app-components/modal-container.js index c9591c31..4cd8e03e 100644 --- a/client/src/app-components/modal-container.js +++ b/client/src/app-components/modal-container.js @@ -16,6 +16,10 @@ class ModalContainer extends React.Component { ); } + static closeModal() { + store.dispatch(ModalActions.closeModal()); + } + static childContextTypes = { closeModal: React.PropTypes.func }; diff --git a/client/src/app-components/topic-edit-modal.js b/client/src/app-components/topic-edit-modal.js index 72c2a10f..bc15de30 100644 --- a/client/src/app-components/topic-edit-modal.js +++ b/client/src/app-components/topic-edit-modal.js @@ -31,7 +31,7 @@ class TopicEditModal extends React.Component {
- + diff --git a/client/src/app-components/topic-viewer.js b/client/src/app-components/topic-viewer.js index 81607982..190875f4 100644 --- a/client/src/app-components/topic-viewer.js +++ b/client/src/app-components/topic-viewer.js @@ -6,8 +6,8 @@ import API from 'lib-app/api-call'; import ModalContainer from 'app-components/modal-container'; import TopicEditModal from 'app-components/topic-edit-modal'; import AreYouSure from 'app-components/are-you-sure'; +import ArticleAddModal from 'app-components/article-add-modal'; -import Header from 'core-components/header'; import Icon from 'core-components/icon'; import Button from 'core-components/button'; @@ -38,6 +38,11 @@ class TopicViewer extends React.Component {
); @@ -84,6 +89,18 @@ class TopicViewer extends React.Component { ); } + renderAddNewArticle() { + let props = { + topicId: this.props.topicId, + position: this.props.articles.length, + topicName: this.props.name + }; + + return ( + + ); + } + onDeleteClick() { API.call({ path: '/article/delete-topic', diff --git a/client/src/app-components/topic-viewer.scss b/client/src/app-components/topic-viewer.scss index 3bb483fc..ecc9aec8 100644 --- a/client/src/app-components/topic-viewer.scss +++ b/client/src/app-components/topic-viewer.scss @@ -32,26 +32,25 @@ } &__list { + &-item { display: inline-block; width: 50%; color: $secondary-blue; margin-bottom: 10px; } + &-item:before { content: "• "; color: $grey; } - // - &-item:nth-child(even) { - //background: red; - } - &-item:nth-child(odd) { - //background: green; - } &-item-button { color: $secondary-blue; } } + + &__add-item { + color: $dark-grey; + } } \ No newline at end of file diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 6bca9888..751a4790 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -84,6 +84,8 @@ export default { 'ADD_TOPIC': 'Add Topic', 'ICON': 'Icon', 'COLOR': 'Color', + 'ADD_NEW_ARTICLE': 'Add new article', + 'ADD_ARTICLE': 'Add article', //VIEW DESCRIPTIONS 'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.', @@ -102,6 +104,7 @@ export default { 'DELETE_USER_DESCRIPTION': 'The user will not be able to log in aging and all its tickets will be erased. Also, the email can not be used any more.', 'DELETE_TOPIC_DESCRIPTION': 'By deleting the topic, all articles on it will be erased.', 'EDIT_TOPIC_DESCRIPTION': 'Here you can change the name, the icon and the icon color of the topic.', + 'ADD_ARTICLE_DESCRIPTION': 'Here you can add an article that will be available for every user. It will be added inside the category {category}.', //ERRORS 'EMAIL_OR_PASSWORD': 'Email or password invalid',