{
+ this.$newsServices.canPublishNews(this.spaceId).then(canPublishNews => {
this.canPublishNews = canPublishNews;
});
if (this.newsId) {
@@ -480,8 +485,8 @@ export default {
if (this.news.publicationState !== this.$newsConstants.newsObjectType.DRAFT) {
this.isActivityPosted = this.news.activityPosted;
}
- this.schedulePostDate = news.schedulePostDate;
- this.selectedTargets = news.targets;
+ this.schedulePostDate = news?.schedulePostDate;
+ this.selectedTargets = news?.targets;
this.audience = news.audience ? news.audience : 'all';
this.$root.$emit('news-space-url',news.spaceUrl);
}
@@ -489,6 +494,7 @@ export default {
},
postArticle() {
this.$emit('post-article', this.postArticleMode !== 'later' ? null : this.$newsUtils.convertDate(this.postDate), this.postArticleMode, this.publish, this.isActivityPosted, this.selectedTargets, this.publish ? this.selectedAudience : null);
+ this.closeDrawer();
},
closeDrawer() {
if (this.news) {
@@ -527,4 +533,4 @@ export default {
},
}
};
-
\ No newline at end of file
+
diff --git a/content-webapp/src/main/webapp/vue-app/services/newsConstants.js b/content-webapp/src/main/webapp/vue-app/services/newsConstants.js
index de8b4715a..db3f122fe 100644
--- a/content-webapp/src/main/webapp/vue-app/services/newsConstants.js
+++ b/content-webapp/src/main/webapp/vue-app/services/newsConstants.js
@@ -23,7 +23,7 @@ export const newsConstants = {
PORTAL_NAME: eXo.env.portal.portalName || '',
CONTAINER_NAME: eXo.env.portal.containerName || '',
PORTAL_REST: eXo.env.portal.rest,
- NEWS_API: `${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/news`,
+ CONTENT_API: '/content/rest',
SOCIAL_ACTIVITY_API: `${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/activities`,
SOCIAL_SPACE_API: `${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/spaces`,
SOCIAL_SPACES_SUGGESTION_API: `${eXo.env.portal.context}/${eXo.env.portal.rest}${eXo.env.portal.context}/social/spaces/suggest.json`,
@@ -37,9 +37,9 @@ export const newsConstants = {
};
export const newsUpdateType = {
- CONTENT: 'content',
- POSTING_AND_PUBLISHING: 'postingAndPublishing',
- SCHEDULE: 'schedule'
+ CONTENT_AND_TITLE: 'CONTENT_AND_TITLE',
+ POSTING_AND_PUBLISHING: 'POSTING_AND_PUBLISHING',
+ SCHEDULE: 'SCHEDULE'
};
export const newsObjectType = {
diff --git a/content-webapp/src/main/webapp/vue-app/services/newsServices.js b/content-webapp/src/main/webapp/vue-app/services/newsServices.js
index 2a5ae43a5..ca5639052 100644
--- a/content-webapp/src/main/webapp/vue-app/services/newsServices.js
+++ b/content-webapp/src/main/webapp/vue-app/services/newsServices.js
@@ -21,8 +21,8 @@
import {newsConstants} from '../services/newsConstants.js';
import {newsUpdateType} from '../services/newsConstants.js';
-export function getNewsById(id, editMode, type) {
- return fetch(`${newsConstants.NEWS_API}/${id}?editMode=${editMode || ''}&type=${type || ''}`, {
+export function getNewsById(id, editMode, type, lang) {
+ return fetch(`${newsConstants.CONTENT_API}/contents/${id}?editMode=${editMode || ''}&type=${type || ''}&lang=${lang || ''}`, {
credentials: 'include',
method: 'GET',
}).then((resp) => {
@@ -31,15 +31,13 @@ export function getNewsById(id, editMode, type) {
} else if ( resp.status === 401) {
return resp.status;
}
- }).then(resp => {
- return resp;
}).catch((error) => {
return error;
});
}
-export function getNewsByActivityId(activityId) {
- return fetch(`${newsConstants.NEWS_API}/byActivity/${activityId}`, {
+export function getNewsByActivityId(activityId, lang) {
+ return fetch(`${newsConstants.CONTENT_API}/contents/byActivity/${activityId}?lang=${lang || ''}`, {
credentials: 'include',
method: 'GET',
}).then((resp) => {
@@ -52,7 +50,7 @@ export function getNewsByActivityId(activityId) {
}
export function getNewsSpaces(newsId) {
- return fetch(`${newsConstants.NEWS_API}/${newsId}?fields=spaces&type=article`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/${newsId}?fields=spaces&type=article`, {
credentials: 'include',
method: 'GET',
}).then((resp) => resp.json()).then(resp => {
@@ -61,7 +59,7 @@ export function getNewsSpaces(newsId) {
}
export function markNewsAsRead(newsId){
- return fetch(`${newsConstants.NEWS_API}/markAsRead/${newsId}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/markAsRead/${newsId}`, {
credentials: 'include',
method: 'POST',
}).then((resp) => {
@@ -74,7 +72,7 @@ export function markNewsAsRead(newsId){
}
export function getNews(filter, spaces, searchText, offset, limit, returnSize) {
- let url = `${newsConstants.NEWS_API}?author=${newsConstants.userName}&filter=${filter}`;
+ let url = `${newsConstants.CONTENT_API}/contents?author=${newsConstants.userName}&filter=${filter}`;
if (searchText) {
if (searchText.indexOf('#') === 0) {
searchText = searchText.replace('#', '%23');
@@ -108,7 +106,7 @@ export function getNews(filter, spaces, searchText, offset, limit, returnSize) {
}
export function saveNews(news) {
- return fetch(`${newsConstants.NEWS_API}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents`, {
headers: {
'Content-Type': 'application/json'
},
@@ -121,7 +119,7 @@ export function saveNews(news) {
}
export function scheduleNews(news, newsType) {
- return fetch(`${newsConstants.NEWS_API}/schedule?type=${newsType || ''}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/schedule?type=${newsType || ''}`, {
headers: {
'Content-Type': 'application/json'
},
@@ -136,7 +134,7 @@ export function scheduleNews(news, newsType) {
export function importFileFromUrl(url) {
return fetch(url, {
headers: {
- 'Content-Type': 'blob'
+ 'Content-Type': 'blob',
},
credentials: 'include',
method: 'GET',
@@ -144,21 +142,18 @@ export function importFileFromUrl(url) {
}
export function updateNews(news, post, type, updateType) {
- return fetch(`${newsConstants.NEWS_API}/${news.id}?post=${post}&type=${type || ''}&newsUpdateType=${updateType || newsUpdateType.CONTENT}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/${news.id}?post=${post}&type=${type || ''}&newsUpdateType=${updateType || newsUpdateType.CONTENT_AND_TITLE}`, {
headers: {
'Content-Type': 'application/json'
},
credentials: 'include',
method: 'PUT',
body: JSON.stringify(news)
- }).then(resp => resp.json());
-}
-
-export function clickOnEditButton(id) {
- return fetch(`${newsConstants.NEWS_API}/${id}/click`, {
- credentials: 'include',
- method: 'POST',
- body: 'edit'
+ }).then(resp => {
+ if (resp && resp.ok) {
+ return resp.json();
+ }
+ throw new Error(`Error when updating article with id ${news.id}`);
});
}
@@ -172,7 +167,7 @@ export function findUserSpaces(spaceName) {
}
export function deleteDraft(newsId) {
- return fetch(`${newsConstants.NEWS_API}/${newsId}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/${newsId}`, {
credentials: 'include',
method: 'DELETE'
});
@@ -209,16 +204,6 @@ export function searchSpaces(searchText) {
}).then(resp => resp.json());
}
-export function fetchFoldersAndFiles(currentDrive, workspace, parentPath) {
- return fetch(`/portal/rest/managedocument/getFoldersAndFiles/?driveName=${currentDrive}&workspaceName=${workspace}¤tFolder=${parentPath}`,
- {})
- .then(response => response.text())
- .then(xmlStr => (new window.DOMParser()).parseFromString(xmlStr, 'text/xml'))
- .then(xml => {
- return xml;
- });
-}
-
export function escapeHTML(unsafeText) {
const div = document.createElement('div');
div.innerText = unsafeText;
@@ -226,7 +211,7 @@ export function escapeHTML(unsafeText) {
}
export function canUserCreateNews(spaceId) {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/news/canCreateNews/${eXo.env.portal.spaceId || spaceId}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/canCreateNews/${eXo.env.portal.spaceId || spaceId}`, {
headers: {
'Content-Type': 'application/json'
},
@@ -235,7 +220,7 @@ export function canUserCreateNews(spaceId) {
}
export function canScheduleNews(spaceId) {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/news/canScheduleNews/${eXo.env.portal.spaceId || spaceId}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/canScheduleNews/${eXo.env.portal.spaceId || spaceId}`, {
headers: {
'Content-Type': 'application/json'
},
@@ -247,7 +232,7 @@ export function deleteNews(newsId, newsObjectType, delay) {
if (delay > 0) {
localStorage.setItem('deletedNews', newsId);
}
- return fetch(`${newsConstants.NEWS_API}/${newsId}?type=${newsObjectType || ''}&delay=${delay || 0}`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/${newsId}?type=${newsObjectType || ''}&delay=${delay || 0}`, {
credentials: 'include',
method: 'DELETE'
}).then((resp) => {
@@ -258,7 +243,7 @@ export function deleteNews(newsId, newsObjectType, delay) {
}
export function undoDeleteNews(newsId) {
- return fetch(`${newsConstants.NEWS_API}/${newsId}/undoDelete`, {
+ return fetch(`${newsConstants.CONTENT_API}/contents/${newsId}/undoDelete`, {
method: 'POST',
credentials: 'include',
}).then((resp) => {
@@ -270,8 +255,8 @@ export function undoDeleteNews(newsId) {
});
}
-export function canPublishNews() {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/news/canPublishNews?spaceId=${eXo.env.portal.spaceId}`, {
+export function canPublishNews(spaceId) {
+ return fetch(`${newsConstants.CONTENT_API}/contents/canPublishNews?spaceId=${spaceId || eXo.env.portal.spaceId}`, {
headers: {
'Content-Type': 'application/json'
},
@@ -280,3 +265,26 @@ export function canPublishNews() {
return resp;
});
}
+
+export function deleteArticleTranslation(newsId, lang) {
+ return fetch(`${newsConstants.CONTENT_API}/contents/translation/${newsId}?lang=${lang}`, {
+ credentials: 'include',
+ method: 'DELETE'
+ }).then((resp) => {
+ if (resp && !resp.ok) {
+ throw new Error('Error when deleting article translation');
+ }
+ });
+}
+
+export function getArticleLanguages(articleId, withDrafts) {
+ return fetch(`${newsConstants.CONTENT_API}/contents/translation/${articleId}?withDrafts=${withDrafts}`, {
+ credentials: 'include',
+ method: 'GET'
+ }).then((resp) => {
+ if (resp && !resp.ok) {
+ throw new Error('Error when getting article languages');
+ }
+ return resp.json();
+ });
+}
diff --git a/content-webapp/src/main/webapp/vue-app/services/newsTargetingService.js b/content-webapp/src/main/webapp/vue-app/services/newsTargetingService.js
index dd5f05a8d..2a0ceed3f 100644
--- a/content-webapp/src/main/webapp/vue-app/services/newsTargetingService.js
+++ b/content-webapp/src/main/webapp/vue-app/services/newsTargetingService.js
@@ -20,7 +20,7 @@
import {newsConstants} from '../services/newsConstants.js';
export function getAllTargets() {
- return fetch(`${newsConstants.NEWS_API}/targeting`, {
+ return fetch(`${newsConstants.CONTENT_API}/targeting`, {
credentials: 'include',
method: 'GET',
}).then((resp) => {
@@ -30,7 +30,7 @@ export function getAllTargets() {
});
}
export function getAllowedTargets() {
- return fetch(`${newsConstants.NEWS_API}/targeting/allowed`, {
+ return fetch(`${newsConstants.CONTENT_API}/targeting/allowed`, {
credentials: 'include',
method: 'GET',
}).then((resp) => {
@@ -44,7 +44,7 @@ export function deleteTargetByName(targetName, delay) {
if (delay > 0) {
localStorage.setItem('deletedNewsTarget', targetName);
}
- return fetch(`${newsConstants.NEWS_API}/targeting/${targetName}?delay=${delay || 0}`, {
+ return fetch(`${newsConstants.CONTENT_API}/targeting/${targetName}?delay=${delay || 0}`, {
credentials: 'include',
method: 'DELETE'
}).then((resp) => {
@@ -55,7 +55,7 @@ export function deleteTargetByName(targetName, delay) {
}
export function undoDeleteTarget(targetName) {
- return fetch(`${newsConstants.NEWS_API}/targeting/${targetName}/undoDelete`, {
+ return fetch(`${newsConstants.CONTENT_API}/targeting/${targetName}/undoDelete`, {
method: 'POST',
credentials: 'include',
}).then((resp) => {
@@ -68,7 +68,7 @@ export function undoDeleteTarget(targetName) {
}
export function createTarget(target) {
- return fetch(`${newsConstants.NEWS_API}/targeting`, {
+ return fetch(`${newsConstants.CONTENT_API}/targeting`, {
method: 'POST',
credentials: 'include',
headers: {
@@ -85,7 +85,7 @@ export function createTarget(target) {
}
export function updateTarget(target, originalTargetName) {
- return fetch(`${newsConstants.NEWS_API}/targeting/${originalTargetName}`, {
+ return fetch(`${newsConstants.CONTENT_API}/targeting/${originalTargetName}`, {
method: 'PUT',
credentials: 'include',
headers: {
@@ -99,4 +99,4 @@ export function updateTarget(target, originalTargetName) {
throw new Error('Error when updating news target');
}
});
-}
+}
\ No newline at end of file
diff --git a/content-webapp/webpack.common.js b/content-webapp/webpack.common.js
index 63e02150d..f551d6d70 100644
--- a/content-webapp/webpack.common.js
+++ b/content-webapp/webpack.common.js
@@ -22,6 +22,7 @@ let config = {
newsAnalyticsExtensions: './src/main/webapp/vue-app/news-extensions/analytics-extensions/main.js',
newsNotificationExtensions: './src/main/webapp/vue-app/news-extensions/notification-extensions/main.js',
engagementCenterExtensions: './src/main/webapp/vue-app/engagementCenterExtensions/extensions.js',
+ contentTranslationMenu: './src/main/webapp/vue-app/newsTranslationMenu/main.js'
},
output: {
filename: 'js/[name].bundle.js',