From 15ea72c6f4b1b1fbcc2c60aaa720ef1973a028a2 Mon Sep 17 00:00:00 2001 From: Helmi Akermi <70575401+hakermi@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:47:29 +0100 Subject: [PATCH] feat: Notes publication drawer in edit mode - EXO-72749_EXO-73246 - Meeds-io/MIPs#161 (#1153) Enhance reusability of notes publication drawer and implement the edit mode of publication drawer --- .../main/webapp/WEB-INF/gatein-resources.xml | 29 ++++++++++++++++ .../main/webapp/skin/less/notes/notes.less | 7 ++++ .../components}/NotePublicationDrawer.vue | 33 ++++++++++++++----- .../notes-publication/initComponents.js | 11 +++++++ .../webapp/vue-app/notes-publication/main.js | 11 +++++++ .../notes-rich-editor/initComponents.js | 2 -- notes-webapp/webpack.prod.js | 4 ++- 7 files changed, 85 insertions(+), 12 deletions(-) rename notes-webapp/src/main/webapp/vue-app/{notes-rich-editor/components/note-publication => notes-publication/components}/NotePublicationDrawer.vue (87%) create mode 100644 notes-webapp/src/main/webapp/vue-app/notes-publication/initComponents.js create mode 100644 notes-webapp/src/main/webapp/vue-app/notes-publication/main.js diff --git a/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml b/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml index 41917e491b..fbb9ee85ed 100644 --- a/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml @@ -86,6 +86,9 @@ + + NotesPublication + commonVueComponents @@ -114,6 +117,32 @@ + + NotesPublication + NotesGRP + + + commonVueComponents + + + extensionRegistry + + + vue + + + vuetify + + + eXoVueI18n + + + imageCropper + + + NotesEditor 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 eb15d3f0eb..80cf009d0f 100644 --- a/notes-webapp/src/main/webapp/skin/less/notes/notes.less +++ b/notes-webapp/src/main/webapp/skin/less/notes/notes.less @@ -212,6 +212,13 @@ } } +#editorPublicationDrawer { + .post-feed-target { + max-width: 335px; + } + +} + #editorMetadataDrawer, #editorPublicationDrawer { .add-image-area, .image-preview { diff --git a/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/note-publication/NotePublicationDrawer.vue b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue similarity index 87% rename from notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/note-publication/NotePublicationDrawer.vue rename to notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue index f7d16cbec9..f707dce706 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/components/note-publication/NotePublicationDrawer.vue +++ b/notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue @@ -46,6 +46,7 @@ vertical flat>
-
+
+ :class="{'mt-8': !editMode}" + class="d-flex flex-column">
- - {{ $t('notes.publication.post.in.feed.label') }} +
+

+ {{ $t('notes.publication.post.in.feed.label') }} +

- +
@@ -187,7 +195,7 @@ export default { }, computed: { saveButtonLabel() { - return (this.stepper === 1 && !this.expanded) && this.$t('notes.publication.publish.next.label') + return (!this.editMode && this.stepper === 1 && !this.expanded) && this.$t('notes.publication.publish.next.label') || this.$t('notes.publication.publish.save.label'); }, summaryLengthError() { @@ -217,6 +225,9 @@ export default { }, open(noteObject) { this.noteObject = noteObject; + if (this.editMode) { + this.publicationSettings.post = this.noteObject?.activityPosted; + } this.cloneProperties(); this.$refs.publicationDrawer.open(); this.toggleExpand(); @@ -253,6 +264,10 @@ export default { }, 1000); }, save() { + if (this.editMode) { + this.$emit('publish', this.publicationSettings); + return; + } if (!this.expanded && this.stepper === 1) { this.stepper += 1; return; diff --git a/notes-webapp/src/main/webapp/vue-app/notes-publication/initComponents.js b/notes-webapp/src/main/webapp/vue-app/notes-publication/initComponents.js new file mode 100644 index 0000000000..7c7fc54b70 --- /dev/null +++ b/notes-webapp/src/main/webapp/vue-app/notes-publication/initComponents.js @@ -0,0 +1,11 @@ +import NotePublicationDrawer from './components/NotePublicationDrawer.vue'; +import NoteMetadataPropertiesForm from '../notes-rich-editor/components/note-properties/NoteMetadataPropertiesForm.vue'; + +const components = { + 'note-publication-drawer': NotePublicationDrawer, + 'note-metadata-properties-form': NoteMetadataPropertiesForm +}; + +for (const key in components) { + Vue.component(key, components[key]); +} diff --git a/notes-webapp/src/main/webapp/vue-app/notes-publication/main.js b/notes-webapp/src/main/webapp/vue-app/notes-publication/main.js new file mode 100644 index 0000000000..73ebc6d78d --- /dev/null +++ b/notes-webapp/src/main/webapp/vue-app/notes-publication/main.js @@ -0,0 +1,11 @@ +import './initComponents.js'; + +// get overrided components if exists +if (extensionRegistry) { + const components = extensionRegistry.loadComponents('notesPublication'); + if (components && components.length > 0) { + components.forEach(cmp => { + Vue.component(cmp.componentName, cmp.componentOptions); + }); + } +} diff --git a/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/initComponents.js b/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/initComponents.js index 55c0e4f829..b98d5b607e 100644 --- a/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/initComponents.js +++ b/notes-webapp/src/main/webapp/vue-app/notes-rich-editor/initComponents.js @@ -5,7 +5,6 @@ import NoteEditorTopBar from '../notes-rich-editor/components/NoteEditorTopBar.v import NoteFullRichEditor from './components/NoteFullRichEditor.vue'; import NoteEditorMetadataDrawer from './components/note-properties/NoteEditorMetadataDrawer.vue'; import NoteEditorFeaturedImageDrawer from './components/note-properties/NoteEditorFeaturedImageDrawer.vue'; -import NotePublicationDrawer from './components/note-publication/NotePublicationDrawer.vue'; import NoteMetadataPropertiesForm from './components/note-properties/NoteMetadataPropertiesForm.vue'; const components = { @@ -16,7 +15,6 @@ const components = { 'note-full-rich-editor': NoteFullRichEditor, 'note-editor-metadata-drawer': NoteEditorMetadataDrawer, 'note-editor-featured-image-drawer': NoteEditorFeaturedImageDrawer, - 'note-publication-drawer': NotePublicationDrawer, 'note-metadata-properties-form': NoteMetadataPropertiesForm }; diff --git a/notes-webapp/webpack.prod.js b/notes-webapp/webpack.prod.js index 022fdf509b..a896dc3f8e 100644 --- a/notes-webapp/webpack.prod.js +++ b/notes-webapp/webpack.prod.js @@ -19,7 +19,9 @@ const config = { engagementCenterExtensions: './src/main/webapp/vue-app/engagementCenterExtensions/extensions.js', connectorEventExtensions: './src/main/webapp/vue-app/connectorEventExtensions/extensions.js', notePageView: './src/main/webapp/vue-app/note-page-view/main.js', - notesNotificationExtension: './src/main/webapp/vue-app/notification-extensions/main.js' + notesNotificationExtension: './src/main/webapp/vue-app/notification-extensions/main.js', + notesPublication: './src/main/webapp/vue-app/notes-publication/main.js', + }, output: { publicPath: '',