Ivan - Add delete article button[skip ci]
This commit is contained in:
parent
0d921472e2
commit
e0d1fd0e40
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import {connect} from 'react-redux';
|
||||
import {browserHistory} from 'react-router';
|
||||
import RichTextEditor from 'react-rte-browserify';
|
||||
|
||||
import ArticlesActions from 'actions/articles-actions';
|
||||
|
@ -9,6 +10,7 @@ import i18n from 'lib-app/i18n';
|
|||
import API from 'lib-app/api-call';
|
||||
import DateTransformer from 'lib-core/date-transformer';
|
||||
|
||||
import AreYouSure from 'app-components/are-you-sure';
|
||||
import Header from 'core-components/header';
|
||||
import Loading from 'core-components/loading';
|
||||
import Button from 'core-components/button';
|
||||
|
@ -61,10 +63,14 @@ class AdminPanelViewArticle extends React.Component {
|
|||
renderArticlePreview(article) {
|
||||
return (
|
||||
<div className="admin-panel-view-article__content">
|
||||
<div className="admin-panel-view-article__edit-button">
|
||||
<Button size="medium" onClick={this.onEditClick.bind(this, article)}>{i18n('EDIT')}</Button>
|
||||
<div className="admin-panel-view-article__edit-buttons">
|
||||
<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 className="admin-panel-view-article__article">
|
||||
<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) {
|
||||
API.call({
|
||||
path: '/article/edit',
|
||||
|
@ -139,6 +149,15 @@ class AdminPanelViewArticle extends React.Component {
|
|||
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) => {
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
.admin-panel-view-article {
|
||||
|
||||
&__edit-button {
|
||||
&__edit-buttons {
|
||||
text-align: left;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
&__edit-button {
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
&__last-edited {
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
|
|
|
@ -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}.',
|
||||
'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.',
|
||||
'DELETE_ARTICLE_DESCRIPTION': 'You\'re going to delete this article for ever.',
|
||||
'STAFF_MEMBERS_DESCRIPTION': 'Here you can see who are your staff members.',
|
||||
'ADD_STAFF_DESCRIPTION': 'Here you can add staff members to your teams.',
|
||||
'EDIT_STAFF_DESCRIPTION': 'Here you can edit information about a staff member.',
|
||||
|
|
Loading…
Reference in New Issue