diff --git a/app/controllers/api/v1/accounts/articles_controller.rb b/app/controllers/api/v1/accounts/articles_controller.rb
index ccaa33a42..a2aab527c 100644
--- a/app/controllers/api/v1/accounts/articles_controller.rb
+++ b/app/controllers/api/v1/accounts/articles_controller.rb
@@ -42,7 +42,8 @@ class Api::V1::Accounts::ArticlesController < Api::V1::Accounts::BaseController
def article_params
params.require(:article).permit(
- :title, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status
+ :title, :content, :description, :position, :category_id, :author_id, :associated_article_id, :status, meta: [:title, :description,
+ { tags: [] }]
)
end
diff --git a/app/javascript/dashboard/api/helpCenter/articles.js b/app/javascript/dashboard/api/helpCenter/articles.js
index 7430d65a4..ea6a4f244 100644
--- a/app/javascript/dashboard/api/helpCenter/articles.js
+++ b/app/javascript/dashboard/api/helpCenter/articles.js
@@ -21,6 +21,17 @@ class ArticlesAPI extends PortalsAPI {
if (category_slug) baseUrl += `&category_slug=${category_slug}`;
return axios.get(baseUrl);
}
+
+ getArticle({ id, portalSlug }) {
+ return axios.get(`${this.url}/${portalSlug}/articles/${id}`);
+ }
+
+ updateArticle({ portalSlug, articleId, articleObj }) {
+ return axios.patch(
+ `${this.url}/${portalSlug}/articles/${articleId}`,
+ articleObj
+ );
+ }
}
export default new ArticlesAPI();
diff --git a/app/javascript/dashboard/api/specs/article.spec.js b/app/javascript/dashboard/api/specs/article.spec.js
index a60a784c0..e20e2e222 100644
--- a/app/javascript/dashboard/api/specs/article.spec.js
+++ b/app/javascript/dashboard/api/specs/article.spec.js
@@ -26,4 +26,30 @@ describe('#PortalAPI', () => {
);
});
});
+ describeWithAPIMock('API calls', context => {
+ it('#getArticle', () => {
+ articlesAPI.getArticle({
+ id: 1,
+ portalSlug: 'room-rental',
+ });
+ expect(context.axiosMock.get).toHaveBeenCalledWith(
+ '/api/v1/portals/room-rental/articles/1'
+ );
+ });
+ });
+ describeWithAPIMock('API calls', context => {
+ it('#updateArticle', () => {
+ articlesAPI.updateArticle({
+ articleId: 1,
+ portalSlug: 'room-rental',
+ articleObj: { title: 'Update shipping address' },
+ });
+ expect(context.axiosMock.patch).toHaveBeenCalledWith(
+ '/api/v1/portals/room-rental/articles/1',
+ {
+ title: 'Update shipping address',
+ }
+ );
+ });
+ });
});
diff --git a/app/javascript/dashboard/i18n/locale/en/helpCenter.json b/app/javascript/dashboard/i18n/locale/en/helpCenter.json
index 3878cef01..75e0e436f 100644
--- a/app/javascript/dashboard/i18n/locale/en/helpCenter.json
+++ b/app/javascript/dashboard/i18n/locale/en/helpCenter.json
@@ -18,13 +18,14 @@
}
},
"EDIT_HEADER": {
+ "ALL_ARTICLES": "All Articles",
"PUBLISH_BUTTON": "Publish",
"PREVIEW": "Preview",
"ADD_TRANSLATION": "Add translation",
"OPEN_SIDEBAR": "Open sidebar",
"CLOSE_SIDEBAR": "Close sidebar",
- "SAVING": "Draft saving...",
- "SAVED": "Draft saved"
+ "SAVING": "Saving...",
+ "SAVED": "Saved"
},
"ARTICLE_SETTINGS": {
"TITLE": "Article Settings",
@@ -175,8 +176,12 @@
}
},
"EDIT_ARTICLE": {
+ "LOADING": "Loading article...",
"TITLE_PLACEHOLDER": "Article title goes here",
- "CONTENT_PLACEHOLDER": "Write your article here"
+ "CONTENT_PLACEHOLDER": "Write your article here",
+ "API": {
+ "ERROR": "Error while saving article"
+ }
},
"SIDEBAR": {
"SEARCH": {
diff --git a/app/javascript/dashboard/components/helpCenter/EditArticle.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/components/ArticleEditor.vue
similarity index 88%
rename from app/javascript/dashboard/components/helpCenter/EditArticle.vue
rename to app/javascript/dashboard/routes/dashboard/helpcenter/components/ArticleEditor.vue
index cf6eafb15..cbb261ce3 100644
--- a/app/javascript/dashboard/components/helpCenter/EditArticle.vue
+++ b/app/javascript/dashboard/routes/dashboard/helpcenter/components/ArticleEditor.vue
@@ -25,7 +25,9 @@
diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue
index 241cac1cf..39503efef 100644
--- a/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue
+++ b/app/javascript/dashboard/routes/dashboard/helpcenter/pages/articles/NewArticle.vue
@@ -1,35 +1,21 @@
-