From f8cc7177eeec7f47beaa5c3487cd7d1076e52641 Mon Sep 17 00:00:00 2001 From: Mohamed Amine Krout Date: Wed, 30 Aug 2023 17:39:59 +0100 Subject: [PATCH] Task-65373: Language version option Task-65423: Add a language --- .../exoplatform/wiki/jpa/EntityConverter.java | 1 + .../exoplatform/wiki/jpa/JPADataStorage.java | 7 +- .../wiki/service/rest/NotesRestService.java | 95 ++++++-- .../wiki/mow/core/api/TestVersioning.java | 2 +- .../portlet/notes/notesPortlet_en.properties | 7 + .../portlet/notes/notesPortlet_fr.properties | 8 + .../webapp/WEB-INF/conf/configuration.xml | 1 + .../wiki/features-flags-configuration.xml | 33 +++ .../webui/workspace/UINotesHeadTemplate.gtmpl | 11 + .../javascript/eXo/wiki/notesService.js | 44 +++- .../main/webapp/skin/less/notes/notes.less | 12 +- .../components/NoteCustomPlugins.vue | 2 +- .../components/NotesEditorDashboard.vue | 59 ++++- .../components/TranslationsEditBar.vue | 223 ++++++++++++++++++ .../vue-app/notes-editor/initComponents.js | 2 + .../documents/DocumentUploadFromZipBotton.vue | 25 ++ .../notes/components/NoteTreeviewDrawer.vue | 2 +- .../notes/components/NotesOverview.vue | 4 +- 18 files changed, 504 insertions(+), 34 deletions(-) create mode 100644 notes-webapp/src/main/webapp/WEB-INF/conf/wiki/features-flags-configuration.xml create mode 100644 notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl create mode 100644 notes-webapp/src/main/webapp/vue-app/notes-editor/components/TranslationsEditBar.vue create mode 100644 notes-webapp/src/main/webapp/vue-app/notes-extensions/components/documents/DocumentUploadFromZipBotton.vue diff --git a/notes-service/src/main/java/org/exoplatform/wiki/jpa/EntityConverter.java b/notes-service/src/main/java/org/exoplatform/wiki/jpa/EntityConverter.java index 5c2fc6da39..66ff234dce 100644 --- a/notes-service/src/main/java/org/exoplatform/wiki/jpa/EntityConverter.java +++ b/notes-service/src/main/java/org/exoplatform/wiki/jpa/EntityConverter.java @@ -443,6 +443,7 @@ public static PageVersion convertPageVersionEntityToPageVersion(PageVersionEntit if (pageVersionEntity != null) { pageVersion = new PageVersion(); pageVersion.setName(String.valueOf(pageVersionEntity.getVersionNumber())); + pageVersion.setTitle(pageVersionEntity.getTitle()); pageVersion.setAuthor(pageVersionEntity.getAuthor()); pageVersion.setContent(pageVersionEntity.getContent()); pageVersion.setCreatedDate(pageVersionEntity.getCreatedDate()); diff --git a/notes-service/src/main/java/org/exoplatform/wiki/jpa/JPADataStorage.java b/notes-service/src/main/java/org/exoplatform/wiki/jpa/JPADataStorage.java index 146bcdee49..e84692882f 100644 --- a/notes-service/src/main/java/org/exoplatform/wiki/jpa/JPADataStorage.java +++ b/notes-service/src/main/java/org/exoplatform/wiki/jpa/JPADataStorage.java @@ -1117,14 +1117,14 @@ public void addPageVersion(Page page , String userName) throws WikiException { pageVersionEntity.setPage(pageEntity); pageVersionEntity.setVersionNumber(versionNumber); - pageVersionEntity.setName(pageEntity.getName()); - pageVersionEntity.setTitle(pageEntity.getTitle()); + pageVersionEntity.setName(page.getName()); + pageVersionEntity.setTitle(page.getTitle()); if (StringUtils.isNotEmpty(userName)) { pageVersionEntity.setAuthor(userName); } else { pageVersionEntity.setAuthor(pageEntity.getAuthor()); } - pageVersionEntity.setContent(pageEntity.getContent()); + pageVersionEntity.setContent(page.getContent()); pageVersionEntity.setSyntax(pageEntity.getSyntax()); pageVersionEntity.setMinorEdit(pageEntity.isMinorEdit()); pageVersionEntity.setComment(pageEntity.getComment()); @@ -1140,7 +1140,6 @@ public void addPageVersion(Page page , String userName) throws WikiException { if (pageVersionEntities == null) { pageVersionEntities = new ArrayList<>(); } - pageVersionEntities.add(pageVersionEntity); pageEntity.setVersions(pageVersionEntities); diff --git a/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java b/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java index 5f11d79046..c3bc3e5ddb 100644 --- a/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java +++ b/notes-service/src/main/java/org/exoplatform/wiki/service/rest/NotesRestService.java @@ -45,7 +45,8 @@ import org.exoplatform.wiki.service.search.SearchResultType; import org.exoplatform.wiki.service.search.TitleSearchResult; import org.exoplatform.wiki.service.search.WikiSearchData; -import org.json.JSONObject; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; import org.gatein.api.EntityNotFoundException; import org.exoplatform.common.http.HTTPStatus; import org.exoplatform.commons.utils.HTMLSanitizer; @@ -73,7 +74,7 @@ import org.exoplatform.wiki.tree.utils.TreeUtils; import org.exoplatform.wiki.utils.NoteConstants; import org.exoplatform.wiki.utils.Utils; - +import org.exoplatform.portal.localization.LocaleContextInfoUtils; import org.exoplatform.services.rest.http.PATCH; @Path("/notes") @@ -328,7 +329,7 @@ public Response getLatestDraftOfPage(@Parameter(description = "Note id", require DraftPage draftNote = noteService.getLatestDraftPageByUserAndTargetPageAndLang(Long.valueOf(targetPage.getId()), currentUserId, lang); - return Response.ok(draftNote != null ? draftNote : JSONObject.NULL).build(); + return Response.ok(draftNote != null ? draftNote : org.json.JSONObject.NULL).build(); } catch (Exception e) { log.error("Can't get draft note {}", noteId, e); return Response.serverError().entity(e.getMessage()).build(); @@ -608,35 +609,56 @@ public Response updateNoteById(@Parameter(description = "Note id", required = tr return Response.status(Response.Status.CONFLICT).entity(NOTE_NAME_EXISTS).build(); } note_.setToBePublished(note.isToBePublished()); - String newNoteName = TitleResolver.getId(note.getTitle(), false); + String newNoteName = note_.getName(); if (!note_.getTitle().equals(note.getTitle()) && !note_.getContent().equals(note.getContent())) { - note_.setTitle(note.getTitle()); - note_.setContent(note.getContent()); - if (!NoteConstants.NOTE_HOME_NAME.equals(note.getName()) && !note.getName().equals(newNoteName)) { - noteService.renameNote(note_.getWikiType(), note_.getWikiOwner(), note_.getName(), newNoteName, note.getTitle()); - note_.setName(newNoteName); + if(StringUtils.isEmpty(note.getLang())) { + newNoteName = TitleResolver.getId(note.getTitle(), false); + note_.setTitle(note.getTitle()); + note_.setContent(note.getContent()); + if (!NoteConstants.NOTE_HOME_NAME.equals(note.getName()) && !note.getName().equals(newNoteName)) { + noteService.renameNote(note_.getWikiType(), note_.getWikiOwner(), note_.getName(), newNoteName, note.getTitle()); + note_.setName(newNoteName); + } + note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_CONTENT_AND_TITLE, identity); + } else { + note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_CONTENT_AND_TITLE, identity); + note_.setTitle(note.getTitle()); + note_.setContent(note.getContent()); + note_.setLang(note.getLang()); } - note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_CONTENT_AND_TITLE, identity); noteService.createVersionOfNote(note_, identity.getUserId()); if (!Utils.ANONYM_IDENTITY.equals(identity.getUserId())) { WikiPageParams noteParams = new WikiPageParams(note_.getWikiType(), note_.getWikiOwner(), newNoteName); noteService.removeDraftOfNote(noteParams); } } else if (!note_.getTitle().equals(note.getTitle())) { - if (!NoteConstants.NOTE_HOME_NAME.equals(note.getName()) && !note.getName().equals(newNoteName)) { - noteService.renameNote(note_.getWikiType(), note_.getWikiOwner(), note_.getName(), newNoteName, note.getTitle()); - note_.setName(newNoteName); + if(StringUtils.isEmpty(note.getLang())) { + newNoteName = TitleResolver.getId(note.getTitle(), false); + if (!NoteConstants.NOTE_HOME_NAME.equals(note.getName()) && !note.getName().equals(newNoteName)) { + noteService.renameNote(note_.getWikiType(), note_.getWikiOwner(), note_.getName(), newNoteName, note.getTitle()); + note_.setName(newNoteName); + } + note_.setTitle(note.getTitle()); + note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_TITLE, identity); + } else { + note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_TITLE, identity); + note_.setTitle(note.getTitle()); + note_.setLang(note.getLang()); } - note_.setTitle(note.getTitle()); - note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_TITLE, identity); noteService.createVersionOfNote(note_, identity.getUserId()); if (!Utils.ANONYM_IDENTITY.equals(identity.getUserId())) { WikiPageParams noteParams = new WikiPageParams(note_.getWikiType(), note_.getWikiOwner(), newNoteName); noteService.removeDraftOfNote(noteParams); } } else if (!note_.getContent().equals(note.getContent())) { - note_.setContent(note.getContent()); - note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_CONTENT, identity); + if(StringUtils.isNotEmpty(note.getLang())) { + note_.setContent(note.getContent()); + note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_CONTENT, identity); + } else { + note_ = noteService.updateNote(note_, PageUpdateType.EDIT_PAGE_CONTENT, identity); + note_.setContent(note.getContent()); + note_.setLang(note.getLang()); + } noteService.createVersionOfNote(note_, identity.getUserId()); if (!Utils.ANONYM_IDENTITY.equals(identity.getUserId())) { WikiPageParams noteParams = new WikiPageParams(note_.getWikiType(), note_.getWikiOwner(), newNoteName); @@ -1327,6 +1349,45 @@ public Response searchData(@Context } + /** + * Return a list of available languages. + * + * @return List of languages + * @throws Exception if an error occured + */ + @GET + @Path("languages") + @Produces(MediaType.APPLICATION_JSON) + @RolesAllowed("users") + public Response getAvailableLanguages(@Context + UriInfo uriInfos, + @QueryParam("lang") String lang + ) throws Exception { + try { + Set locales = LocaleContextInfoUtils.getSupportedLocales(); + List localesList = new ArrayList(locales); + JSONArray localesJSON = new JSONArray(); + Locale currentLocal= Locale.ENGLISH; + if (!lang.isEmpty()){ + currentLocal = Arrays.stream(Locale.getAvailableLocales()).filter(local -> local.getLanguage().equals(lang)).findAny().get(); + } + for (Locale locale : localesList) { + JSONObject object = new JSONObject(); + if (locale.toString().equals("ma")) { + continue; + } else { + object.put("value", locale.toString()); + object.put("text", locale.getDisplayName(currentLocal) + " / " + locale.getDisplayName(locale)); + } + localesJSON.add(object); + } + return Response.ok(localesJSON, MediaType.APPLICATION_JSON).build(); + } catch (Exception e) { + return Response.status(HTTPStatus.INTERNAL_ERROR).build(); + } + } + + private List getJsonTree(WikiPageParams params, HashMap context) throws Exception { Wiki noteBook = noteBookService.getWikiByTypeAndOwner(params.getType(), params.getOwner()); diff --git a/notes-service/src/test/java/org/exoplatform/wiki/mow/core/api/TestVersioning.java b/notes-service/src/test/java/org/exoplatform/wiki/mow/core/api/TestVersioning.java index 13e7e7cbba..669f070f5d 100644 --- a/notes-service/src/test/java/org/exoplatform/wiki/mow/core/api/TestVersioning.java +++ b/notes-service/src/test/java/org/exoplatform/wiki/mow/core/api/TestVersioning.java @@ -96,7 +96,7 @@ public void testCreateVersionHistoryTree() throws Exception { assertEquals("testCreateVersionHistoryTree-ver2.0", pageVersion.getContent()); pageVersion = itVersions.next(); - assertEquals("testCreateVersionHistoryTree-ver1.0", pageVersion.getContent()); + assertEquals("testCreateVersionHistoryTree-ver2.0", pageVersion.getContent()); pageVersion = itVersions.next(); assertEquals("testCreateVersionHistoryTree-ver2.0", pageVersion.getContent()); diff --git a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties index addb891424..d18cef21de 100644 --- a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties +++ b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties @@ -162,6 +162,13 @@ notes.draft.savedDraftStatus=Draft saved notes.filter.label.all.notes=All notes.filter.label.published.notes=Published notes.filter.label.drafts=Drafts +notes.label.translations=Translation: +notes.label.translation.add=Add a new translation: +notes.label.chooseLangage=Choose language +notes.label.translation.originalVersion=Original version +notes.label.noTranslations=No translation + + ############################################################################# #SpaceApplications diff --git a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties index 6e1e97f545..4edfddf180 100644 --- a/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties +++ b/notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties @@ -163,6 +163,14 @@ notes.filter.label.all.notes=Tous notes.filter.label.published.notes=Publi\u00E9 notes.filter.label.drafts=Brouillons + +notes.label.translations=Translation: +notes.label.translation.add=Ajouter une translation: +notes.label.chooseLangage=Choisir une langue +notes.label.translation.originalVersion=Version originale +notes.label.noTranslations=Pas de translation + + ############################################################################# #SpaceApplications ############################################################################# diff --git a/notes-webapp/src/main/webapp/WEB-INF/conf/configuration.xml b/notes-webapp/src/main/webapp/WEB-INF/conf/configuration.xml index 5972884ad6..187c768914 100644 --- a/notes-webapp/src/main/webapp/WEB-INF/conf/configuration.xml +++ b/notes-webapp/src/main/webapp/WEB-INF/conf/configuration.xml @@ -33,6 +33,7 @@ war:/conf/wiki/notification-configuration.xml war:/conf/wiki/dynamic-container-configuration.xml war:/conf/wiki/search-configuration.xml + war:/conf/wiki/features-flags-configuration.xml war:/conf/wiki/analytics-ui-watchers-configuration.xml diff --git a/notes-webapp/src/main/webapp/WEB-INF/conf/wiki/features-flags-configuration.xml b/notes-webapp/src/main/webapp/WEB-INF/conf/wiki/features-flags-configuration.xml new file mode 100644 index 0000000000..1ea9788155 --- /dev/null +++ b/notes-webapp/src/main/webapp/WEB-INF/conf/wiki/features-flags-configuration.xml @@ -0,0 +1,33 @@ + + + + + NotesMultilingualFeatureProperties + org.exoplatform.container.ExtendedPropertyConfigurator + + + NotesMultilingualFeatureProperties + MultiLang notes enablement flag + + + + + + + org.exoplatform.groovyscript.text.TemplateService + + UIPortalApplication-head + addTemplateExtension + org.exoplatform.groovyscript.text.TemplateExtensionPlugin + + + templates + The list of templates to include in HTML Page Header with UIPortalApplication.gtmpl + war:/groovy/webui/workspace/UINotesHeadTemplate.gtmpl + + + + + diff --git a/notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl b/notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl new file mode 100644 index 0000000000..c4757187bc --- /dev/null +++ b/notes-webapp/src/main/webapp/groovy/webui/workspace/UINotesHeadTemplate.gtmpl @@ -0,0 +1,11 @@ +<% + import org.exoplatform.commons.api.settings.ExoFeatureService; + import org.exoplatform.portal.application.PortalRequestContext; + def rcontext = _ctx.getRequestContext(); + ExoFeatureService featureService = uicomponent.getApplicationComponent(ExoFeatureService.class); + def userName = rcontext.getRemoteUser(); +%> + + \ No newline at end of file diff --git a/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js b/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js index 7891e1636f..845b7f146f 100644 --- a/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js +++ b/notes-webapp/src/main/webapp/javascript/eXo/wiki/notesService.js @@ -43,7 +43,7 @@ export function getLatestDraftOfPage(noteId) { }); } -export function getNoteById(noteId,source,type,owner,withChildren) { +export function getNoteById(noteId,lang,source,type,owner,withChildren) { let url = `${notesConstants.PORTAL}/${notesConstants.PORTAL_REST}/notes/note/${noteId}`; if (source){ url=`${url}${getSeparator(url)}source=${source}`; @@ -53,6 +53,8 @@ export function getNoteById(noteId,source,type,owner,withChildren) { url=`${url}${getSeparator(url)}noteBookOwner=${owner}`; } if (withChildren){ url=`${url}${getSeparator(url)}withChildren=${withChildren}`; + }if (lang){ + url=`${url}${getSeparator(url)}lang=${lang}`; } return fetch(url, { method: 'GET', @@ -339,3 +341,43 @@ export function getNoteVersionsByNoteId(noteId) { } }); } + +export function getAvailableLanguages() { + const lang = eXo && eXo.env.portal.language || 'en'; + return fetch(`${notesConstants.PORTAL}/${notesConstants.PORTAL_REST}/notes/languages?lang=${lang}`, { + method: 'GET', + credentials: 'include', + }).then(resp => { + if (!resp || !resp.ok) { + throw new Error('Response code indicates a server error', resp); + } else { + return resp.json(); + } + }); +} +export function getNoteLanguages(noteId) { + return fetch(`${notesConstants.PORTAL}/${notesConstants.PORTAL_REST}/notes/note/langs/${noteId}`, { + method: 'GET', + credentials: 'include', + }).then(resp => { + if (!resp || !resp.ok) { + throw new Error('Response code indicates a server error', resp); + } else { + return resp.json(); + } + }); +} + +export function deleteNoteTranslation(noteId, lang) { + return fetch(`${notesConstants.PORTAL}/${notesConstants.PORTAL_REST}/notes/note/translations/${noteId}/${lang}`, { + credentials: 'include', + method: 'DELETE', + }).then((resp) => { + if (resp && resp.ok) { + return resp; + } else { + throw new Error('Error when deleting translation'); + } + }); +} + diff --git a/notes-webapp/src/main/webapp/skin/less/notes/notes.less b/notes-webapp/src/main/webapp/skin/less/notes/notes.less index b2d6f4f5c0..e8f8934b40 100644 --- a/notes-webapp/src/main/webapp/skin/less/notes/notes.less +++ b/notes-webapp/src/main/webapp/skin/less/notes/notes.less @@ -123,7 +123,7 @@ flex: auto; img { - height: 40px; + height: 41px; } input[type="text"] { @@ -1197,3 +1197,13 @@ ul.note-manual-child { } +.translation-chips .v-chip.v-chip--outlined.v-chip.v-chip { + color: @primaryColor !important; +} + +.left-separator { + border-left: solid; +} + + + diff --git a/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NoteCustomPlugins.vue b/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NoteCustomPlugins.vue index 4d6250778d..1064fbf85e 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NoteCustomPlugins.vue +++ b/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NoteCustomPlugins.vue @@ -102,7 +102,7 @@ export default { this.$refs.customPluginsDrawer.close(); }, retrieveNoteChildren(noteId) { - this.$notesService.getNoteById(noteId, '','','',true).then(data => { + this.$notesService.getNoteById(noteId,'', '','','',true).then(data => { this.noteChildren = data && data.children || []; }); }, diff --git a/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NotesEditorDashboard.vue b/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NotesEditorDashboard.vue index 66c537afdb..13996100c5 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NotesEditorDashboard.vue +++ b/notes-webapp/src/main/webapp/vue-app/notes-editor/components/NotesEditorDashboard.vue @@ -16,11 +16,18 @@ id="notesEditor" class="notesEditor width-full">
-
+
{{ noteFormTitle }} + + fa-language +

{{ draftSavingStatus }}

@@ -49,7 +56,7 @@ @click.stop="postNote(true)" class="px-2"> mdi-arrow-collapse-up @@ -59,6 +66,10 @@
+
@@ -85,6 +96,7 @@
+ ]*>/g, '').replace(/ /g, '').trim().length > 45 ? 'lengthyAlertMessage' : ''; }, + notesMultilingualActive() { + return eXo?.env?.portal?.notesMultilingual; + } }, watch: { 'note.title'() { @@ -203,6 +220,9 @@ export default { if (urlParams.has('appName')) { this.appName = urlParams.get('appName'); } + if (urlParams.has('lang')) { + this.slectedLanguage = urlParams.get('lang'); + } if (urlParams.has('noteId')) { this.noteId = urlParams.get('noteId'); const isDraft = urlParams.has('isDraft') && urlParams.get('isDraft') === 'true'; @@ -238,6 +258,9 @@ export default { this.$root.$on('show-alert', message => { this.displayMessage(message); }); + this.$root.$on('hide-translations', () => { + this.showTranslationBar=false; + }); this.$root.$on('display-treeview-items', filter => { if ( urlParams.has('noteId') ) { this.$refs.noteTreeview.open(this.note, 'includePages', null, filter); @@ -248,6 +271,20 @@ export default { }); } }); + this.$root.$on('add-translation', lang => { + this.slectedLanguage=lang; + this.note.content=''; + this.note.title=''; + this.note.lang=lang; + this.initCKEditor(); + }); + this.$root.$on('lang-translation-changed', lang => { + const noteId= !this.note.draftPage?this.note.id:this.note.targetPageId; + this.slectedLanguage=lang; + this.getNote(noteId); + this.note.lang=lang; + this.initCKEditor(); + }); this.$root.$on('include-page', (note) => { const editor = $('textarea#notesContent').ckeditor().editor; const editorSelectedElement = editor.getSelection().getStartElement(); @@ -329,7 +366,7 @@ export default { this.displayMessage(messageObject, true); this.initActualNoteDone = true; } else { - this.$notesService.getNoteById(id).then(data => { + this.$notesService.getNoteById(id,this.slectedLanguage).then(data => { this.$nextTick(()=> this.fillNote(data)); this.initActualNoteDone = true; }); @@ -358,6 +395,7 @@ export default { name: this.note.name, title: this.note.title, content: this.note.content, + lang: this.note.lang, author: this.note.author, owner: this.note.owner, breadcrumb: this.note.breadcrumb, @@ -366,9 +404,11 @@ export default { const childContainer = '

'; - CKEDITOR.instances['notesContent'].setData(data.content); + if (CKEDITOR.instances['notesContent']) { + CKEDITOR.instances['notesContent'].setData(data.content); + } if ((this.note.content.trim().length === 0)) { - this.$notesService.getNoteById(this.noteId, '','','',true).then(data => { + this.$notesService.getNoteById(this.noteId,this.slectedLanguage,'','','',true).then(data => { if (data && data.children && data.children.length) { CKEDITOR.instances['notesContent'].setData(childContainer); this.setFocus(); @@ -387,6 +427,7 @@ export default { id: this.note.targetPageId ? this.note.targetPageId : null, title: this.note.title, name: this.note.name, + lang: this.note.lang, wikiType: this.note.wikiType, wikiOwner: this.note.wikiOwner, content: this.getBody() || this.note.content, @@ -399,6 +440,7 @@ export default { id: this.note.id, title: this.note.title, name: this.note.name, + lang: this.note.lang, wikiType: this.note.wikiType, wikiOwner: this.note.wikiOwner, content: this.getBody() || this.note.content, @@ -452,6 +494,7 @@ export default { title: this.note.title, content: this.getBody() || this.note.content, name: this.note.name, + lang: this.note.lang, appName: this.appName, wikiType: this.note.wikiType, wikiOwner: this.note.wikiOwner, @@ -672,7 +715,7 @@ export default { const element = evt.data.element; if ( element && element.is('a')) { const noteId = element.getAttribute( 'href' ); - self.$notesService.getNoteById(noteId).then(data => { + self.$notesService.getNoteById(noteId,this.slectedLanguage).then(data => { const note = data; self.$refs.noteTreeview.open(note, 'includePages', 'no-arrow'); }); @@ -831,6 +874,10 @@ export default { this.postingNote = false; this.postKey++; }, + showTranslations() { + this.showTranslationBar=true; + this.$refs.translationsEditBar.show(); + }, isDefaultContent(noteContent) { const div = document.createElement('div'); div.innerHTML = noteContent; diff --git a/notes-webapp/src/main/webapp/vue-app/notes-editor/components/TranslationsEditBar.vue b/notes-webapp/src/main/webapp/vue-app/notes-editor/components/TranslationsEditBar.vue new file mode 100644 index 0000000000..2f6be0b3e1 --- /dev/null +++ b/notes-webapp/src/main/webapp/vue-app/notes-editor/components/TranslationsEditBar.vue @@ -0,0 +1,223 @@ + + \ No newline at end of file diff --git a/notes-webapp/src/main/webapp/vue-app/notes-editor/initComponents.js b/notes-webapp/src/main/webapp/vue-app/notes-editor/initComponents.js index 5e4088266b..1bfeadad5e 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes-editor/initComponents.js +++ b/notes-webapp/src/main/webapp/vue-app/notes-editor/initComponents.js @@ -1,6 +1,7 @@ import NotesEditorDashboard from './components/NotesEditorDashboard.vue'; import NoteCustomPlugins from './components/NoteCustomPlugins.vue'; import NoteTablePluginsDrawer from './components/NoteTablePluginsDrawer.vue'; +import TranslationsEditBar from './components/TranslationsEditBar.vue'; import NoteTreeviewDrawer from '../notes/components/NoteTreeviewDrawer.vue'; @@ -9,6 +10,7 @@ const components = { 'note-custom-plugins': NoteCustomPlugins, 'note-treeview-drawer': NoteTreeviewDrawer, 'note-table-plugins-drawer': NoteTablePluginsDrawer, + 'note-translation-edit-bar': TranslationsEditBar, }; for (const key in components) { diff --git a/notes-webapp/src/main/webapp/vue-app/notes-extensions/components/documents/DocumentUploadFromZipBotton.vue b/notes-webapp/src/main/webapp/vue-app/notes-extensions/components/documents/DocumentUploadFromZipBotton.vue new file mode 100644 index 0000000000..c9d9d42b9c --- /dev/null +++ b/notes-webapp/src/main/webapp/vue-app/notes-extensions/components/documents/DocumentUploadFromZipBotton.vue @@ -0,0 +1,25 @@ + + diff --git a/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue b/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue index 81979e9585..1a87c3780a 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue +++ b/notes-webapp/src/main/webapp/vue-app/notes/components/NoteTreeviewDrawer.vue @@ -562,7 +562,7 @@ export default { this.$refs.breadcrumbDrawer.close(); } else if (this.movePage) { if (note.noteId !== this.note.id) { - this.$notesService.getNoteById(note.noteId, '', '', '', true).then(data => { + this.$notesService.getNoteById(note.noteId,'', '', '', '', true).then(data => { this.breadcrumb = data && data.breadcrumb || []; this.breadcrumb[0].name = this.$t('notes.label.noteHome'); this.destinationNote = data; diff --git a/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue b/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue index 501dac468f..efdc4713bf 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue +++ b/notes-webapp/src/main/webapp/vue-app/notes/components/NotesOverview.vue @@ -390,7 +390,7 @@ export default { }, methods: { getNodeById(noteId, source, noteBookType, noteBookOwner) { - return this.$notesService.getNoteById(noteId, source, noteBookType, noteBookOwner).then(data => { + return this.$notesService.getNoteById(noteId,'', source, noteBookType, noteBookOwner).then(data => { this.note = data || {}; this.$notesService.getFullNoteTree(data.wikiType, data.wikiOwner, data.name, false).then(data => { if (data && data.jsonList.length) { @@ -664,7 +664,7 @@ export default { clearInterval(this.intervalId); }, getNoteById(noteId, source) { - return this.$notesService.getNoteById(noteId, source, this.noteBookType, this.noteBookOwner).then(data => { + return this.$notesService.getNoteById(noteId,'', source, this.noteBookType, this.noteBookOwner).then(data => { this.note = data || {}; this.loadData = true; this.currentNoteBreadcrumb = this.note.breadcrumb;