From e0d1fd0e4004d6f64f4823680ffc40afd4e94d06 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 16 Dec 2016 01:22:26 -0300 Subject: [PATCH] Ivan - Add delete article button[skip ci] --- .../articles/admin-panel-view-article.js | 25 ++++++++++++++++--- .../articles/admin-panel-view-article.scss | 6 ++++- client/src/data/languages/en.js | 1 + 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/client/src/app/admin/panel/articles/admin-panel-view-article.js b/client/src/app/admin/panel/articles/admin-panel-view-article.js index 13c0af00..13ec35c2 100644 --- a/client/src/app/admin/panel/articles/admin-panel-view-article.js +++ b/client/src/app/admin/panel/articles/admin-panel-view-article.js @@ -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 (
-
- +
+ +
-
@@ -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) => { diff --git a/client/src/app/admin/panel/articles/admin-panel-view-article.scss b/client/src/app/admin/panel/articles/admin-panel-view-article.scss index 300041c9..431fe9a4 100644 --- a/client/src/app/admin/panel/articles/admin-panel-view-article.scss +++ b/client/src/app/admin/panel/articles/admin-panel-view-article.scss @@ -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; diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 0805e711..07d8f8e5 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -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.',