Ivan - Add delete article button[skip ci]

This commit is contained in:
ivan 2016-12-16 01:22:26 -03:00
parent 0d921472e2
commit e0d1fd0e40
3 changed files with 28 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {browserHistory} from 'react-router';
import RichTextEditor from 'react-rte-browserify'; import RichTextEditor from 'react-rte-browserify';
import ArticlesActions from 'actions/articles-actions'; import ArticlesActions from 'actions/articles-actions';
@ -9,6 +10,7 @@ import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call'; import API from 'lib-app/api-call';
import DateTransformer from 'lib-core/date-transformer'; import DateTransformer from 'lib-core/date-transformer';
import AreYouSure from 'app-components/are-you-sure';
import Header from 'core-components/header'; import Header from 'core-components/header';
import Loading from 'core-components/loading'; import Loading from 'core-components/loading';
import Button from 'core-components/button'; import Button from 'core-components/button';
@ -61,10 +63,14 @@ class AdminPanelViewArticle extends React.Component {
renderArticlePreview(article) { renderArticlePreview(article) {
return ( return (
<div className="admin-panel-view-article__content"> <div className="admin-panel-view-article__content">
<div className="admin-panel-view-article__edit-button"> <div className="admin-panel-view-article__edit-buttons">
<Button size="medium" onClick={this.onEditClick.bind(this, article)}>{i18n('EDIT')}</Button> <Button className="admin-panel-view-article__edit-button" size="medium" onClick={this.onEditClick.bind(this, article)} type="tertiary">
{i18n('EDIT')}
</Button>
<Button size="medium" onClick={this.onDeleteClick.bind(this, article)}>
{i18n('DELETE')}
</Button>
</div> </div>
<div className="admin-panel-view-article__article"> <div className="admin-panel-view-article__article">
<Header title={article.title}/> <Header title={article.title}/>
@ -116,6 +122,10 @@ class AdminPanelViewArticle extends React.Component {
}); });
} }
onDeleteClick(article) {
AreYouSure.openModal(i18n('DELETE_ARTICLE_DESCRIPTION'), this.onArticleDeleted.bind(this, article));
}
onFormSubmit(form) { onFormSubmit(form) {
API.call({ API.call({
path: '/article/edit', path: '/article/edit',
@ -139,6 +149,15 @@ class AdminPanelViewArticle extends React.Component {
editable: false editable: false
}); });
} }
onArticleDeleted(article) {
API.call({
path: '/article/delete',
data: {
articleId: article.id
}
}).then(() => browserHistory.push('/admin/panel/articles/list-articles'));
}
} }
export default connect((store) => { export default connect((store) => {

View File

@ -1,10 +1,14 @@
.admin-panel-view-article { .admin-panel-view-article {
&__edit-button { &__edit-buttons {
text-align: left; text-align: left;
margin-bottom: 20px; margin-bottom: 20px;
} }
&__edit-button {
margin-right: 20px;
}
&__last-edited { &__last-edited {
font-style: italic; font-style: italic;
text-align: right; text-align: right;

View File

@ -136,6 +136,7 @@ export default {
'ADD_ARTICLE_DESCRIPTION': 'Here you can add an article that will be available for every user. It will be added inside the category {category}.', 'ADD_ARTICLE_DESCRIPTION': 'Here you can add an article that will be available for every user. It will be added inside the category {category}.',
'LIST_ARTICLES_DESCRIPTION': 'This is a list of articles that includes information about our services.', 'LIST_ARTICLES_DESCRIPTION': 'This is a list of articles that includes information about our services.',
'ADD_TOPIC_DESCRIPTION': 'Here you can add a topic that works as a category for articles.', 'ADD_TOPIC_DESCRIPTION': 'Here you can add a topic that works as a category for articles.',
'DELETE_ARTICLE_DESCRIPTION': 'You\'re going to delete this article for ever.',
'STAFF_MEMBERS_DESCRIPTION': 'Here you can see who are your staff members.', 'STAFF_MEMBERS_DESCRIPTION': 'Here you can see who are your staff members.',
'ADD_STAFF_DESCRIPTION': 'Here you can add staff members to your teams.', 'ADD_STAFF_DESCRIPTION': 'Here you can add staff members to your teams.',
'EDIT_STAFF_DESCRIPTION': 'Here you can edit information about a staff member.', 'EDIT_STAFF_DESCRIPTION': 'Here you can edit information about a staff member.',